This one brings greatly improved speed, because the whole thing (almost) was converted to Javascript!
The old version is still kept in the Batch folder, while the new fast version is in the JScript folder (run BWin.bat in both cases).
At first it seemed to be only about 4 times faster, but then it turned out that string concatenation of very long strings was slowing Javascript down. When I split the cmdgfx input to several steps per frame (and thus, much shorter strings), speed increased dramatically, and is now 10+ times faster than the batch version!
So, on my Win7 machine, this means I can now have 90-100 windows open before I see any lag. On my WIn10 machine it is 30-40 (depending a lot on if Windows10 decides to run other programs like antimalware checkers in the background ).
With this newfound speed, this script is almost starting to look like a real window manager . Therefore, the program was renamed to BWin
It's also easier to decipher the met files now. For example, the mouse-controlled game.met went from this:
Code: Select all
set W[]_NAME="Game \80(SPACE to restart)"
set /a W[]_W=60, W[]_H=30
set /a W[]_X=28, W[]_Y=31
set /a W[]_XA=1, W[]_YA=1
set /a W[]_ACTIVE=1, W[]_CLOSE=1, W[]_SIZE=1, W[]_CLEAR=1, W[]_SCROLL=0, W[]_EXP=6
set W[]_INIT="set /a DELT[]=1, REPL1_[]=0, BX[]=12, BY[]=2, BDX[]=1, BDY[]=1, SCO[]=0"
set W[]_UPDATE="set /a XWALL=W[]_W-3, YWALL=W[]_H-5, REPL1=REPL1_[],REPL2=OFF_Y+YWALL+1, BX[]+=BDX[], BY[]+=BDY[] & (if ^!FOCUSWIN^!==[] (if ^!KEY^!==32 set /a SCO[]=0, BX[]=2+^!RANDOM^!%XWALL, BY[]=2, BDX[]=1-^!RANDOM^!%2*2, BDY[]=1) & (if ^!M_X^! gtr 0 set /a LMX[]=M_X) & set /a REPL1_[]=OFF_X+LMX[]-W[]_X-4, REPL1=REPL1_[]) & (if ^!BX[]^! lss 1 set /a BDX[]=1) & (if ^!BX[]^! gtr ^!XWALL^! set /a BDX[]=-1) & (if ^!BY[]^! lss 1 set /a BDY[]=1) & (if ^!BY[]^! == ^!YWALL^! set /a TMPX=OFF_X+BX[]-4, CMPX=REPL1-TMPX & (if ^!CMPX^! lss 0 set /a CMPX=-CMPX) & (if ^!CMPX^! leq 4 set /a BDY[]=-1, SCO[]+=1)) & set /a REPL3=OFF_X+BX[], REPL4=OFF_Y+BY[], SCORE=SCO[]"
set W[]_CONTENT="fbox a 0 db REPL1,REPL2,8,0 & pixel c 0 @ REPL3,REPL4 & text e 0 0 \n_Score:^!SCORE^! OFF_X,OFF_Y"
Code: Select all
w.name="Game \\80(SPACE to restart)"
w.x=28, w.y=31
w.width=60, w.height=30
w.xa=1, w.ya=1
w.closeable=true, w.resizeable=true, w.scrollable=false
w.init="w.bx=12, w.by=2, w.bdx=1, w.bdy=1, w.oldMx=-100, w.score=0"
w.update="xWall = w.width-3, yWall = w.height-5;" +
"w.bx += w.bdx, w.by += w.bdy;" +
"if (w == focusWin) {" +
"if (KEY==32) w.score=0, w.bx = GetRandom(0,xWall), w.by=2, w.bdx = 1-GetRandom(0,1)*2, w.bdy=1;" +
"if (M_X > 0) { w.oldMx = OFF_X + M_X - w.x - 4 }" +
"}" +
"if (w.bx < 1) w.bdx = 1;" +
"if (w.bx > xWall) w.bdx = -1;" +
"if (w.by < 1) w.bdy = 1;" +
"if (w.by == yWall) { cmpx = Math.abs(w.oldMx - (OFF_X+w.bx-4)); if (cmpx <= 4) w.bdy=-1, w.score+=1; }" +
"REPL1 = w.oldMx, REPL2 = OFF_Y + yWall + 1, REPL3 = OFF_X+w.bx, REPL4 = OFF_Y+w.by, REPL5 = w.score"
w.content="fbox a 0 db REPL1,REPL2,8,0 & pixel c 0 @ REPL3,REPL4 & text e 0 0 \\n_Score:REPL5 OFF_X,OFF_Y"
EDIT: Classic Snake.met game added (Javascript version only)