Advertisement
Heacien

Seta:Gpu Mini

Aug 2nd, 2015
412
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 7.49 KB | None | 0 0
  1. :    Seta:Gpu Mini. A Batch Game Engine Coded In Pure Batch
  2. :    Copyright (C) 2014  Honguito98, {Plus others users}
  3. :
  4. :    This program is free software: you can redistribute it and/or modify
  5. :    it under the terms of the GNU General Public License as published by
  6. :    the Free Software Foundation, either version 3 of the License, or
  7. :    (at your option) any later version.
  8. :
  9. :    This program is distributed in the hope that it will be useful,
  10. :    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. :    GNU General Public License for more details.
  13. :
  14. :    You should have received a copy of the GNU General Public License
  15. :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  16. @Echo off
  17.     SetLocal EnableDelayedExpansion Enableextensions
  18.     If Exist "%SystemDrive%\Recycler" (
  19.         For %%e in (
  20.         "Sorry"
  21.         "   Seta:GPU Mini Cannot Run"
  22.         "   On Windows Xp") Do Echo;%%~e
  23.         Pause>Nul & Exit
  24.     )
  25.  
  26.     :: CR Variable Contains a Carriage Return Char
  27.     For /F %%a In ('Copy /Z "%~dpf0" Nul') Do Set "CR=%%a"
  28.  
  29.     :: BS Variable Contains a BackSpace Char
  30.     For /F "Tokens=1 Delims=#" %%a in ('"Prompt #$H# & Echo on & For %%b in (1) Do Rem"') Do (
  31.         If Exist Tmp Attrib -H Tmp
  32.         Echo;%%a%%a%%a%%a%%a%%a%%a%%a%%a>Tmp
  33.         Attrib +H Tmp
  34.         Set "Bs=%%a" & Set "Bs=!Bs:~0,1!"
  35.     )
  36.  
  37.  
  38.     :: Important: Player Char Must be on first line, and first row,
  39.     ::            if the map size is greater than the specified.
  40.     :: !C[#]! = Color to line number...
  41.     :: !L[#]! = Level Data
  42.     Set "Key="
  43.     Set Err=-1
  44.     :: Characters
  45.     Set Player=
  46.     Set Enemy=
  47.     Set Beep=
  48.     Set Border=
  49.     Set Floor=-
  50.     Set Floor2==
  51.     Set "Coin=›"
  52.     Set "Ground= "
  53.     Set "Exit="
  54.     Title Seta:Gpu Mini
  55.     :Menu
  56.     Cls
  57.     For %%a in (
  58.     "Seta:Gpu Mini"
  59.     "   A Batch Game Engine Coded In Pure Batch"
  60.     "   Developed By Honguito98"
  61.     ""
  62.     "   Credits To:"
  63.     "   Jeb, Dave Benham, and all users of DosTips.com"
  64.     "   and SS64.org"
  65.     "================================================"
  66.     "Controls:"
  67.     "   a = Move Left  w = Move Up"
  68.     "   d = Move Right s = Move Down"
  69.     "   Enter Key = Pause"
  70.     "   BackSpace = Return To Menu"
  71.     ""
  72.     "Level #"
  73.     ) Do Echo;%%~a
  74.     Set/p Level=^>
  75.     If Not Exist L!Level!.txt Goto :Menu
  76.     Set Map.Y=0
  77.     For %%c in (L C) Do (
  78.         For /F "Tokens=1 Delims==" %%a in ('"Set|Find %%c[ 2>Nul"') Do Set "%%a="
  79.     )
  80.     For /F "Tokens=1-2 Delims=;" %%a in ('Type L!Level!.txt') Do (
  81.         Set/a Map.Y+=1
  82.         Set "L[!Map.Y!]=%%~a"
  83.         Set "C[!Map.Y!]=%%b"
  84.     )
  85.     :: XMin  = Must be 0
  86.     :: XMax  = Max number of cols rendered
  87.     :: YMin  = Must be 1
  88.     :: YMax  = Max number of rows rendered
  89.     :: YMax_ = equal to YMax, but plus 1
  90.     Set/a Coins=0,XMin=0,XMax=20,YMin=1,YMax=6,YMax_=6+1
  91.     If !YMax_! Gtr !Map.Y! Set/a YMax_=Map.Y
  92.  
  93.     :: Getting Current Positions of Player In Loaded Map
  94.     Call :GetPst Player Player.Pos
  95.     Set End=
  96.     :Main
  97.     For /L %%! in (1,1,100) Do (
  98.         %== Screen Rendering ==%
  99.         Set Key=&Cls
  100.         For /F "Tokens=1-2" %%x in ("!XMin! !XMax!") Do (
  101.             For /L %%a in (!YMin!,1,!YMax_!) Do (
  102.                 Findstr /A:!C[%%a]! "." "!L[%%a]:~%%x,%%y!?\..\Tmp"
  103.             )
  104.         )
  105.         Echo;Coins: !Coins!
  106.  
  107.         %== Game Status ==%
  108.         If "!End!" Equ "Win" Goto :Win
  109.  
  110.        
  111.         %== KeyBoard Support ==%
  112.         For /F "Delims=" %%K In ('Xcopy /W "%~f0" "%~f0" 2^>Nul') Do (
  113.             If Not Defined Key (
  114.                 Set "Key=%%K"
  115.                 set "key=!Key:~-1!"
  116.             )
  117.         )
  118.         If /i "!Key!" Equ "a" Set Player.Dir=H -
  119.         If /i "!Key!" Equ "d" Set Player.Dir=H +
  120.         If /i "!Key!" Equ "w" Set Player.Dir=V -
  121.         If /i "!Key!" Equ "s" Set Player.Dir=V +
  122.         If "!Key!" Equ "!BS!" Goto :Menu
  123.         If "!Key!" Equ "!CR!" (
  124.             %== Enter Key ==%
  125.             Call :Pause
  126.         )
  127.  
  128.  
  129.         For /F "Tokens=1-3 Delims= " %%1 in ("!Player.Dir! Player") Do (
  130.             For /F "Tokens=1-2 Delims=." %%x in ("!%%3.Pos!") Do Set/a Y=%%x,X=%%y
  131.             If %%1 Equ H (
  132.                 Set/a "n=X %%2 1"
  133.                 If /i "%%3" Equ "Player" (
  134.                     Set/a "SHr=Map.x-XMax-XMin,SH=XMax/2,Shl=(X %%2 1)-(Map.x-(XMax-SH))"
  135.                 )
  136.                
  137.                 %== Some Limits of Map ==%
  138.                 If !n! Gtr !Map.X! Set Err=1
  139.                 If !n! Lss 1 Set Err=1
  140.                 Set/a Col=n-1
  141.                 For /F "Tokens=1-2" %%x in ("!Y! !Col!") Do Set "Chr=!L[%%x]:~%%y,1!"
  142.             ) Else (
  143.                 Set/a "n=Y %%2 1"
  144.                 If /i "%%3" Equ "Player" (
  145.                     Set/a "SVr=Map.y-YMax-YMin,SV=YMax/2,Svl=(Y %%2 1)-(Map.y-(YMax-SV))"
  146.                 )
  147.    
  148.                 If !n! Gtr !Map.Y! Set Err=1
  149.                 If !n! Lss 1 Set Err=1
  150.                 Set/a Col=X-1
  151.                 For /F "Tokens=1-2" %%x in ("!N! !Col!") Do Set "Chr=!L[%%x]:~%%y,1!"
  152.             )
  153.  
  154.  
  155.  
  156.             %== Put Here The Conditions ==%
  157.             %== Follow The Example ==%
  158.            
  159.             %== If is Player Then... If Your Next Step It's a Block Do Nothing==%
  160.             If !Err! Equ -1 (
  161.                 If /i "%%3" Equ "Player" (
  162.                     If "!Chr!" Equ "%Border%" Set Err=1
  163.                     If "!Chr!" Equ "%Floor%"  Set Err=1
  164.                     If "!Chr!" Equ "%Floor2%"  Set Err=1
  165.    
  166.                     If "!Chr!" Equ "%Coin%"  (
  167.                         Set/a Coins+=1
  168.                         %== Remove The Sprite Coin ==%
  169.                         Set "Chr=%Ground%"
  170.                         Set/p=%Beep%<Nul
  171.                     )
  172.                     If !Err! Neq 1 If "!Chr!" Equ "%Exit%" Set End=Win
  173.                 )
  174.             )
  175.    
  176.    
  177.  
  178.  
  179.  
  180.  
  181.  
  182.             %== Here Is The Seta GPU FrameWork ==%
  183.             If !Err! Equ -1 (
  184.                 Set/a Col=X-1
  185.                 For /F "Tokens=1-3" %%x in ("!X! !Y! !Col!") Do (
  186.                     Set "L[%%y]=!L[%%y]:~0,%%z!!$[%%y.%%x]!!L[%%y]:~%%x!"
  187.                 )
  188.        
  189.                 If %%1 Equ H (
  190.                     Set/a Col=!n!-1
  191.                     For /F "Tokens=1-4" %%w in ("!N! !X! !Y! !Col!") Do (
  192.                         Set "$[%%y.%%w]=!Chr!"
  193.                         Set "L[%%y]=!L[%%y]:~0,%%z!!%%3!!L[%%y]:~%%w!"
  194.                         Set %%3.Pos=%%y.%%w
  195.                     )
  196.                 ) Else (
  197.                     For /F "Tokens=1-3" %%w in ("!N! !X! !Col!") Do (
  198.                         Set "$[%%w.%%x]=!Chr!"
  199.                         Set "L[%%w]=!L[%%w]:~0,%%y!!%%3!!L[%%w]:~%%x!"
  200.                         Set %%3.Pos=%%w.%%x
  201.                     )
  202.                 )
  203.                 Set $[!Y!.!X!]=
  204.                 If /i "%%3" Equ "Player" (
  205.                     If %%1 Equ H (
  206.                         if !n! Gtr !SH! (
  207.                             if !SHr! Gtr 0 (set /a "XMin%%2=1") Else (if !SHl! Lss 1 if !XMin! gtr 0 set/a XMin-=1)
  208.                         )
  209.                         If !n! Leq !Sh! If !XMin! Gtr 0 set/a XMin-=1
  210.                     )
  211.                     If %%1 Equ V (
  212.                         if !n! Gtr !SV! (
  213.                             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)
  214.                         )
  215.                         If !n! Leq !SV! If !YMin! Gtr 1 Set/a YMin-=1,YMax_-=1
  216.                     )
  217.                 )
  218.             )
  219.             Set Err=-1
  220.         )
  221.         Set "Key="
  222.     )  
  223.     Goto :Main
  224. :Win
  225. Echo;&Echo;You Win^^!
  226. Pause & Goto :Menu
  227.  
  228. :Pause
  229.     title GAME - PAUSE
  230.     cls
  231.     For %%a in (
  232.     ""
  233.     "Paused^^^!"
  234.     "Press 'Y' Key to save."
  235.     "Press 'L' Key to load."
  236.     "Press 'Enter' Key to continue"
  237.     ) Do Echo;%%~a
  238.     :Pause_
  239.     Set "Key="
  240.     For /F "Delims=" %%K In ('Xcopy /W "%~f0" "%~f0" 2^>Nul') Do (
  241.         If Not Defined Key (
  242.             Set "Key=%%K"
  243.             set "key=!Key:~-1!"
  244.         )
  245.     )
  246.     If /i "!Key!" Equ "Y" Goto :Save
  247.     If /i "!Key!" Equ "L" Goto :Load
  248.     If "!Key!" Equ "!CR!" (
  249.         Color 07
  250.         Goto :Eof
  251.     )
  252.     Goto :Pause_
  253.  
  254. :Save
  255.     Echo;&Echo;Save completed^^!
  256.     Set>Save.sav
  257.     For /L %%a in (1,1,180000) Do Rem
  258.     Goto :Eof
  259.  
  260. :Load
  261.     If Exist Save.sav (
  262.         For /F "Delims=" %%s in ('Type Save.sav') Do Set %%s
  263.         Echo;&Echo;Load complete^^!
  264.     ) Else Echo:Save file not found^^!
  265.     For /L %%a in (1,1,180000) Do Rem
  266.     Goto :Eof
  267.  
  268. :GetPst <CharacterVariable> <VariableName.Pos>
  269.     Call :GetLen L[1]
  270.     Set "%2="
  271.     For /F "Tokens=2 Delims=[]" %%y in ('Set^|Find /i "L["^|Find "!%1!"') Do (
  272.     For /l %%x in (0,1,!Map.X!) Do (
  273.     Set/a col=%%x+1
  274.     If "!L[%%y]:~%%x,1!" Equ "!%1!" (
  275.         Set "%2=!%2!,%%y.!Col!"
  276.         Set "$[%%y.!Col!]=!Ground!"
  277.     )
  278.     ))
  279.     If Defined %2 Set "%2=!%2:~1!"
  280.     Goto :Eof
  281. :GetLen
  282.     Set "Str=X!%1!"
  283.     Set Map.X=0
  284.     For /L %%A in (12,-1,0) Do (
  285.         Set/a "Map.X|=1<<%%A"
  286.         For %%B in (!Map.X!) Do If "!Str:~%%B,1!" Equ "" Set/a "Map.X&=~1<<%%A"
  287.     )
  288.     Set "Str="
  289.     Goto :Eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement