CmdRunner - 3d game (CubeRunner clone)

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
misol101
Posts: 465
Joined: 02 May 2016 18:20

Re: CmdRunner - 3d game (CubeRunner clone)

#16 Post by misol101 » 27 Jun 2016 10:03

misol101 wrote:Ahh, ok, I didn't know about the empty parantheses. Interesting solution with the "while loop" there though. But doesn't make sense for this game (edit: was curious, so changed gameloop into a WHILE loop Aacini style... no noticeable speed difference).


Umm, scratch that! :) Actually after some more fiddling around using the while loops make the game another 8% or so faster! Did not update the archive yet.

A much easier way to increase speed though is to decrease the MAXCUBES variable. Just changing it from 30 to 26 increases the game speed around 10% !

Makes me wonder why... it's certainly not cmdgfx which takes so much shorter just drawing 4 less shapes... It seems it might be because of the string concatenation, it just grows larger and larger and lots of data in ENV variables is bad for speed apparently. But I don't know what else to do?

Also, I played around with event-driven multi-threading as in viewtopic.php?f=3&t=6601 ... It's working, but it ain't faster so far... I think the threads waiting for each other kills the speed increase... or I'm doing something wrong (I'm using "method A" from the link above)

aGerman
Expert
Posts: 4005
Joined: 22 Jan 2010 18:01
Location: Germany

Re: CmdRunner - 3d game (CubeRunner clone)

#17 Post by aGerman » 27 Jun 2016 11:44

Umm, scratch that! :) Actually after some more fiddling around using the while loops make the game another 8% or so faster!

Good to hear because you FOR /R example is beyond me :mrgreen:

lots of data in ENV variables is bad for speed apparently

Yes. Variables that you only need temporarily could be set and processed in a sub-environment using setlocal/endlocal.

Another thing you could try is changing the PATH environment. As you may know command tools are searched in the folders that are saved in %PATH% and in the same order as they appear. There are discussions in the forum where it was suggested to completely clear out the PATH (undefine the variable). Instead call the tools by their full name. E.g. C:\Window\System32\findstr.exe instead of only findstr.
Run ...

Code: Select all

@echo off &setlocal EnableDelayedExpansion
set /a int=0, ext=0
for /f %%i in ('help^|findstr /rbc:"[A-Z][ABCDEFGHIJKLMNOPQRSTUVWXYZ]"') do (
  for /f "tokens=1,2 delims=?" %%j in ("%%i.exe?%%i.com") do (
    if "%%~$PATH:j%%~$PATH:k"=="" (
      set /a int+=1
      set "line=%%i                                                  "
      echo !line:~,50! - internal
    ) else (
      set /a ext+=1
      echo %%i "%%~$PATH:j%%~$PATH:k"
    )
  )
)

echo(
echo internal %int%
echo external %ext%
pause

... in order to separate internal functions of the CMD from external console tools. (Both taken from the output of HELP.)

misol101
Posts: 465
Joined: 02 May 2016 18:20

Re: CmdRunner - 3d game (CubeRunner clone)

#18 Post by misol101 » 27 Jun 2016 12:19

Thanks for the tips!

aGerman wrote:Good to hear because your FOR /R example is beyond me :mrgreen:


:D Do you think you could run it once though? Does it actually produce an infinite loop for you as well? (increase the 2000 value)

(the rationale I used was that the code for "for /R" cannot realistically make a full depth-search of folders right away, that would take way too long if you were for example in the root of the drive. SO it doesn't know when it's supposed to stop unlike /L or /F (which seems to read the whole file at once, so the number of iterations is set from the start). Thus, if you add folders quickly enough, it never ends :)

I don't know why it needs 3 for /R in a row though... :wink:

aGerman
Expert
Posts: 4005
Joined: 22 Jan 2010 18:01
Location: Germany

Re: CmdRunner - 3d game (CubeRunner clone)

#19 Post by aGerman » 27 Jun 2016 13:06

Does it actually produce an infinite loop for you as well?

Yes it does. In principle I already understood how it works (and yes, compared with FOR /F a FOR /R doesn't buffer anything). The way how you control the number of generated and removed folders is something that I can't comprehend yet :lol: Nevermind.

einstein1969
Expert
Posts: 776
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: CmdRunner - 3d game (CubeRunner clone)

#20 Post by einstein1969 » 28 Jun 2016 08:00

misol101 wrote:
einstein1969 wrote:For achieve major performnce you can do this:
1 - Use one set/A using comma separator instead using set/A&set/a&....
2 - Using a for /L %%. () do for a loop instead using GOTO :label
3 - Do not execute every time cmdgfx. manage input into cmdgfx or use a parallel process. Look at work done in batchSNAKE by dbenham or other work done by aAcini. http://www.dostips.com/forum/viewtopic.php?f=3&t=6601


1 - That's something I should start doing, definitely. I don't think in this script that it would matter much (very few repeated "set" in the time critical sections). Perhaps if I re-structured things.
2 - I have found that to be true as well, so I use no GOTO loops except for the "infinite" ones in this script. Can I get rid of them too somehow, i.e. can I create infinite for loops? (actually I have discovered a way to make infinite for loops (a double "for /R" with folder creation in the loop), but it's slower than a regular GOTO loop :) )
3 - In this script and in general I concatenate strings and only run cmdgfx.exe once per frame. Is that what you mean by "manage input?"
Parallell processing sounds interesting! (and kind of tricky, I'll read the link)


2-
I have tested a goto :label with "paretnthesis block" and seem 50% faster. But the faster is FOR /L with break condition

Code: Select all

@echo off
setlocal EnableDelayedExpansion

set MaxIter=10000

rem First loop using GOTO :LABEL

set t1=%time%

set L=0

:loop

set /a L+=1

if !L! lss !MaxIter! goto :loop

for /F "tokens=1-8 delims=:.," %%a in ("!t1!:!time: =0!") do set /a "a=(((1%%e-1%%a)*60)+1%%f-1%%b)*6000+1%%g%%h-1%%c%%d, a+=(a>>31)&8640000"

echo elapsed %a%0ms !L!

pause

rem second LOOP using Parenthesis block

set t1=%time%

set L=0

:loop1
(
set /a L+=1

if !L! lss !MaxIter! goto :loop1)

for /F "tokens=1-8 delims=:.," %%a in ("!t1!:!time: =0!") do set /a "a=(((1%%e-1%%a)*60)+1%%f-1%%b)*6000+1%%g%%h-1%%c%%d, a+=(a>>31)&8640000"

echo elapsed %a%0ms !L!

pause

rem third loop using ONE for /L and break condition + parenthesis block

set t1=%time%

set L=0
set Break=

:loop2
(
For /L %%. in (1,1,10) do if not defined break (

set /a L+=1
if not !L! lss !MaxIter! set Break=T

)

if !L! lss !MaxIter! goto :loop2)

for /F "tokens=1-8 delims=:.," %%a in ("!t1!:!time: =0!") do set /a "a=(((1%%e-1%%a)*60)+1%%f-1%%b)*6000+1%%g%%h-1%%c%%d, a+=(a>>31)&8640000"

echo elapsed %a%0ms !L!

pause

output:

Code: Select all

elapsed 18810ms 10000
Premere un tasto per continuare . . .
elapsed 15430ms 10000
Premere un tasto per continuare . . .
elapsed 2260ms 10000
Premere un tasto per continuare . . .



but I prefer a cascade for loop with fast exit...

Code: Select all

rem this define 100 loops with fast escape.
for /L %%1 in (1,1,10) do if not defined break for /L %%2 in (1,1,10) do if not defined break (
(
   rem loop code here
   rem if condition of exit is true define "break" variable
)


3- yes, but this mode is not for generic utility. I thinks on SERVER/SLAVE architecture where the server is alway run and
execute slave commands

Code: Select all

SLAVE | SERVERcmdgfx


The slave manage input and generate the output for cmdgfx that visulize result. etc
The time of execute every time cmdgfx in this manner is off (zero)

einstein1969

misol101
Posts: 465
Joined: 02 May 2016 18:20

Re: CmdRunner - 3d game (CubeRunner clone)

#21 Post by misol101 » 28 Jun 2016 10:38

einstein1969 wrote:but I prefer a cascade for loop with fast exit...


Ah, yes, don't know why I didn't think of that... And then to make it infinite, you could just have a single GOTO outside the loop (in this case, 1 goto per 1000000 runs):

Code: Select all

set STOP=
:INF_LOOP
for /L %%a in (1,1,100) do if not defined STOP for /L %%b in (1,1,100) do if not defined STOP for /L %%c in (1,1,100) do if not defined STOP (

  rem if condition of exit is true define "STOP" variable
)
if not defined STOP goto INF_LOOP




einstein1969 wrote:

Code: Select all

SLAVE | SERVERcmdgfx



I have tried a setup like this based on the link you posted earlier, so far I don't see a speed increase but I agree there should be one. I'm having some deadlock issues too but I'll keep trying :)


Edit: no more deadlocks, still not faster.
Last edited by misol101 on 29 Jun 2016 11:51, edited 1 time in total.

misol101
Posts: 465
Joined: 02 May 2016 18:20

Re: CmdRunner - 3d game (CubeRunner clone)

#22 Post by misol101 » 28 Jun 2016 15:31

Archives updated again.

The game(s) is now about 8% faster due to using for loops instead of goto's even for the infinite loops.

First I was using "while" loops as discussed earlier but the speed increase was the same and normal for /L loops are simpler to deal with.

misol101
Posts: 465
Joined: 02 May 2016 18:20

Re: CmdRunner - 3d game (CubeRunner clone)

#23 Post by misol101 » 03 Jul 2016 07:42

Updated the archive in the link in the first post.

The game is again about 5-6% faster due to an improvement in cmdgfx that re-uses 3d objects without having to read the file/parse again.


The other thing I included this time is cmdrunner_t.bat. This is just a test using threading to improve speed even more, as described here: viewtopic.php?f=3&t=6601 (I use approach A) : master | slave

Unfortunately though, it's not faster but actually slower. (NOTE: At the moment I only use threading in the idle loop, i.e. before the game is started with SPACE. But comparing this initial screen with the single-threaded cmdrunner.bat, it is clearly slower)

On my machine, for 30 cubes the cmdgfx command takes about 50% of the time, while everything else takes the remaining 50%. By moving the cmdgfx call to its own thread, theoretically it should be possible to make the game twice as fast. But this is not happening.

Can anybody with experience in this find some reason why, or perhaps even re-write the thing? To communicate between threads I write all the operations for cmdgfx to a file from T1, then send a command over the pipe to "draw", and on the other side (T2) I read the file, and assemble the variable, and then draw it with cmdgfx. Meanwhile thread 1 is supposed to prepare the next batch of operations to draw

Actually, is it even sure that Windows scheduler will allow T1 and T2 to get as much processing time each as they would if they didn't run concurrently? If not, maybe 1+1 will be closer to 1 than 2 with this approach...
Last edited by misol101 on 04 Jul 2016 05:53, edited 2 times in total.

misol101
Posts: 465
Joined: 02 May 2016 18:20

Re: CmdRunner - 3d game (CubeRunner clone)

#24 Post by misol101 » 04 Jul 2016 05:32

Perhaps it's easier if I just post the relevant section(s) from the code of cmdrunner_t.bat :

Code: Select all

set "spaces= "
for /L %%i in (1,1,10) do set "spaces=!spaces!!spaces!"

...

"%~NX0" IDLELOOP 3>&1 1>&2 | "%~NX0" ThreadA 1

...

:IDLELOOP
del /Q a? 2>NUL
set SWITCH=0
set "output=draw%spaces%"
set "output=%output:~0,1016%"
echo 0 >key
set KEY=0

:IDLELOOPER
set /A INDEX=%STARTINDEX%-1
for /L %%b in (1,1,%MAXCUBES%) do set /A INDEX+=1&(if !INDEX! gtr %MAXCUBES% set INDEX=1)& for %%a in (!INDEX!) do echo  ^& 3d cube.ply %DRAWMODE% 0,%RY%,0 !PX%%a!,-1800,!PZ%%a! -250,0,0,0 0,0,0,10 %XMID%,%YMID%,%DIST%,%ASPECT% !CPAL%%a!>>a!SWITCH!&set /A PZ%%a-=%ACCSPEED% & if !PZ%%a! lss 1000 set PZ%%a=30000&set /A PX%%a=!RANDOM! %% 8000 - 4000&set /A STARTINDEX-=1&if !STARTINDEX! lss 1 set STARTINDEX=%MAXCUBES%
echo 1: !SWITCH! !output!>&3
set /A TSWITCH=1-!SWITCH!
:WAITLOOP
if exist a!TSWITCH! goto WAITLOOP
if exist key set /p KEY=<key
set /a RY+=8
set /A SWITCH=1-!SWITCH!
if %KEY% == 27 goto ESCAPE
if not %KEY% == 32 goto IDLELOOPER

...



:ThreadA
   set /P "command="
   for /F "tokens=1-3" %%a in ("%command%") do (
      if "%%a" equ "%myID%:" (
      if "%%c" == "draw" (
            set CRSTR=""
            for /F "tokens=*" %%a in (a%%b) do set CRSTR="!CRSTR:~1,-1!%%a"
            cmdgfx "%BKSTR:~1,-1% & image CR2.gxy 0 0 20 28,2 & !CRSTR:~1,-1! & text f 1 _Press_SPACE_to_play_ 80,15" k
            echo !ERRORLEVEL!>key
            set CRSTR=
            del /Q a%%b
         )
      ) else (
         echo %command%
      )
   )
if "%command:~5,4%" neq "exit" goto ThreadA


misol101
Posts: 465
Joined: 02 May 2016 18:20

Re: CmdRunner - 3d game (CubeRunner clone)

#25 Post by misol101 » 05 Jul 2016 08:02

Another archive update. I noticed the fog version didn't have infinite for loops, so added it and it's now about 8% faster (actually quite noticeably so)

Edit: Also, I increased the ACCSPEED in the fog version from 350 to 400, making it seem to have pretty much the same speed (even though the fog version actually runs about 16% slower)

foxidrive
Expert
Posts: 6033
Joined: 10 Feb 2012 02:20

Re: CmdRunner - 3d game (CubeRunner clone)

#26 Post by foxidrive » 06 Jul 2016 05:50

I notice that you don't get a lot of feedback for your code here - people must be too busy playing your games. :)

misol101
Posts: 465
Joined: 02 May 2016 18:20

Re: CmdRunner - 3d game (CubeRunner clone)

#27 Post by misol101 » 06 Jul 2016 05:58

foxidrive wrote:I notice that you don't get a lot of feedback for your code here - people must be too busy playing your games. :)


It's the only explanation that makes sense!! :mrgreen:

Naah, I'm starting to think they're not up for the challenge... Come on guys!


EDIT: Since last upload I've added an "insert file" operation to cmdgfx, so the for loop in threadA creating CRSTR could be removed. Still slower than single-threaded though...

misol101
Posts: 465
Joined: 02 May 2016 18:20

Re: CmdRunner - 3d game (CubeRunner clone)

#28 Post by misol101 » 18 May 2017 16:47

A blast from the past! :D

With the recent server addons to cmdgfx (not yet "officially releaed"), I wanted to convert some of my old games to run with server (especially since I recently learned that my non-server scripts are quite slow on some computers)

This should hopefully be quite a lot faster now (target FPS is around 66). It will take a semi-decent computer to run at that framerate though, mini-netbooks won't make it (but it might be somewhat playable anyway, or try reducing the variable MAXCUBES otherwise).

Key responsiveness and framerate is the main thing here. Running with a server only and letting it read keys is challenging, and I'm not sure how well it works on other machines. Actually this game is not really the best to check key response since the gameplay is based around pressing and *holding* (the left/right) keys, but it should give an indication still.

If I could get some feedback on this I'd be very happy! :P

Archive link is the same as before: http://www.mediafire.com/download/wj9p99po9tj92tz/cmdrunner.zip

misol101
Posts: 465
Joined: 02 May 2016 18:20

Re: CmdRunner - 3d game (CubeRunner clone)

#29 Post by misol101 » 19 Jan 2018 22:10

Archive update.

I had pretty much given up on making this game run at a reasonable pace on my Windows 10 machine, since the Batch script processing was simply too slow. I could only move about 15 cubes (of 30) at a time if I wanted to keep my target frame rate of 66.

But then it hit me: why not make a jscript hybrid instead??

....so I did a quick translation, and oh yes, it is fast! I can now easily move 100 cubes and more per frame! :D

Also, I added some music (the archive is a bit bigger due to that)


Current script:

Code: Select all

@if (true == false) @end /*
@echo off
bg font 6 & cls
cmdwiz showcursor 0

if defined __ goto :START
set __=.
cmdgfx_input.exe m0unW14x | call %0 %* | cmdgfx_gdi "" Sf0:0,0,180,110W0
set __=
goto :eof

:START
setlocal EnableDelayedExpansion
set /a F6W=180/2, F6H=110/2
mode %F6W%,%F6H%

cmdwiz getdisplaydim w & set SW=!errorlevel!
cmdwiz getdisplaydim h & set SH=!errorlevel!
cmdwiz getwindowbounds w & set WINW=!errorlevel!
cmdwiz getwindowbounds h & set WINH=!errorlevel!
set /a WPX=%SW%/2-%WINW%/2, WPY=%SH%/2-%WINH%/2-20
cmdwiz setwindowpos %WPX% %WPY%

cscript //nologo //e:javascript "%~dpnx0" %*
::cmdwiz getch & rem Enable this line to see jscript parse errors

mode 80,50
echo "cmdgfx: quit"
title input:Q
endlocal
exit /b 0 */


var W=180, H=110, RY=0
var XMID=W/2, YMID=H/2-53
var DIST=2500, ASPECT=0.6925
var DRAWMODE=0, GROUNDCOL=3, PLYCHAR="db"

var ACCSPEED=270
var MAXCUBES=30

var fs = new ActiveXObject("Scripting.FileSystemObject")
var shell = new ActiveXObject("WScript.Shell")

var HISCORE=0
var inputfile = "hiscore.dat";
if (fs.FileExists(inputfile))
{
	var f1 = fs.OpenTextFile(inputfile, 1)  // 1=ForReading
    HISCORE = parseInt(f1.ReadLine())
    f1.close()
}

var cubecols = [
	["4 c db 4 c db  4 c b1  4 c b1  4 c 20", "6 0 db 6 0 db  6 e b1  6 e b1  6 e 20", "2 a db 2 a db  2 a b1  2 a b1  2 a 20", "5 d db 5 d db  5 d b1  5 d b1  5 d 20"],
	["4 1 b2 4 1 b2  4 c b2  4 c b2  0 c b1", "6 1 b2 6 1 b2  6 e b2  6 e b2  0 e b1", "2 1 b2 2 1 b2  2 a b2  2 a b2  0 a b1", "5 1 b2 5 1 b2  5 d b2  5 d b2  0 d b1"],
	["4 0 b0 4 0 b0  4 0 b1  4 0 b1  4 0 b2", "6 0 b0 6 0 b0  6 0 b1  6 0 b1  6 0 b2", "2 0 b0 2 0 b0  2 0 b1  2 0 b1  2 0 b2", "5 0 b0 5 0 b0  5 0 b1  5 0 b1  5 0 b2"]
];

shell.Exec("cmd /c dlc.exe -p paparazzi.mp3 paparazzi.mp3 paparazzi.mp3 paparazzi.mp3 paparazzi.mp3 paparazzi.mp3 paparazzi.mp3 paparazzi.mp3 paparazzi.mp3 paparazzi.mp3");


do {
	var NOFCUBES=15, SCORE=0, TILT=0, ACTIVECUBES=0

	var CURRZ=30000
	var ACZ=CURRZ/MAXCUBES

	var PX=[0], PY=[0], PZ=[0], CPAL=[0]
	for (j = 1; j <= MAXCUBES; j++) {
		CURRZ-=ACZ; PZ.push(CURRZ + Math.floor(Math.random() * ACZ)); PX.push(Math.floor(Math.random() * 8000) - 4000); PY.push(-18000); CPAL.push(Math.floor(Math.random() * 4));
	}

	var STARTINDEX=1
	shell.Exec("cmd /c echo W14>inputflags.dat"); 

	var BKSTR="fbox 0 1 b1 0,0," + W + ",10 & fbox 0 1 20 0,10," + W + ",5 & fbox 9 1 b1 0,15," + W + ",5 & fbox 9 1 db 0,19," + W + ",1  &  fbox 0 0 20 0,21," + W + ",5 & fbox 0 " + GROUNDCOL + " b2 0,23," + W + ",5 & fbox 0 " + GROUNDCOL + " b1 0,27," + W + ",10 & fbox 0 " + GROUNDCOL + " b0 0,34," + W + ",22 & fbox 8 " + GROUNDCOL + " 20 0,50," + W + ",100 "
	var stop=0, death=0

	while (stop == 0) {
		I=STARTINDEX-1
		WScript.Echo("\"cmdgfx: " + BKSTR + "\" n")

		for (j = 1; j <= MAXCUBES; j++) {
			I++
			if (I > MAXCUBES) I=1;
			var COLD=Math.floor((PZ[I]-5000)/10500); if (COLD < 0) COLD=0
			WScript.Echo("\"cmdgfx: 3d cube.ply " + DRAWMODE + ",-1 0," + RY + ",0 " + PX[I] + ",-1800," + PZ[I] + "  -250,-250,-250,0,0,0 0,0,0,10 " + XMID + "," + YMID + "," + DIST + "," + ASPECT + " " + cubecols[COLD][CPAL[I]] + "\" n")

			PZ[j]-=ACCSPEED
			if (PZ[I] < 1000) {
				PZ[I]=30000
				PX[I]=Math.floor(Math.random() * 8000) - 4000
				STARTINDEX-=1; if (STARTINDEX < 1) STARTINDEX=MAXCUBES
			}
		}
		
		WScript.Echo("\"cmdgfx: image CR2.gxy 0 0 0 20 28,2 & text f 1 0 _Press_SPACE_to_play_ 80,15\"")

		var input = WScript.StdIn.ReadLine()
		var ti = input.split(" ")
		if (ti[3] == "1")
		{
			var key=ti[5]
			if (key == "27") {
				stop=2
			}
			if (key == "32") {
				stop=1
			}
		}
		RY+=8
	}


	if (stop <= 1) {
		stop=0, death=0
		shell.Exec("cmd /c echo W15>inputflags.dat"); 
		var ACTIVE_KEY=0
		
		while (stop == 0) {
			I=STARTINDEX-1
			WScript.Echo("\"cmdgfx: " + BKSTR + "\" n")
			
			for (j = 1; j <= MAXCUBES; j++) {
			
				if (PY[j] > -15000 && PZ[j] < 4000 && PZ[j] > 3500 && PX[j] > -300 && PX[j] < 300) death=1

				I++
				if (I > MAXCUBES) I=1;
				var COLD=Math.floor((PZ[I]-5000)/10500); if (COLD < 0) COLD=0
				WScript.Echo("\"cmdgfx: 3d cube.ply " + DRAWMODE + ",-1 0," + RY + ",0 " + PX[I] + "," + PY[I] + "," + PZ[I] + "  -250,-250,-250,0,0,0 0,0,0,10 " + XMID + "," + YMID + "," + DIST + "," + ASPECT + " " + cubecols[COLD][CPAL[I]] + "\" n")

				PZ[j]-=ACCSPEED
				if (PZ[I] < 1000) {
					PZ[I]=30000
					PX[I]=Math.floor(Math.random() * 8000) - 4000 - TILT*50
					if (ACTIVECUBES <= NOFCUBES && PY[I] < -1800 && Math.random() < 0.3333) { PY[I]=-1800; ACTIVECUBES+=1; }
					STARTINDEX-=1; if (STARTINDEX < 1) STARTINDEX=MAXCUBES
				}
			}

			WScript.Echo("\"cmdgfx: 3d tetramod.ply " + DRAWMODE + ",-1 0,180," + TILT + " 0,-1800,4000 -50,-50,-50,0,0,0 1,0,0,10 " + XMID + "," + YMID + "," + DIST + "," + ASPECT + " f " + GROUNDCOL + " " + PLYCHAR + " 7 " + GROUNDCOL + " " + PLYCHAR + " & 3d tetramod.ply " + DRAWMODE + ",-1 0,180," + TILT + " 0,-1900,4000 -50,-50,-50,0,0,0 1,0,0,10 " + XMID + "," + YMID + "," + DIST + "," + ASPECT + " 0 " + GROUNDCOL + " b2 0 " + GROUNDCOL + " b2 & text 7 1 0 SCORE:_" + SCORE + "_(" + HISCORE + ") 2,1  \"")

			if (death==1) {
				stop = 1
				for (k = 1; k <= 80; k++) {
					WScript.Echo("\"cmdgfx: " + BKSTR + "\" n")
					I=STARTINDEX-1
					for (j = 1; j <= MAXCUBES; j++) {
						I++
						if (I > MAXCUBES) I=1;
						var COLD=Math.floor((PZ[I]-5000)/10500); if (COLD < 0) COLD=0
						WScript.Echo("\"cmdgfx: 3d cube.ply " + DRAWMODE + ",-1 0," + RY + ",0 " + PX[I] + "," + PY[I] + "," + PZ[I] + "  -250,-250,-250,0,0,0 0,0,0,10 " + XMID + "," + YMID + "," + DIST + "," + ASPECT + " " + cubecols[COLD][CPAL[I]] + "\" n")
					}
					TILT+=20
					WScript.Echo("\"cmdgfx: 3d tetramod.ply " + DRAWMODE + ",-1 0,180," + TILT + " 0,-1800,4000 -50,-50,-50,0,0,0 1,0,0,10 " + XMID + "," + YMID + "," + DIST + "," + ASPECT + " f " + GROUNDCOL + " " + PLYCHAR + " 7 " + GROUNDCOL + " " + PLYCHAR + " & text 7 1 0 SCORE:_" + SCORE + "_(" + HISCORE + ") 2,1  \"")
				}
			}

			var input = WScript.StdIn.ReadLine()
			var ti = input.split(" ")
			var key = ti[5]
			if (ti[3] == "1")
			{
				if (key == "27") stop=1
				if (key == "331") ACTIVE_KEY=331
				if (key == "333") ACTIVE_KEY=333
			} else {
				if (key == "331" || key == "333") ACTIVE_KEY=0
			}
			
			NOFCUBES = 15 + Math.floor(SCORE/250)
			if (NOFCUBES > MAXCUBES) NOFCUBES=MAXCUBES
			
			if (TILT > 0) TILT-=1
			if (TILT < 0) TILT+=1

			if (ACTIVE_KEY==331) TILT+=4; if (TILT > 55) TILT=55
			if (ACTIVE_KEY==333) TILT-=4; if (TILT <-55) TILT=-55

			if (TILT != 0) for (j = 1; j <= MAXCUBES; j++) PX[j]+=TILT
			
			RY+=8, SCORE+=1
			if (SCORE > HISCORE) HISCORE = SCORE			
		}

		f1 = fs.OpenTextFile(inputfile, 2, true)  // 2=ForWriting
		f1.WriteLine(HISCORE + "")
		f1.close()
	}

} while (stop <= 1)

shell.Exec("cmd /c taskkill.exe /F /IM dlc.exe>nul")

misol101
Posts: 465
Joined: 02 May 2016 18:20

Re: CmdRunner - 3d game (CubeRunner clone)

#30 Post by misol101 » 05 Dec 2019 07:54

Archive update! :)

According to Mediafire's download stats, Cmdrunner keeps being downloaded at a steady pace. It actually has more downloads than Cmdgfx now (but not as many as Blockout, another unsolved mystery).

It's a bit funny, because all games I've made (Cmdrunner, Blockout, Mariorun, Pong3d) are included in the Cmdgfx archive already (I suppose that's not common knowledge).

Anyway, I realized now that Cmdrunner archive was not updated in a long time and actually has a faulty "death animation" (it runs too fast on fast machines). This bug in the script was fixed in Cmdgfx archive some time ago but not in the Cmdrunner archive. But, now it is.

Another technical change is that the game now utilizes Cmdgfx's Z-buffer. This simplifies the script because there is no longer a need to manually keep track of in which order cubes should be drawn.

Post Reply