Skip to content

Commit

Permalink
archclip: special-case version of arch
Browse files Browse the repository at this point in the history
  • Loading branch information
jmtd committed Jun 14, 2022
1 parent 33a697a commit efe8a5b
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
7 changes: 7 additions & 0 deletions doc/reference.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,13 @@ width, i.e. if width = 128, then subdivision = 64 gives you sectors of 2 units w
Arch adds to xoff automatically to reduce funny texturing. On the y axis it is best
if you precede arch by unpegged.


archclip(height,width,depth,subdivision,floor,lightlevel,clip)

This is a special-case version of arch which has an additional parameter, clip, to
cut short generating the arch. This can be used to create structures such as gothic
arches.

mergesectors

turns sector merge mode on. In this mode WadC will check for existing sectors
Expand Down
3 changes: 3 additions & 0 deletions doc/release_notes.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ Thank you Kayvan, for introducing me to Doom, amongst many other things.

=== Language features

* New (experimental) built-in `archclip`: behaves the same as `arch`,
but stops generating the arch after N units, where N is the seventh
parameter supplied
* Two new built-ins: `getx` and `gety` return the cursor's current X/Y
position.

Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/redmars/wadc/Builtin.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Builtin {
Exp eval(Exp a, Exp b, Exp c, Exp d) { return null; }
Exp eval(Exp a, Exp b, Exp c, Exp d, Exp e) { return null; }
Exp eval(Exp a, Exp b, Exp c, Exp d, Exp e, Exp f) { return null; }
Exp eval(Exp a, Exp b, Exp c, Exp d, Exp e, Exp f, Exp g) { return null; }
Exp eval(Exp a, Exp b, Exp c, Exp d, Exp e, Exp f, Exp g, Exp h) { return null; }
};

39 changes: 39 additions & 0 deletions src/main/java/org/redmars/wadc/WadRun.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,38 @@ void addBuiltins() {
return n;
}});

builtin("archclip", 7, new Builtin() { Exp eval(Exp a, Exp b, Exp c, Exp d, Exp e, Exp f, Exp g) {
int height = a.ival();
int width = b.ival();
int depth = c.ival();
int steps = d.ival();
int step = width/steps;
floor = e.ival();
lightlevel = f.ival();

int maxLength = g.ival(); // maximum length we will generate, to make shortened arches
int curLength = 0;

for(int i = 0; i<steps && curLength < maxLength; i++) {
step = width/steps;
if( (maxLength - curLength) < step) {
step = maxLength - curLength;
}
curLength += step;

int xtra = (int)(Math.sin(Math.acos(2*i/(double)steps-1.0))*width/2);
step(step,0);
step(0,depth);
step(-step,0);
step(0,-depth);
step(step,0);
makesector(true,-1,floor,floor+height+xtra,lightlevel);
xoff += step;
}
return n;
}});


builtin("arch", 6, new Builtin() { Exp eval(Exp a, Exp b, Exp c, Exp d, Exp e, Exp f) {
int height = a.ival();
int width = b.ival();
Expand Down Expand Up @@ -1336,6 +1368,13 @@ Exp call(Id caller) {
((Exp)v.elementAt(3)).eval(this),
((Exp)v.elementAt(4)).eval(this),
((Exp)v.elementAt(5)).eval(this)); break;
case 7: r = b.eval(((Exp)v.elementAt(0)).eval(this),
((Exp)v.elementAt(1)).eval(this),
((Exp)v.elementAt(2)).eval(this),
((Exp)v.elementAt(3)).eval(this),
((Exp)v.elementAt(4)).eval(this),
((Exp)v.elementAt(5)).eval(this),
((Exp)v.elementAt(6)).eval(this)); break;
case 8: r = b.eval(((Exp)v.elementAt(0)).eval(this),
((Exp)v.elementAt(1)).eval(this),
((Exp)v.elementAt(2)).eval(this),
Expand Down

0 comments on commit efe8a5b

Please sign in to comment.