Seta:Gpu Mini. A Batch Game Engine Coded In Pure Batch

Microsoft Windows
Post Reply
User avatar
MigrationUser
Posts: 336
Joined: 2021-Jul-12, 1:37 pm
Contact:

Seta:Gpu Mini. A Batch Game Engine Coded In Pure Batch

Post by MigrationUser »

15 May 2014 21:27
Honguito98

I have done a variant of Seta:Gpu Ver 'A', but without use any external command
For get keystrokes I used Xcopy, and for get colours, with FindStr.

I based me from some techniques from Dave's SNAKE game. And other some stuff.
Many thanks to: Jeb, Dave Benham, and all users of DosTips.com and SS64.org.

Some limitations are: doesn't works on XP,and cannot be used the slashes and shadows chars in maps
Image Image

Code: Select all

:    Seta:Gpu Mini. A Batch Game Engine Coded In Pure Batch
:    Copyright (C) 2014  Honguito98, {Plus others users}
:
:    This program is free software: you can redistribute it and/or modify
:    it under the terms of the GNU General Public License as published by
:    the Free Software Foundation, either version 3 of the License, or
:    (at your option) any later version.
:
:    This program is distributed in the hope that it will be useful,
:    but WITHOUT ANY WARRANTY; without even the implied warranty of
:    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
:    GNU General Public License for more details.
:
:    You should have received a copy of the GNU General Public License
:    along with this program.  If not, see <http://www.gnu.org/licenses/>.
@Echo off
	SetLocal EnableDelayedExpansion Enableextensions
	If Exist "%SystemDrive%\Recycler" (
		For %%e in (
		"Sorry"
		"	Seta:GPU Mini Cannot Run"
		"	On Windows Xp") Do Echo;%%~e
		Pause>Nul & Exit
	)

	:: CR Variable Contains a Carriage Return Char
	For /F %%a In ('Copy /Z "%~dpf0" Nul') Do Set "CR=%%a"

	:: BS Variable Contains a BackSpace Char
	For /F "Tokens=1 Delims=#" %%a in ('"Prompt #$H# & Echo on & For %%b in (1) Do Rem"') Do (
		If Exist Tmp Attrib -H Tmp
		Echo;%%a%%a%%a%%a%%a%%a%%a%%a%%a>Tmp
		Attrib +H Tmp
		Set "Bs=%%a" & Set "Bs=!Bs:~0,1!"
	)


	:: Important: Player Char Must be on first line, and first row,
	::	          if the map size is greater than the specified.
	:: !C[#]! = Color to line number...
	:: !L[#]! = Level Data
	Set "Key="
	Set Err=-1
	:: Characters
	Set Player=
	Set Enemy=
	Set Beep=
	Set Border=#
	Set Floor=-
	Set Floor2==
	Set "Coin=›"
	Set "Ground= "
	Set "Exit="
	Title Seta:Gpu Mini
	:Menu
	Cls
	For %%a in (
	"Seta:Gpu Mini"
	"	A Batch Game Engine Coded In Pure Batch"
	"	Developed By Honguito98"
	""
	"	Credits To:"
	"	Jeb, Dave Benham, and all users of DosTips.com"
	"	and SS64.org"
	"================================================"
	"Controls:"
	"	a = Move Left  w = Move Up"
	"	d = Move Right s = Move Down"
	"	Enter Key = Pause"
	"	BackSpace = Return To Menu"
	""
	"Level #"
	) Do Echo;%%~a
	Set/p Level=^>
	If Not Exist L!Level!.txt Goto :Menu
	Set Map.Y=0
	For %%c in (L C) Do (
		For /F "Tokens=1 Delims==" %%a in ('"Set|Find %%c[ 2>Nul"') Do Set "%%a="
	)
	For /F "Tokens=1-2 Delims=;" %%a in ('Type L!Level!.txt') Do (
		Set/a Map.Y+=1
		Set "L[!Map.Y!]=%%~a"
		Set "C[!Map.Y!]=%%b"
	)
	:: XMin  = Must be 0
	:: XMax  = Max number of cols rendered
	:: YMin  = Must be 1
	:: YMax  = Max number of rows rendered
	:: YMax_ = equal to YMax, but plus 1
	Set/a Coins=0,XMin=0,XMax=20,YMin=1,YMax=6,YMax_=6+1
	If !YMax_! Gtr !Map.Y! Set/a YMax_=Map.Y

	:: Getting Current Positions of Player In Loaded Map
	Call :GetPst Player Player.Pos
	Set End=
	:Main
	For /L %%! in (1,1,100) Do (
		%== Screen Rendering ==%
		Set Key=&Cls
		For /F "Tokens=1-2" %%x in ("!XMin! !XMax!") Do (
			For /L %%a in (!YMin!,1,!YMax_!) Do (
				Findstr /A:!C[%%a]! "." "!L[%%a]:~%%x,%%y!?\..\Tmp"
			)
		)
		Echo;Coins: !Coins!

		%== Game Status ==%
		If "!End!" Equ "Win" Goto :Win

		
		%== KeyBoard Support ==%
		For /F "Delims=" %%K In ('Xcopy /W "%~f0" "%~f0" 2^>Nul') Do (
			If Not Defined Key (
				Set "Key=%%K"
				set "key=!Key:~-1!"
			)
		)
		If /i "!Key!" Equ "a" Set Player.Dir=H -
		If /i "!Key!" Equ "d" Set Player.Dir=H +
		If /i "!Key!" Equ "w" Set Player.Dir=V -
		If /i "!Key!" Equ "s" Set Player.Dir=V +
		If "!Key!" Equ "!BS!" Goto :Menu
		If "!Key!" Equ "!CR!" (
			%== Enter Key ==%
			Echo;Paused^^!
			Pause>Nul & Goto :Main
		)


		For /F "Tokens=1-3 Delims= " %%1 in ("!Player.Dir! Player") Do (
			For /F "Tokens=1-2 Delims=." %%x in ("!%%3.Pos!") Do Set/a Y=%%x,X=%%y
			If %%1 Equ H (
				Set/a "n=X %%2 1"
				If /i "%%3" Equ "Player" (
					Set/a "SHr=Map.x-XMax-XMin,SH=XMax/2,Shl=(X %%2 1)-(Map.x-(XMax-SH))"
				)
				
				%== Some Limits of Map ==%
				If !n! Gtr !Map.X! Set Err=1
				If !n! Lss 1 Set Err=1
				Set/a Col=n-1
				For /F "Tokens=1-2" %%x in ("!Y! !Col!") Do Set "Chr=!L[%%x]:~%%y,1!"
			) Else (
				Set/a "n=Y %%2 1"
				If /i "%%3" Equ "Player" (
					Set/a "SVr=Map.y-YMax-YMin,SV=YMax/2,Svl=(Y %%2 1)-(Map.y-(YMax-SV))"
				)
	
				If !n! Gtr !Map.Y! Set Err=1
				If !n! Lss 1 Set Err=1
				Set/a Col=X-1
				For /F "Tokens=1-2" %%x in ("!N! !Col!") Do Set "Chr=!L[%%x]:~%%y,1!"
			)



			%== Put Here The Conditions ==%
			%== Follow The Example ==%
			
			%== If is Player Then... If Your Next Step It's a Block Do Nothing==%
			If !Err! Equ -1 (
				If /i "%%3" Equ "Player" (
					If "!Chr!" Equ "%Border%" Set Err=1
					If "!Chr!" Equ "%Floor%"  Set Err=1
					If "!Chr!" Equ "%Floor2%"  Set Err=1
	
					If "!Chr!" Equ "%Coin%"  (
						Set/a Coins+=1
						%== Remove The Sprite Coin ==%
						Set "Chr=%Ground%"
						Set/p=%Beep%<Nul
					)
					If !Err! Neq 1 If "!Chr!" Equ "%Exit%" Set End=Win
				)
			)
	
	





			%== Here Is The Seta GPU FrameWork ==%
			If !Err! Equ -1 (
				Set/a Col=X-1
				For /F "Tokens=1-3" %%x in ("!X! !Y! !Col!") Do (
					Set "L[%%y]=!L[%%y]:~0,%%z!!$[%%y.%%x]!!L[%%y]:~%%x!"
				)
		
				If %%1 Equ H (
					Set/a Col=!n!-1
					For /F "Tokens=1-4" %%w in ("!N! !X! !Y! !Col!") Do (
						Set "$[%%y.%%w]=!Chr!"
						Set "L[%%y]=!L[%%y]:~0,%%z!!%%3!!L[%%y]:~%%w!"
						Set %%3.Pos=%%y.%%w
					)
				) Else (
					For /F "Tokens=1-3" %%w in ("!N! !X! !Col!") Do (
						Set "$[%%w.%%x]=!Chr!"
						Set "L[%%w]=!L[%%w]:~0,%%y!!%%3!!L[%%w]:~%%x!"
						Set %%3.Pos=%%w.%%x
					)
				)
				Set $[!Y!.!X!]=
				If /i "%%3" Equ "Player" (
					If %%1 Equ H (
						if !n! Gtr !SH! (
							if !SHr! Gtr 0 (set /a "XMin%%2=1") Else (if !SHl! Lss 1 if !XMin! gtr 0 set/a XMin-=1)
						)
						If !n! Leq !Sh! If !XMin! Gtr 0 set/a XMin-=1
					)
					If %%1 Equ V (
						if !n! Gtr !SV! (
							if !SVr! Gtr 0 (Set/a "YMin%%2=1,YMax_%%2=1") Else (if !SVl! Lss 0 if !Ymin! gtr 0 Set/a YMin-=1,YMax_-=1)
						)
						If !n! Leq !SV! If !YMin! Gtr 1 Set/a YMin-=1,YMax_-=1
					)
				)
			)
			Set Err=-1
		)
		Set "Key="
	)	
	Goto :Main
:Win
Echo;&Echo;You Win^^!
Pause & Goto :Menu

:GetPst <CharacterVariable> <VariableName.Pos>
	Call :GetLen L[1]
	Set "%2="
	For /F "Tokens=2 Delims=[]" %%y in ('Set^|Find /i "L["^|Find "!%1!"') Do (
	For /l %%x in (0,1,!Map.X!) Do (
	Set/a col=%%x+1
	If "!L[%%y]:~%%x,1!" Equ "!%1!" (
		Set "%2=!%2!,%%y.!Col!"
		Set "$[%%y.!Col!]=!Ground!"
	)
	))
	If Defined %2 Set "%2=!%2:~1!"
	Goto :Eof
:GetLen
	Set "Str=X!%1!"
	Set Map.X=0
	For /L %%A in (12,-1,0) Do (
		Set/a "Map.X|=1<<%%A"
		For %%B in (!Map.X!) Do If "!Str:~%%B,1!" Equ "" Set/a "Map.X&=~1<<%%A"
    )
	Set "Str="
	Goto :Eof
Files moved to sourceforge.
Levels and Bat File can found Here

Last edited by Honguito98 (18 May 2014 03:04)

.::{Honguito98}::.

----------------------------

#2 16 May 2014 00:46
Evanator

This looks interesting. You know what would be cool? If you made a sidescrolling platformer game like Mario or Dangerous Dave.
Still, this is great...for batch.

----------------------------

#3 16 May 2014 05:07
Honguito98

Thanks! I have done a batch game called 'Batch Adventures', it's a sidescrolling plataformer game, is on my youtube channel.

Update 15-may-14 @ 11:07 PM
Added 4-way sidescrolling. Updated Link.

Last edited by Honguito98 (16 May 2014 05:07)

.::{Honguito98}::.

----------------------------

#4 18 May 2014 23:33
Honguito98

How to make a new map world

Code: Select all

Help for novices

                 ____ Map world data (enclosed with quotes)
                /             __________ Color codes. (See L4.txt or color /?) [First number: BG color, Second number: FG color]
               v            v
"-----------------------";94
"                       ";94
"                       ";94
"                       ";94
"#######################";2a

Unsupported chars: / \ " ! ° (any character for draw graphics) (see L3.txt for supported chars.)
Color help
Color

.::{Honguito98}::.

----------------------------

#5 03 Jun 2014 18:23
einstein1969

Hi Honguito,

It looks very nice!
Some limitations are: doesn't works on XP,and cannot be used the slashes and shadows chars in maps
I have not tried but I think we can overcome this limitation and have an even more enjoyable.

einstein1969

Last edited by einstein1969 (03 Jun 2014 18:26)

----------------------------

#6 04 Jun 2014 03:53
Honguito98

@einstein1969
The problem with findstr is that does not support extended ascii / ansi chars (they show as dots).
There's a solution, but it's just for a ascii game (using the typical 'X' and 'O' chars).

But is possible write a batch game engine that supports XP, but will use third party tools, this is not the point for do a 'batch game in pure batch'

.::{Honguito98}::.

----------------------------

#7 04 Jun 2014 23:23
carlos

@Honguito: Sure, findstr for win xp can be patched for not print the dots.
Post Reply