MarioRun - 2d scrolling game with parallax background

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

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

MarioRun - 2d scrolling game with parallax background

#1 Post by misol101 » 25 Jun 2016 17:49

You control Mario in this silly little game, don't run into the bad guys!

Keys:

SPACE or UP to jump
DOWN to crouch (you can hold down the key to keep crouching)
LEFT to run backwards (funny thing in this game: you can actually run away from the enemies, at least in the beginning of the game. However you get no points when you run backwards)
RIGHT to run forward. Quickly shifting direction back and forth can save your life in many cases.

Download here: http://www.mediafire.com/download/4gffc0wa8y6zhga/mariorun.zip

Image
Last edited by misol101 on 16 Apr 2017 14:08, edited 1 time in total.

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

Re: MarioRun - 2d scrolling game with parallax background

#2 Post by misol101 » 25 Jun 2016 17:52

Here is the script:

Code: Select all

:: Parallax scrolling jumping game : Mikael Sollenborn 2016
@echo off
setlocal ENABLEDELAYEDEXPANSION
cls & bg font 0
set W=240&set H=110
mode con lines=%H% cols=%W%
mode con rate=31 delay=0
for /F "Tokens=1 delims==" %%v in ('set') do if not %%v==H if not %%v==W set "%%v="
color 07
set HISCORE=0&if exist hiscore.dat for /F "tokens=*" %%i in (hiscore.dat) do set /A HISCORE=%%i

:OUTERLOOP
set MIN_ADV_L1=60
set /A HILLS_L1=%W%/%MIN_ADV_L1% + 2
set /A WX=0
for /L %%b in (1,1,%HILLS_L1%) do set WL1_%%b=!WX!&set /A WLW1_%%b=!RANDOM!%%40+30&set /A WLH1_%%b=!WLW1_%%b!+!RANDOM!%%37&set /A WX+=!RANDOM! %% 60 + %MIN_ADV_L1%&set /A WLW1b_%%b=!WLW1_%%b!+5

set MIN_ADV_L2=60
set /A HILLS_L2=%W%/%MIN_ADV_L2% + 2
set /A WX=0
for /L %%b in (1,1,%HILLS_L2%) do set WL2_%%b=!WX!&set /A WLW2_%%b=!RANDOM!%%30+20&set /A WLH2_%%b=!WLW2_%%b!+!RANDOM!%%19+50&set /A WX+=!RANDOM! %% 60 + %MIN_ADV_L2%&set /A WLW2b_%%b=!WLW2_%%b!+2

set /A WMAX=%W%+100
set DIR=1
set PLXPOS=20
set /A PLXB=%PLXPOS%+18
set /A PLXB2=%PLXPOS%-19
set PLYPOS=85
set JMP=0&set JMPV=0
set DWN=0&set DWNV=0
set PLNAME=mario

set NOF_ENEMIES=3
set ENEMY_MUL=100
set ENEMY_MINDIST=60
set ENEMY_DISTRANGE=100
set /A EX=(%W%+30)
for /L %%a in (1,1,%NOF_ENEMIES%) do set /A ENEMY%%aX=!EX!*%ENEMY_MUL%&set /A EX+=%ENEMY_MINDIST% + (!RANDOM! %% %ENEMY_DISTRANGE%)&set /A EY=!RANDOM! %% 3&set /A ENEMY%%aY=88-(!EY! * 14)&set ENEMY%%aI=1&(if !EY! geq 1 set ENEMY%%aI=2)
set ENEMY_S=80
set ENEMY_SD=100
set ENEMY_MAXS=450
set SCORE=0

set CNT=0
:SHOWLOOP
set L1=""
set /A ADD=%DIR%*(1+%CNT% %% 2)
for /L %%a in (1,1,%HILLS_L1%) do set /A WL1_%%a-=%ADD% & set CX=!WL1_%%a!& set L1="!L1:~1,-1! & fellipse 2 0 20 !CX!,98,!WLW1b_%%a!,!WLH1_%%a! & fellipse a 0 b1 !CX!,100,!WLW1_%%a!,!WLH1_%%a! & fellipse a 0 db !CX!,120,!WLW1_%%a!,!WLH1_%%a!"& set /A CX+=!WLW1_%%a!*%DIR% & set OUT=0&(if %DIR%==1 if !CX! lss -100 set OUT=1&set /A INDEX=%%a-1&if !INDEX! lss 1 set INDEX=%HILLS_L1%)&(if %DIR%==-1 if !CX! gtr %WMAX% set OUT=1&set /A INDEX=%%a+1&if !INDEX! gtr %HILLS_L1% set INDEX=1)&if !OUT!==1 for %%b in (!INDEX!) do set /A WL1_%%a=!WL1_%%b! + !RANDOM!*%DIR% %% 60 + %MIN_ADV_L1%*%DIR%&set /A WLW1_%%a=!RANDOM!%%40+30&set /A WLW1b_%%a=!WLW1_%%a!+5&set /A WLH1_%%a=!WLW1_%%a!+!RANDOM!%%37
set L2=""
set /A ADD=%DIR%*(1+%CNT% %% 1)
for /L %%a in (1,1,%HILLS_L2%) do set /A WL2_%%a-=%ADD% & set CX=!WL2_%%a!& set L2="!L2:~1,-1! & fellipse 2 0 20 !CX!,99,!WLW2b_%%a!,!WLH2_%%a! & fellipse 2 0 b0 !CX!,100,!WLW2_%%a!,!WLH2_%%a! & fellipse 2 0 db !CX!,110,!WLW2_%%a!,!WLH2_%%a!"& set /A CX+=!WLW2_%%a!*%DIR%& set OUT=0&(if %DIR%==1 if !CX! lss -100 set OUT=1&set /A INDEX=%%a-1&if !INDEX! lss 1 set INDEX=%HILLS_L2%)&(if %DIR%==-1 if !CX! gtr %WMAX% set OUT=1&set /A INDEX=%%a+1&if !INDEX! gtr %HILLS_L2% set INDEX=1)&if !OUT!==1 for %%b in (!INDEX!) do set /A WL2_%%a=!WL2_%%b! + !RANDOM!*%DIR% %% 60 + %MIN_ADV_L2%*%DIR%&set /A WLW2_%%a=!RANDOM!%%30+20&set /A WLW2b_%%a=!WLW2_%%a!+2&set /A WLH2_%%a=!WLW2_%%a!+!RANDOM!%%19+50

set PLY="" & set XFLIP=0&(if %DIR%==-1 set XFLIP=1)&set /A IMG=%CNT% %% 8/4+1&set PLY="image %PLNAME%!IMG!.gxy 0 0 0 %PLXPOS%,%PLYPOS% %XFLIP%"

set NMY=""& for /L %%a in (1,1,%NOF_ENEMIES%) do set /A ENEMY%%aX-=%ENEMY_S% + %ENEMY_SD%*%DIR%&set /A EX%%a=!ENEMY%%aX!/%ENEMY_MUL%&set NMY="!NMY:~1,-1! image e!ENEMY%%aI!_!IMG!.gxy 0 0 0 !EX%%a!,!ENEMY%%aY! 1 & "&if !EX%%a! lss -30 set /A EY=!RANDOM! %% 3&set /A ENEMY%%aY=88-(!EY! * 14)&set ENEMY%%aI=1&(if !EY! geq 1 set ENEMY%%aI=2)&(if %DIR%==1 set /A SCORE+=1)&(if !SCORE! gtr %HISCORE% set HISCORE=!SCORE!)&set /A ENEMY_S+=4&(if !ENEMY_S! geq %ENEMY_MAXS% set ENEMY_S=%ENEMY_MAXS%)&set /A TMP=%%a+%NOF_ENEMIES%-1&(if !TMP! gtr %NOF_ENEMIES% set /A TMP=!TMP!-%NOF_ENEMIES%)&for %%b in (!TMP!) do set /A EX2=!ENEMY%%bX!/%ENEMY_MUL%&set PL=0&set /A DIFF=%W%+30-!EX2!&(if !DIFF! lss !ENEMY_MINDIST! set /A PL=!ENEMY_MINDIST!-!DIFF!)&set /A ENEMY%%aX=((%W%+30)+!PL!+!RANDOM! %% %ENEMY_DISTRANGE%) * %ENEMY_MUL%

cmdgfx "fbox 1 9 b2 0,0,%W%,10 & fbox 1 9 b1 0,3,%W%,10 & fbox 1 9 b0 0,9,%W%,%H% & %L2:~1,-1% & %L1:~1,-1% & fbox a 0 20 0,95,%W%,50 & fbox a e b2 0,96,%W%,50 & fbox a e b1 0,102,%W%,50 & %PLY:~1,-1% & %NMY:~1,-1% &  text 7 1 SCORE:_%SCORE%_(%HISCORE%) 2,1"" k

set /A PLYB=%PLYPOS%+16&set /A PLYB2=%PLYPOS%-15+%DWN%*10
for /L %%a in (1,1,%NOF_ENEMIES%) do if !EX%%a! lss %PLXB% if !EX%%a! gtr %PLXB2% if !ENEMY%%aY! lss %PLYB% if !ENEMY%%aY! gtr %PLYB2% call :GAMEOVER & (if !GAMECHOICE! == 0 goto OUTERLOOP)&(if !GAMECHOICE! == 1 goto ESCAPE)

if %DWN% == 1 set /A DWNV-=1&if !DWNV! lss 0 set DWN=0&set PLNAME=mario
if %JMP% == 1 set /A PLYPOS-=%JMPV%/32*4&set /A JMPV-=4&if !JMPV! lss -64 set PLYPOS=85&set JMP=0

if !ERRORLEVEL!==27 goto ESCAPE
if !ERRORLEVEL!==331 set DIR=-1
if !ERRORLEVEL!==333 set DIR=1
if !ERRORLEVEL!==328 if %JMP%== 0 set JMPV=64&set JMP=1&set DWN=0&set DWNV=0&set PLNAME=mario
if !ERRORLEVEL!==32 if %JMP%== 0 set JMPV=64&set JMP=1&set DWN=0&set DWNV=0&set PLNAME=mario
if !ERRORLEVEL!==336 if %JMP%== 0 if %DWNV% lss 4 set /A DWNV=24 - %ENEMY_S%/47&set DWN=1&set PLNAME=mariosmall

set /A ENEMY_MINDIST=60 + %ENEMY_S%/15
set /A ENEMY_DISTRANGE=100 - %ENEMY_S%/15

set /A CNT+=1
goto SHOWLOOP

:ESCAPE
echo %HISCORE% >hiscore.dat
endlocal
mode con cols=80 lines=50
cls & bg font 6
goto :eof

:GAMEOVER
set GAMECHOICE=0
gotoxy 105 29 ".-----------------------.\n|                       |\n|\e0   G A M E   O V E R   \r|\n|                       |\n|\d0    SPACE TO RESTART   \r|\n|                       |\n|\80     ESCAPE TO QUIT    \r|\n|                       |\n ----------------------- \K" c 0 r
if not !ERRORLEVEL!==32 if not !ERRORLEVEL!==27 goto GAMEOVER
if !ERRORLEVEL!==27 set GAMECHOICE=1
goto :eof

batchcc
Posts: 139
Joined: 17 Aug 2015 06:05
Contact:

Re: MarioRun - 2d scrolling game with parallax background

#3 Post by batchcc » 26 Jun 2016 17:10

This is cool but when I scanned it with virustotal.com 6 negative results appeared :!: .

Code: Select all

AVG   I-Worm/Nuwar.R   20160626
AegisLab   Malware.Gen!c   20160624
AhnLab-V3   Worm/Win32.Zhelatin.R35810   20160626
Baidu   Win32.Trojan.WisdomEyes.151026.9950.9973   20160624
McAfee   Artemis!291DB75C4D4C   20160626
McAfee-GW-Edition   Artemis   20160626

Any idea why and is it safe to use?

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

Re: MarioRun - 2d scrolling game with parallax background

#4 Post by misol101 » 26 Jun 2016 17:35

batchcc wrote:Any idea why and is it safe to use?


It's safe. Seems like some of the AV scanners don't like programs compiled with tcc. (well, I had similar problems with gcc too sometimes). I.e cmdgfx.exe compiled with tcc has 1 "malware", with gcc it has 0, but the tcc one runs slightly faster. Tried adding resource files to the exes without much success. Apparently gotoxy.exe in the latest compile has loads of "malware" in it, perhaps if I add another printf instruction somewhere it will decrease a bit (or increase, who knows) :x

Sorry, but seems to me these "heuristic scans" cry wolf just a little too easily.. I'm probably wrong.

(I mean, none of those 5 AV scanners out of 55 even report the *same* malware)

batchcc
Posts: 139
Joined: 17 Aug 2015 06:05
Contact:

Re: MarioRun - 2d scrolling game with parallax background

#5 Post by batchcc » 27 Jun 2016 04:55

Ok thanks misol101

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

Re: MarioRun - 2d scrolling game with parallax background

#6 Post by foxidrive » 27 Jun 2016 22:36

aGerman posted a method in recent days to get AV scanners to behave. It involved adding a resource file of some kind to the compile so it shows properties of the executable, and which AV scanners may have more tolerance of.

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

Re: MarioRun - 2d scrolling game with parallax background

#7 Post by misol101 » 18 May 2017 18:56

Same as for cmdrunner:

Updated archive to try out new server functionality.

This game is more suited to try out key response. Also, since it's a simple game I expect this to run close to the target FPS of 50 on any machine.

Please help me try it! :mrgreen:

Same URL as before (right click and open in new tab):

http://www.mediafire.com/download/4gffc0wa8y6zhga/mariorun.zip


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

Re: MarioRun - 2d scrolling game with parallax background

#9 Post by einstein1969 » 19 May 2017 13:13

this run pretty fast on my old monocore machine! 8)

Why do not add, at your game, the achieved FPS?

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

Re: MarioRun - 2d scrolling game with parallax background

#10 Post by misol101 » 19 May 2017 14:41

einstein1969: Nice! Hmmm yes I suppose I should have included a way to see FPS... :oops:

A DIY method:

On line 74, after it says: "!HISCORE!" , add the text "__[FRAMECOUNT]" . So it looks like: text 7 1 0 SCORE:_!SCORE!_(!HISCORE!)__[FRAMECOUNT]

You will now see the frame count in the top left text. Now run the game for example 5 seconds (measure with a timer), note the number in the top left text and divide by 5.

I get around 250, so my FPS is 50, which is the target framerate (even on a very fast machine it should not go above that)

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

Re: MarioRun - 2d scrolling game with parallax background

#11 Post by aGerman » 19 May 2017 16:09

I get ~40 FPS. Same for CmdRunner (although holding the arrow keys slows down the motion of the cubes tremendously).

Steffen

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

Re: MarioRun - 2d scrolling game with parallax background

#12 Post by misol101 » 19 May 2017 18:40

Thanks Steffen. Unexpected that you got as much as 40 for Cmdrunner. As for key presses, hmm... I have seen slowdown for that too, but not extreme. Does your computer have an SSD drive? To communicate key presses from server to client I have to write a file. This might be quite slow on an SSD drive. :cry: If only I could do key reading on the client side...but as the Lovechild thread showed, that causes too much of a slowdown as well...

Perhaps you could try Blockout too, which I will post right about.. now :)

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

Re: MarioRun - 2d scrolling game with parallax background

#13 Post by aGerman » 20 May 2017 03:28

It's an eMMC drive :lol: So don't spend too much time - as I said this won't ever be a gaming computer and keeps being a couch toy. (And this is absolutely okay because my opinion is that playing computer games is a waste of time for me :wink: Just trying to give you some feedback ...)

Steffen

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

Re: MarioRun - 2d scrolling game with parallax background

#14 Post by einstein1969 » 23 May 2017 08:05

I confirm about 38-40 FPS on my machine. NOT BAD!

ShadowThief
Expert
Posts: 986
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: MarioRun - 2d scrolling game with parallax background

#15 Post by ShadowThief » 23 May 2017 18:01

I'm getting 48-50 FPS on my machine. Nice work.

batnoob wrote:wait... is that really foxidrive?
http://www.dostips.com/forum/viewtopic.php?f=3&t=7529

The post was made five months before that topic was, so yes.

Post Reply