Trending Tutorials

How to make a Snake Game in Notepad!



Hey Guys, this is a quick video showing you how to make a snake game with only notepad!!
You HAVE GOT to see this!!

MAKE SURE TO SUBSCRIBE TO MY SECOND CHANNEL:

==CODE==

It does not fit here so here is a link:

Mirror1:

Mirror2:

If you want to see more videos like this, make sure to hit that LIKE button to let me know.
SUBSCRIBE for more EPIC…

42 Comments on How to make a Snake Game in Notepad!

  1. DON'T ENTER THAT LINK IT`S VIRUS

  2. In the first link is virus

  3. Can you actually type out the whole thing on the video?

  4. I tried but cmd says
    Do was unexpected at this time

    What can I do

  5. You have to tell your viewers step by step meaning of each command but you also not know what is the command you are entering

  6. really tho i want a TUTORIAL not an "introduction" dislike

  7. yeah, i can code lol

  8. what you have write tell me

  9. Yeah I’m going to type it out myself

  10. I just want to do this so that I don't have to pay for this game

  11. Why it's so small?

  12. You have to not save as .bas
    in bat

  13. Ok so you should have saved it as snake.html and then pasted it into your desktop file then opened it but ok

  14. I can't see the code can you send it to me

  15. I got a strange file on my computer called "key" that's empty

  16. Doesn't work! Ok, what's an alpha-numeric key?!?!?! Im pressing all keys and nothing is happening!

  17. does anybody know what language this is

  18. The website with the code is sketchy and it didn't work

  19. @echo off
    if "%~1" == "startGame" goto :game
    if "%~1" == "startController" goto :controller

    ::————————————————————
    :: verify existence of CHOICE command
    :: set up a macro appropriately depending on available version

    set "choice="
    2>nul >nul choice /c:yn /t 0 /d y
    if errorlevel 1 if not errorlevel 2 set "choice=choice /cs"
    if not defined choice (
    2>nul >nul choice /c:yn /t:y,1
    if errorlevel 1 if not errorlevel 2 set "choice=choice /s"
    )
    if not defined choice (
    echo ERROR: This game requires the CHOICE command, but it is missing.
    echo Game aborted. 🙁
    echo(
    echo A 16 bit port of CHOICE.EXE from FREEDOS is available at
    echo http://winsupport.org/utilities/freedos-choice.html
    echo(
    echo A 32 bit version from ??? suitable for 64 bit machines is available at
    echo http://hp.vector.co.jp/authors/VA007219/dkclonesup/choice.html
    echo(
    exit /b
    )

    ::———————————————————————
    :: setup some global variables used by both the game and the controller

    set "keys=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
    set "keyFile=key.txt"
    set "cmdFile=cmd.txt"

    ::——————————————
    :: launch the game and the controller

    copy nul "%keyFile%" >nul
    start "" /b "%~f0" startController 9^>^>%keyFile% 2^>nul ^>nul
    cmd /c "%~f0" startGame 9^<%keyFile% ^<nul
    echo(

    ::——————————————————————————–
    :: Upon exit, wait for the controller to close before deleting the temp input file

    :close
    2>nul (>>"%keyFile%" call )||goto :close
    del "%keyFile%"
    exit /b

    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :game
    setlocal disableDelayedExpansion
    title %~nx0
    cls

    ::—————————-
    :: user configurable options

    set "up=W"
    set "down=S"
    set "left=A"
    set "right=D"

    set "width=40" max=99
    set "height=25" max=99
    :: max playing field: (width-2)*(height-2) <= 1365

    ::—————————-
    :: resize the console window

    set /a cols=width+1, lines=height+10, area=(width-2)*(height-2)
    if %area% gtr 1365 (
    echo ERROR: Playfield area too large
    >"%cmdFile%" (echo quit)
    exit
    )
    if %lines% lss 14 set lines=14
    if %cols% lss 46 set cols=46
    mode con: cols=%cols% lines=%lines%

    ::—————————-
    :: define variables

    set "spinner1=-"
    set "spinner2="
    set "spinner3=|"
    set "spinner4=/"
    set "spinner= spinner1 spinner2 spinner3 spinner4 "

    set "space= "
    set "bound=#"
    set "food=+"
    set "head=@"
    set "body=O"
    set "death=X"
    set "playerSpace=%space%%food%"

    set "xDiff%up%=+0"
    set "xDiff%down%=+0"
    set "xDiff%left%=-1"
    set "xDiff%right%=+1"

    set "yDiff%up%=-1"
    set "yDiff%down%=+1"
    set "yDiff%left%=+0"
    set "yDiff%right%=+0"

    set "%up%Axis=Y"
    set "%down%Axis=Y"
    set "%left%Axis=X"
    set "%right%Axis=X"

    set "delay1=20"
    set "delay2=15"
    set "delay3=10"
    set "delay4=7"
    set "delay5=5"
    set "delay6=3"
    set "delay0=0"

    set "desc1=Sluggard"
    set "desc2=Crawl"
    set "desc3=Slow"
    set "desc4=Normal"
    set "desc5=Fast"
    set "desc6=Insane"
    set "desc0=Unplayable"

    set "spinnerDelay=3"

    set /a "width-=1, height-=1"

    ::—————————
    :: define macros

    ::define a Line Feed (newline) string (normally only used as !LF!)
    set LF=^

    ::Above 2 blank lines are required – do not remove

    ::define a newline with line continuation
    set ^"n=^^^%LF%%LF%^%LF%%LF%^^"

    :: setErr
    ::: Sets the ERRORLEVEL to 1
    set "setErr=(call)"

    :: clrErr
    ::: Sets the ERRORLEVEL to 0
    set "clrErr=(call )"

    :: getKey ValidKeys
    ::: Check for keypress. Only accept keys listed in ValidKeys
    ::: Return result in Key variable. Key is undefined if no valid keypress.
    set getKey=%n%
    for %%# in (1 2) do if %%#==2 (for /f "eol= delims= " %%1 in ("!args!") do (%n%
    set "validKeys=%%1"%n%
    set "key="%n%
    ^<^&9 set /p "key="%n%
    if defined key if "!key!" neq ":" (%n%
    set /a key-=1%n%
    for %%K in (!key!) do set "key=!keys:~%%K,1!"%n%
    )%n%
    for %%K in (!key!) do if "!validKeys:%%K=!" equ "!validKeys!" set "key="%n%
    )) else set args=

    :: draw
    ::: draws the board
    set draw=%n%
    cls%n%
    for /l %%Y in (0,1,%height%) do echo(!line%%Y!%n%
    echo Speed=!Difficulty!%n%
    echo Score=!score!

    :: test X Y ValueListVar
    ::: tests if value at coordinates X,Y is within contents of ValueListVar
    set test=%n%
    for %%# in (1 2) do if %%#==2 (for /f "tokens=1-3" %%1 in ("!args!") do (%n%
    for %%A in ("!line%%2:~%%1,1!") do if "!%%3:%%~A=!" neq "!%%3!" %clrErr% else %setErr%%n%
    )) else set args=

    :: plot X Y ValueVar
    ::: places contents of ValueVar at coordinates X,Y
    set plot=%n%
    for %%# in (1 2) do if %%#==2 (for /f "tokens=1-3" %%1 in ("!args!") do (%n%
    set "part2=!line%%2:~%%1!"%n%
    set "line%%2=!line%%2:~0,%%1!!%%3!!part2:~1!"%n%
    )) else set args=

    ::————————————–
    :: start the game
    setlocal enableDelayedExpansion
    call :initialize

    ::————————————–
    :: main loop (infinite loop)
    for /l %%. in (1 0 1) do (

    %=== compute time since last move ===%
    for /f "tokens=1-4 delims=:.," %%a in ("!time: =0!") do set /a "t2=(((1%%a*60)+1%%b)*60+1%%c)*100+1%%d-36610100, tDiff=t2-t1"
    if !tDiff! lss 0 set /a tDiff+=24*60*60*100

    if !tDiff! geq !delay! (
    %=== delay has expired, so time for movement ===%

    %=== establish direction ===%
    %getKey% ASDW
    for %%K in (!key!) do if "!%%KAxis!" neq "!axis!" (
    set /a "xDiff=xDiff%%K, yDiff=yDiff%%K"
    set "axis=!%%KAxis!"
    )

    %=== erase the tail ===%
    set "TX=!snakeX:~-2!"
    set "TY=!snakeY:~-2!"
    set "snakeX=!snakeX:~0,-2!"
    set "snakeY=!snakeY:~0,-2!"
    %plot% !TX! !TY! space

    %=== compute new head location and attempt to move ===%
    set /a "X=PX+xDiff, Y=PY+yDiff"
    set "X= !X!"
    set "Y= !Y!"
    set "X=!X:~-2!"
    set "Y=!Y:~-2!"
    (%test% !X! !Y! playerSpace) && (

    %=== move successful ===%

    %=== remove the new head location from the empty list ===%
    for %%X in ("!X!") do for %%Y in ("!Y!") do set "empty=!empty:#%%~X %%~Y=!"

    (%test% !X! !Y! food) && (
    %=== moving to food – eat it ===%

    %=== restore the tail ===%
    %plot% !TX! !TY! body
    set "snakeX=!snakeX!!TX!"
    set "snakeY=!snakeY!!TY!"

    %=== increment score and locate and draw new food ===%
    set /a "score+=1, F=(!random!%%(emptyCnt-=1))*6+1"
    for %%F in (!F!) do (%plot% !empty:~%%F,5! food)

    ) || (
    %=== moving to empty space ===%

    %=== add the former tail position to the empty list ===%
    set "empty=!empty!#!TX! !TY!"
    )

    %=== draw the new head ===%
    if defined snakeX (%plot% !PX! !PY! body)
    %plot% !X! !Y! head

    %=== Add the new head position to the snake strings ===%
    set "snakeX=!X!!snakeX!"
    set "snakeY=!Y!!snakeY!"
    set "PX=!X!"
    set "PY=!Y!"

    %draw%

    ) || (

    %=== failed move – game over ===%
    %plot% !TX! !TY! body
    call :spinner !PX! !PY! death
    %draw%
    echo(
    call :ask "Would you like to play again? (Y/N)" YN
    if /i "!key!" equ "N" (
    >"%cmdFile%" (echo quit)
    exit
    ) else (
    call :initialize
    )
    )

    set /a t1=t2
    )
    )

    :ask Prompt ValidKeys
    :: Prompt for a keypress. ValidKeys is a list of acceptable keys
    :: Wait until a valid key is pressed and return result in Key variable
    >"%cmdFile%" (echo prompt)
    <nul set /p "=%~1 "
    :purge
    (%getKey% 🙂
    if not defined key goto :purge
    :getResponse
    (%getKey% %2)
    if not defined key (
    >"%cmdFile%" (echo one)
    goto :getResponse
    )
    exit /b

    :spinner X Y ValueVar
    set /a d1=-1000000
    for /l %%N in (1 1 5) do for %%C in (%spinner%) do (
    call :spinnerDelay
    %plot% %1 %2 %%C
    %draw%
    )
    call :spinnerDelay
    (%plot% %1 %2 %3)
    exit /b

    :spinnerDelay
    for /f "tokens=1-4 delims=:.," %%a in ("!time: =0!") do set /a "d2=(((1%%a*60)+1%%b)*60+1%%c)*100+1%%d-36610100, dDiff=d2-d1"
    if %dDiff% lss 0 set /a dDiff+=24*60*60*100
    if %dDiff% lss %spinnerDelay% goto :spinnerDelay
    set /a d1=d2
    exit /b

    ::————————————-
    :initialize
    cls

    echo Speed Options:
    echo delay
    echo # Description (seconds)
    echo — ———– ———
    echo 1 Sluggard 0.20
    echo 2 Crawl 0.15
    echo 3 Slow 0.10
    echo 4 Normal 0.07
    echo 5 Fast 0.05
    echo 6 Insane 0.03
    echo 0 Unplayable none
    echo(
    call :ask "Pick a speed (1-6, 0):" 1234560
    set "difficulty=!desc%key%!"
    set "delay=!delay%key%!"
    echo %key% – %difficulty%
    echo(
    <nul set /p "=Initializing."
    set "axis=X"
    set "xDiff=+1"
    set "yDiff=+0"
    set "empty="
    set /a "PX=1, PY=height/2, FX=width/2+1, FY=PY, score=0, emptyCnt=0, t1=-1000000"
    set "snakeX= %PX%"
    set "snakeY= %PY%"
    set "snakeX=%snakeX:~-2%"
    set "snakeY=%snakeY:~-2%"
    for /l %%Y in (0 1 %height%) do (
    <nul set /p "=."
    set "line%%Y="
    for /l %%X in (0,1,%width%) do (
    set "cell="
    if %%Y equ 0 set "cell=%bound%"
    if %%Y equ %height% set "cell=%bound%"
    if %%X equ 0 set "cell=%bound%"
    if %%X equ %width% set "cell=%bound%"
    if %%X equ %PX% if %%Y equ %PY% set "cell=%head%"
    if not defined cell (
    set "cell=%space%"
    set "eX= %%X"
    set "eY= %%Y"
    set "empty=!empty!#!eX:~-2! !eY:~-2!"
    set /a emptyCnt+=1
    )
    if %%X equ %FX% if %%Y equ %FY% set "cell=%food%"
    set "line%%Y=!line%%Y!!cell!"
    )
    )
    (%draw%)
    echo(
    echo Movement keys: %up%=up %down%=down %left%=left %right%=right
    echo Avoid running into yourself (%body%%body%%head%) or wall (%bound%)
    echo Eat food (%food%) to grow.
    echo(
    call :ask "Press any alpha-numeric key to start…" %keys%
    >"%cmdFile%" (echo go)
    exit /b

    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :controller

    setlocal enableDelayedExpansion
    set "cmd=hold"
    set "key="
    for /l %%. in (1 0 1) do (
    if "!cmd!" neq "hold" (
    %choice% /n /c:!keys!
    set "key

  20. This is so much f**

  21. This link is not find

  22. A slightly better version

    @echo off
    color E
    if "%~1" == "startGame" goto :game
    if "%~1" == "startController" goto :controller

    ::———————————————————————
    :: setup some global variables used by both the game and the controller

    setlocal disableDelayedExpansion
    :getSession
    if defined temp (set "tempFileBase=%temp%") else if defined tmp set "tempFileBase=%tmp%"
    set "tempFileBase=%tempFileBase%Snake%time::=_%"
    set "keyFile=%tempFileBase%_key.txt"
    set "cmdFile=%tempFileBase%_cmd.txt"
    set "gameLock=%tempFileBase%_gameLock.txt"
    set "gameLog=%tempFileBase%_gameLog.txt"
    set "signal=%tempFileBase%_signal.txt"
    set "saveLoc=%userprofile%Snake"
    set "userPref=%saveLoc%SnakeUserPref.txt"
    set "hiFile=%saveLoc%Snake!growth!Hi"
    set "keyStream=9"
    set "cmdStream=8"
    set "lockStream=7"

    ::——————————————
    :: Lock this game session and launch.
    :: Loop back and try a new session if failure.
    :: Cleanup and exit when finished

    call :launch %lockStream%>"%gameLock%" || goto :getSession
    del "%tempFileBase%*"
    exit /b

    ::——————————————
    :launch the game and the controller

    call :fixLogs
    copy nul "%keyFile%" >nul
    copy nul "%cmdFile%" >nul
    start "" /b cmd /c ^""%~f0" startController %keyStream%^>^>"%keyFile%" %cmdStream%^<"%cmdFile%" 2^>nul ^>nul^"
    cmd /c ^""%~f0" startGame %keyStream%^<"%keyFile%" %cmdStream%^>^>"%cmdFile%" ^<nul^"
    echo(

    ::————————————————————–
    :: Upon exit, wait for the controller to close before returning

    :close
    2>nul (>>"%keyFile%" call )||goto :close
    if not exist "%~dp0CursorPos.exe" (
    echo Game play can be improved by installing
    echo Aacini's CursorPos.exe, available at
    echo http://goo.gl/hr6Kkn
    echo(
    echo %cmdcmdline%|find /i "%~f0">nul&&pause
    )
    exit /b 0

    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :game
    title %~nx0
    cls

    ::—————————————
    :: Playfield size
    :: max playing field: (width-2)*(height-2) <= 1365

    set "width=40" max=99
    set "height=25" max=99

    ::—————————-
    :: resize the console window

    set /a cols=width+1, lines=height+10, area=(width-2)*(height-2)
    if %area% gtr 1365 (
    echo ERROR: Playfield area too large
    %sendCmd% quit
    exit
    )
    if %lines% lss 14 set lines=14
    if %cols% lss 46 set cols=46
    mode con: cols=%cols% lines=%lines%

    ::—————————-
    :: define variables

    set "configOptions=diffCode difficulty growth moveKeys up down left right"
    set "configOptionCnt=9"

    set "moveKeys=4"

    set "up=W"
    set "down=S"
    set "left=A"
    set "right=D"
    set "pause=P"

    set "space= "
    set "bound=#"
    set "food=+"
    set "head=@"
    set "body=O"
    set "death=X"

    set "growth=1"

    if exist "%userPref%" for /f "usebackq delims=" %%V in ("%userPref%") do set "%%V"

    set "spinner1=-"
    set "spinner2="
    set "spinner3=|"
    set "spinner4=/"
    set "spinner= spinner1 spinner2 spinner3 spinner4 "

    set "delay1=20"
    set "delay2=15"
    set "delay3=10"
    set "delay4=7"
    set "delay5=5"
    set "delay6=3"

    set "desc1=Sluggard"
    set "desc2=Crawl"
    set "desc3=Slow"
    set "desc4=Normal"
    set "desc5=Fast"
    set "desc6=Insane"

    set "spinnerDelay=3"

    set /a "width-=1, height-=1"

    :: define LF as a Line Feed (newline) character
    set ^"LF=^

    ^" Above empty line is required – do not remove

    :: define CR as a Carriage Return character
    for /f %%A in ('copy /Z "%~dpf0" nul') do set "CR=%%A"

    :: define BS as a BackSpace character
    for /f %%A in ('"prompt $H&for %%B in (1) do rem"') do set "BS=%%A"

    set "upper=A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"
    set "invalid=*~="

    ::—————————
    :: define macros

    if exist "%~dp0CursorPos.exe" (
    set "cls=CursorPos 0 0"
    set "ClearLine=echo( &CursorPos 0 -1"
    set "ClearPrev=CursorPos 0 -0&echo( "
    ) else (
    set "cls=cls"
    set "ClearLine="
    set "ClearPrev="
    )

    :: define a newline with line continuation
    set ^"n=^^^%LF%%LF%^%LF%%LF%^^"

    :: setErr
    ::: Sets the ERRORLEVEL to 1
    set "setErr=(call)"

    :: clrErr
    ::: Sets the ERRORLEVEL to 0
    set "clrErr=(call )"

    :: sendCmd command
    ::: sends a command to the controller
    set "sendCmd=>&%cmdStream% echo"

    :: getKey [ValidKey] [ValidKey…]
    ::: Check for keypress from the controller. Only accept a ValidKey.
    ::: Token delimiters and poison characters must be quoted.
    ::: Accept any key if no ValidKey specified.
    ::: Return result in Key variable. Key is undefined if no valid keypress.
    set getKey=%n%
    for %%# in (1 2) do if %%#==2 (%n%
    set key=%n%
    set inKey=%n%
    set keyTest=%n%
    ^<^&%keyStream% set /p "inKey="%n%
    if defined inKey (%n%
    set inKey=!inKey:~0,-1!%n%
    for %%C in (!args!) do set /a keyTest=1^&if /i !inKey! equ %%~C set key=!inKey!%n%
    )%n%
    if not defined keyTest set key=!inKey!%n%
    ) else set args=

    :: draw
    ::: draws the board
    set draw=%n%
    set screen=%n%
    for /l %%Y in (0,1,%height%) do set screen=!screen!!line%%Y!!LF!%n%
    set screen=!screen!Speed = !Difficulty! !replay!!LF!Growth Rate = !growth! HighScore = !hi!!LF!Score = !score! Time = !m!:!s!%n%
    if defined replay if not defined replayFinished (%n%
    set screen=!screen!!LF!!LF!Press a key to abort the replay%n%
    )%n%
    %cls%^&echo(!screen!

    :: test X Y ValueListVar
    ::: tests if value at coordinates X,Y is within contents of ValueListVar
    set test=%n%
    for %%# in (1 2) do if %%#==2 (for /f "tokens=1-3" %%1 in ("!args!") do (%n%
    for %%A in ("!line%%2:~%%1,1!") do if "!%%3:%%~A=!" neq "!%%3!" %clrErr% else %setErr%%n%
    )) else set args=

    :: plot X Y ValueVar
    ::: places contents of ValueVar at coordinates X,Y
    set plot=%n%
    for %%# in (1 2) do if %%#==2 (for /f "tokens=1-3" %%1 in ("!args!") do (%n%
    set "part2=!line%%2:~%%1!"%n%
    set "line%%2=!line%%2:~0,%%1!!%%3!!part2:~1!"%n%
    )) else set args=

    ::————————————–
    :: start the game
    setlocal enableDelayedExpansion
    if not exist "%saveLoc%" md "%saveLoc%"
    set "replay= Aborting… "
    set "replayAvailable="
    call :loadHighScores
    call :mainMenu

    ::————————————–
    :: main loop (infinite loop)
    for /l %%. in () do (

    %=== check for and process abort signal if in replay mode ===%
    if defined replay if exist "%signal%" (
    del "%signal%"
    set "replayFinished=1"
    %draw%
    echo(
    %ClearLine%
    <nul set /p "=Aborting… "
    findstr "^" >nul <&%keyStream%
    for %%A in (!configOptions!) do set "%%A=!%%ASave!"
    call :mainMenu
    )

    %=== compute time since last move ===%
    for /f "tokens=1-4 delims=:.," %%a in ("!time: =0!") do set /a "t2=(((1%%a*60)+1%%b)*60+1%%c)*100+1%%d-36610100, tDiff=t2-t1"
    if !tDiff! lss 0 set /a tDiff+=24*60*60*100

    if !tDiff! geq !delay! (
    %=== delay has expired, so time for movement ===%
    set /a t1=t2

    %=== compute game time ===%
    if not defined gameStart set "gameStart=!t2!"
    set /a "gameTime=(t2-gameStart)"
    if !gameTime! lss 0 set /a "gameTime+=24*60*60*100"
    set /a "gameTime=(gameTime-pauseTime)/100, m=gameTime/60, s=gameTime%%60"
    if !m! lss 10 set "m=0!m!"
    if !s! lss 10 set "s=0!s!"

    %=== get keypress ===%
    %getKey% !keys!
    if /i !key! equ !pause! (

    %=== pause game ===%
    echo(
    call :ask "PAUSED – Press a key to continue…"
    %ClearPrev%
    %sendCmd% go
    for /f "tokens=1-4 delims=:.," %%a in ("!time: =0!") do set /a "t2=(((1%%a*60)+1%%b)*60+1%%c)*100+1%%d-36610100, tDiff=t2-t1"
    if !tDiff! lss 0 set /a tDiff+=24*60*60*100
    set /a pauseTime+=tDiff

    ) else (

    %=== establish direction ===%
    if not defined replay (echo(!key!.) >>"!gameLog!"
    for %%K in (!key!) do if !moveKeys! equ 2 (
    set /a "xDiff=xTurn%%K*!yDiff!, yDiff=yTurn%%K*!xDiff!"
    ) else if "!%%KAxis!" neq "!axis!" (
    set /a "xDiff=xDiff%%K, yDiff=yDiff%%K"
    set "axis=!%%KAxis!"
    )

    %=== erase the tail ===%
    set "TX=!snakeX:~-2!"
    set "TY=!snakeY:~-2!"
    set "snakeX=!snakeX:~0,-2!"
    set "snakeY=!snakeY:~0,-2!"
    %plot% !TX! !TY! space

    %=== compute new head location and attempt to move ===%
    set /a "X=PX+xDiff, Y=PY+yDiff"
    set "X= !X!"
    set "Y= !Y!"
    set "X=!X:~-2!"
    set "Y=!Y:~-2!"
    (%test% !X! !Y! playerSpace) && (

    %=== move successful ===%

    %=== remove the new head location from the empty list ===%
    for %%X in ("!X!") do for %%Y in ("!Y!") do set "empty=!empty:#%%~X %%~Y=!"

    %=== eat any food that may be present ===%
    (%test% !X! !Y! food) && (
    %=== initiate growth ===%
    set /a grow+=growth

    %=== locate and draw new food ===%
    if defined replay (
    <&%keyStream% set /p "F="
    ) else (
    set /a "F=(!random!%%(emptyCnt-1))*6+1"
    (echo !F!) >>"!gameLog!"
    )
    for %%F in (!F!) do (%plot% !empty:~%%F,5! food)
    )

    if !grow! gtr 0 (
    %=== restore the tail ===%
    %plot% !TX! !TY! body
    set "snakeX=!snakeX!!TX!"
    set "snakeY=!snakeY!!TY!"
    set /a emptyCnt-=1

    %=== manage score ===%
    set /a "score+=1, grow-=1"
    if not defined replay if !score! gtr !hi! set /a "hi+=1, newHi=1"

    ) else (
    %=== add the former tail position to the empty list ===%
    set "empty=!empty!#!TX! !TY!"
    )

    %=== draw the new head ===%
    if defined snakeX (%plot% !PX! !PY! body)
    %plot% !X! !Y! head

    %=== Add the new head position to the snake strings ===%
    set "snakeX=!X!!snakeX!"
    set "snakeY=!Y!!snakeY!"
    set "PX=!X!"
    set "PY=!Y!"

    %draw%

    ) || (

    %=== failed move – game over ===%
    set "replayFinished=1"
    %plot% !TX! !TY! body
    call :spinner !PX! !PY! death
    %draw%
    if defined newHi (
    echo(
    echo New High Score – Congratulation

  23. im going to type it myself like a person

  24. Does it use any app to open

  25. ❄✌☹????✋☠☝ ✋☠ ????✋☠????✋☠☝????✏

  26. What Is The Nemeric Key

  27. @echo off
    if "%~1" == "startGame" goto :game
    if "%~1" == "startController" goto :controller

    ::————————————————————
    :: verify existence of CHOICE command
    :: set up a macro appropriately depending on available version

    set "choice="
    2>nul >nul choice /c:yn /t 0 /d y
    if errorlevel 1 if not errorlevel 2 set "choice=choice /cs"
    if not defined choice (
    2>nul >nul choice /c:yn /t:y,1
    if errorlevel 1 if not errorlevel 2 set "choice=choice /s"
    )
    if not defined choice (
    echo ERROR: This game requires the CHOICE command, but it is missing.
    echo Game aborted. 🙁
    echo(
    echo A 16 bit port of CHOICE.EXE from FREEDOS is available at
    echo http://winsupport.org/utilities/freedos-choice.html
    echo(
    echo A 32 bit version from ??? suitable for 64 bit machines is available at
    echo http://hp.vector.co.jp/authors/VA007219/dkclonesup/choice.html
    echo(
    exit /b
    )

    ::———————————————————————
    :: setup some global variables used by both the game and the controller

    set "keys=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
    set "keyFile=key.txt"
    set "cmdFile=cmd.txt"

    ::——————————————
    :: launch the game and the controller

    copy nul "%keyFile%" >nul
    start "" /b "%~f0" startController 9^>^>%keyFile% 2^>nul ^>nul
    cmd /c "%~f0" startGame 9^<%keyFile% ^<nul
    echo(

    ::——————————————————————————–
    :: Upon exit, wait for the controller to close before deleting the temp input file

    :close
    2>nul (>>"%keyFile%" call )||goto :close
    del "%keyFile%"
    exit /b

    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :game
    setlocal disableDelayedExpansion
    title %~nx0
    cls

    ::—————————-
    :: user configurable options

    set "up=W"
    set "down=S"
    set "left=A"
    set "right=D"

    set "width=40" max=99
    set "height=25" max=99
    :: max playing field: (width-2)*(height-2) <= 1365

    ::—————————-
    :: resize the console window

    set /a cols=width+1, lines=height+10, area=(width-2)*(height-2)
    if %area% gtr 1365 (
    echo ERROR: Playfield area too large
    >"%cmdFile%" (echo quit)
    exit
    )
    if %lines% lss 14 set lines=14
    if %cols% lss 46 set cols=46
    mode con: cols=%cols% lines=%lines%

    ::—————————-
    :: define variables

    set "spinner1=-"
    set "spinner2="
    set "spinner3=|"
    set "spinner4=/"
    set "spinner= spinner1 spinner2 spinner3 spinner4 "

    set "space= "
    set "bound=#"
    set "food=+"
    set "head=@"
    set "body=O"
    set "death=X"
    set "playerSpace=%space%%food%"

    set "xDiff%up%=+0"
    set "xDiff%down%=+0"
    set "xDiff%left%=-1"
    set "xDiff%right%=+1"

    set "yDiff%up%=-1"
    set "yDiff%down%=+1"
    set "yDiff%left%=+0"
    set "yDiff%right%=+0"

    set "%up%Axis=Y"
    set "%down%Axis=Y"
    set "%left%Axis=X"
    set "%right%Axis=X"

    set "delay1=20"
    set "delay2=15"
    set "delay3=10"
    set "delay4=7"
    set "delay5=5"
    set "delay6=3"
    set "delay0=0"

    set "desc1=Sluggard"
    set "desc2=Crawl"
    set "desc3=Slow"
    set "desc4=Normal"
    set "desc5=Fast"
    set "desc6=Insane"
    set "desc0=Unplayable"

    set "spinnerDelay=3"

    set /a "width-=1, height-=1"

    ::—————————
    :: define macros

    ::define a Line Feed (newline) string (normally only used as !LF!)
    set LF=^

    ::Above 2 blank lines are required – do not remove

    ::define a newline with line continuation
    set ^"n=^^^%LF%%LF%^%LF%%LF%^^"

    :: setErr
    ::: Sets the ERRORLEVEL to 1
    set "setErr=(call)"

    :: clrErr
    ::: Sets the ERRORLEVEL to 0
    set "clrErr=(call )"

    :: getKey ValidKeys
    ::: Check for keypress. Only accept keys listed in ValidKeys
    ::: Return result in Key variable. Key is undefined if no valid keypress.
    set getKey=%n%
    for %%# in (1 2) do if %%#==2 (for /f "eol= delims= " %%1 in ("!args!") do (%n%
    set "validKeys=%%1"%n%
    set "key="%n%
    ^<^&9 set /p "key="%n%
    if defined key if "!key!" neq ":" (%n%
    set /a key-=1%n%
    for %%K in (!key!) do set "key=!keys:~%%K,1!"%n%
    )%n%
    for %%K in (!key!) do if "!validKeys:%%K=!" equ "!validKeys!" set "key="%n%
    )) else set args=

    :: draw
    ::: draws the board
    set draw=%n%
    cls%n%
    for /l %%Y in (0,1,%height%) do echo(!line%%Y!%n%
    echo Speed=!Difficulty!%n%
    echo Score=!score!

    :: test X Y ValueListVar
    ::: tests if value at coordinates X,Y is within contents of ValueListVar
    set test=%n%
    for %%# in (1 2) do if %%#==2 (for /f "tokens=1-3" %%1 in ("!args!") do (%n%
    for %%A in ("!line%%2:~%%1,1!") do if "!%%3:%%~A=!" neq "!%%3!" %clrErr% else %setErr%%n%
    )) else set args=

    :: plot X Y ValueVar
    ::: places contents of ValueVar at coordinates X,Y
    set plot=%n%
    for %%# in (1 2) do if %%#==2 (for /f "tokens=1-3" %%1 in ("!args!") do (%n%
    set "part2=!line%%2:~%%1!"%n%
    set "line%%2=!line%%2:~0,%%1!!%%3!!part2:~1!"%n%
    )) else set args=

    ::————————————–
    :: start the game
    setlocal enableDelayedExpansion
    call :initialize

    ::————————————–
    :: main loop (infinite loop)
    for /l %%. in (1 0 1) do (

    %=== compute time since last move ===%
    for /f "tokens=1-4 delims=:.," %%a in ("!time: =0!") do set /a "t2=(((1%%a*60)+1%%b)*60+1%%c)*100+1%%d-36610100, tDiff=t2-t1"
    if !tDiff! lss 0 set /a tDiff+=24*60*60*100

    if !tDiff! geq !delay! (
    %=== delay has expired, so time for movement ===%

    %=== establish direction ===%
    %getKey% ASDW
    for %%K in (!key!) do if "!%%KAxis!" neq "!axis!" (
    set /a "xDiff=xDiff%%K, yDiff=yDiff%%K"
    set "axis=!%%KAxis!"
    )

    %=== erase the tail ===%
    set "TX=!snakeX:~-2!"
    set "TY=!snakeY:~-2!"
    set "snakeX=!snakeX:~0,-2!"
    set "snakeY=!snakeY:~0,-2!"
    %plot% !TX! !TY! space

    %=== compute new head location and attempt to move ===%
    set /a "X=PX+xDiff, Y=PY+yDiff"
    set "X= !X!"
    set "Y= !Y!"
    set "X=!X:~-2!"
    set "Y=!Y:~-2!"
    (%test% !X! !Y! playerSpace) && (

    %=== move successful ===%

    %=== remove the new head location from the empty list ===%
    for %%X in ("!X!") do for %%Y in ("!Y!") do set "empty=!empty:#%%~X %%~Y=!"

    (%test% !X! !Y! food) && (
    %=== moving to food – eat it ===%

    %=== restore the tail ===%
    %plot% !TX! !TY! body
    set "snakeX=!snakeX!!TX!"
    set "snakeY=!snakeY!!TY!"

    %=== increment score and locate and draw new food ===%
    set /a "score+=1, F=(!random!%%(emptyCnt-=1))*6+1"
    for %%F in (!F!) do (%plot% !empty:~%%F,5! food)

    ) || (
    %=== moving to empty space ===%

    %=== add the former tail position to the empty list ===%
    set "empty=!empty!#!TX! !TY!"
    )

    %=== draw the new head ===%
    if defined snakeX (%plot% !PX! !PY! body)
    %plot% !X! !Y! head

    %=== Add the new head position to the snake strings ===%
    set "snakeX=!X!!snakeX!"
    set "snakeY=!Y!!snakeY!"
    set "PX=!X!"
    set "PY=!Y!"

    %draw%

    ) || (

    %=== failed move – game over ===%
    %plot% !TX! !TY! body
    call :spinner !PX! !PY! death
    %draw%
    echo(
    call :ask "Would you like to play again? (Y/N)" YN
    if /i "!key!" equ "N" (
    >"%cmdFile%" (echo quit)
    exit
    ) else (
    call :initialize
    )
    )

    set /a t1=t2
    )
    )

    :ask Prompt ValidKeys
    :: Prompt for a keypress. ValidKeys is a list of acceptable keys
    :: Wait until a valid key is pressed and return result in Key variable
    >"%cmdFile%" (echo prompt)
    <nul set /p "=%~1 "
    :purge
    (%getKey% 🙂
    if not defined key goto :purge
    :getResponse
    (%getKey% %2)
    if not defined key (
    >"%cmdFile%" (echo one)
    goto :getResponse
    )
    exit /b

    :spinner X Y ValueVar
    set /a d1=-1000000
    for /l %%N in (1 1 5) do for %%C in (%spinner%) do (
    call :spinnerDelay
    %plot% %1 %2 %%C
    %draw%
    )
    call :spinnerDelay
    (%plot% %1 %2 %3)
    exit /b

    :spinnerDelay
    for /f "tokens=1-4 delims=:.," %%a in ("!time: =0!") do set /a "d2=(((1%%a*60)+1%%b)*60+1%%c)*100+1%%d-36610100, dDiff=d2-d1"
    if %dDiff% lss 0 set /a dDiff+=24*60*60*100
    if %dDiff% lss %spinnerDelay% goto :spinnerDelay
    set /a d1=d2
    exit /b

    ::————————————-
    :initialize
    cls

    echo Speed Options:
    echo delay
    echo # Description (seconds)
    echo — ———– ———
    echo 1 Sluggard 0.20
    echo 2 Crawl 0.15
    echo 3 Slow 0.10
    echo 4 Normal 0.07
    echo 5 Fast 0.05
    echo 6 Insane 0.03
    echo 0 Unplayable none
    echo(
    call :ask "Pick a speed (1-6, 0):" 1234560
    set "difficulty=!desc%key%!"
    set "delay=!delay%key%!"
    echo %key% – %difficulty%
    echo(
    <nul set /p "=Initializing."
    set "axis=X"
    set "xDiff=+1"
    set "yDiff=+0"
    set "empty="
    set /a "PX=1, PY=height/2, FX=width/2+1, FY=PY, score=0, emptyCnt=0, t1=-1000000"
    set "snakeX= %PX%"
    set "snakeY= %PY%"
    set "snakeX=%snakeX:~-2%"
    set "snakeY=%snakeY:~-2%"
    for /l %%Y in (0 1 %height%) do (
    <nul set /p "=."
    set "line%%Y="
    for /l %%X in (0,1,%width%) do (
    set "cell="
    if %%Y equ 0 set "cell=%bound%"
    if %%Y equ %height% set "cell=%bound%"
    if %%X equ 0 set "cell=%bound%"
    if %%X equ %width% set "cell=%bound%"
    if %%X equ %PX% if %%Y equ %PY% set "cell=%head%"
    if not defined cell (
    set "cell=%space%"
    set "eX= %%X"
    set "eY= %%Y"
    set "empty=!empty!#!eX:~-2! !eY:~-2!"
    set /a emptyCnt+=1
    )
    if %%X equ %FX% if %%Y equ %FY% set "cell=%food%"
    set "line%%Y=!line%%Y!!cell!"
    )
    )
    (%draw%)
    echo(
    echo Movement keys: %up%=up %down%=down %left%=left %right%=right
    echo Avoid running into yourself (%body%%body%%head%) or wall (%bound%)
    echo Eat food (%food%) to grow.
    echo(
    call :ask "Press any alpha-numeric key to start…" %keys%
    >"%cmdFile%" (echo go)
    exit /b

    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :controller

    setlocal enableDelayedExpansion
    set "cmd=hold"
    set "key="
    for /l %%. in (1 0 1) do (
    if "!cmd!" neq "hold" (
    %choice% /n /c:!keys!
    set "key

  28. wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle
    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle
    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

    wiggle wiggle

  29. it doesn`t work for win 10

  30. holy man good job man

  31. How to create a key? Exemple: Press "W" and going up. Press "S" and going down.

  32. it said invalid command

  33. and i am now 13

Leave a comment

Your email address will not be published.


*