1

CMD/Batch coding

Oldman_Jankins's Avatar Oldman_Jankins10/1/12 11:39 am
10/2/2012 11:31 am
Oldman_Jankins's Avatar Oldman_Jankins
If you want to post any CMD/Batch games or if you need help with coding or just want to learn here is the place to be.
RULES
Click to reveal
1. No swearing
2. Keep the games clean this is for all ages
3. Dont spam if you are not happy with the help you get
4. Repect the people that post here
5. POST YOUR OWN WORK
6. DONT STEAL OTHERS WORK this is a place to share and give advice not to take others work
Posted by Oldman_Jankins's Avatar
Oldman_Jankins
Level 24 : Expert Artist
7

Create an account or sign in to comment.

12

1
10/02/2012 11:31 am
Level 24 : Expert Artist
Oldman_Jankins
Oldman_Jankins's Avatar
this is my "1 hour game" i made it in an hour just paste this into a .txt and rename it game.bat

Click to reveal
:::::::::start:::::::::
@echo off
goto menu

:menu
cls
echo what do you want to do?
echo.
echo Play Game------(1)
echo Info-----------(2)
echo Exit-----------(3)
set /p a=
if %a% EQU 1 goto start2
if %a% EQU 2 goto info
if %a% EQU 3 exit

:start2
cls
set hp=100
set hpm=100
set mhp=10
set mhpm=10
set atk=2
set matk=1
set gold=0
set pot=2
goto main

:main
cls
Echo Health %hp%/%hpm%
echo Gold %gold%
echo Potions %pot%
echo.
echo.
echo What did you want to do?
echo Battle--------(1)
echo Shop----------(2)
echo Drink potion--(3)
echo Exit----------(4)
set /p a=
if %a% EQU 1 goto battle
if %a% EQU 2 goto shop
if %a% EQU 3 goto potion
if %a% GEQ 4 exit

:potion
cls
if %pot% LEQ 0 goto nopotion
set /a prh=%random%*30/32767+1
set /a pot=%pot%-1
set /a hp=%hp%+%prh%
Echo you heal %prh%
pause >nul
if %hp% GEQ %hpm% goto potion1
goto main

:potion1
set /a hp=%hpm%
goto main

:nopotion
cls
echo You dont have any!
pause >nul
goto main

:shop
cls
echo What do you want to buy?
echo Gold %gold%
echo.
echo potion 5 gold (1)
echo home (2)
set /p a=
if %a% EQU 1 goto shop1
if %a% EQU 2 goto main

:shop1
cls
if %gold% LEQ 4 goto no
set /a pot=%pot%+1
set /a gold=%gold%-5
goto shop

:no
echo not enough gold
pause >nul
goto shop


:battle
cls
if %mhp% LEQ 0 goto win
if %hp% LEQ 0 goto death
set /a matk=%random%*3/32767+1
set /a atk=%random%*10/32767+1
echo What do you want to do? You hp---------%hp%/%hpm%
echo Fight----(1) Monster'S hp---%mhp%/%mhpm%
echo Run------(2)
set /p a=
if %a% EQU 1 goto battle1
if %a% EQU 2 goto main

:death
cls
echo You Died!
pause >nul
exit

:battle1
cls
echo You do %atk% damage to the monster
set /a mhp= %mhp%-%atk%
pause >nul
goto battle2

:battle2
cls
if %mhp% LEQ 0 goto win
if %hp% LEQ 0 goto death
echo The mosnster does %matk% to you
set /a hp= %hp%-%matk%
pause >nul
goto battle

:win
cls
set /a goldp=%random%*10/32767+1
set /a gold=%gold%+%goldp%
set /a mhp=%mhpm%
echo You win! You find %goldp% Gold you know have %gold%
pause >nul
goto main
1
10/02/2012 10:58 am
Level 24 : Expert Artist
Oldman_Jankins
Oldman_Jankins's Avatar
Bump
1
10/01/2012 2:16 pm
Level 61 : High Grandmaster Modder
ehdfawq3er
ehdfawq3er's Avatar
This is all very nice stuff. I know the color and @echo off. I think I understand the language now pretty much...
1
10/01/2012 12:20 pm
Level 14 : Journeyman Goblin
tankboy
tankboy's Avatar
Goto http://www.dostips.com/forum
Its a forum with loads of friendly people who can program in CMD/Batch
1
10/01/2012 12:18 pm
Level 24 : Expert Artist
Oldman_Jankins
Oldman_Jankins's Avatar
because i was giving tommy a code to put into his game and i know that he would already have the @echo off command in his game
1
10/01/2012 12:13 pm
Level 24 : Expert Artist
Oldman_Jankins
Oldman_Jankins's Avatar
i didnt forget it i left it out
1
10/01/2012 12:15 pm
Level 23 : Expert Modder
some1epic123
some1epic123's Avatar
Why...?
1
10/01/2012 12:01 pm
Level 24 : Expert Artist
Oldman_Jankins
Oldman_Jankins's Avatar
it isnt my game its the login system in my game
1
10/01/2012 12:05 pm
Level 23 : Expert Modder
some1epic123
some1epic123's Avatar
I know but you still forgot @echo off. (It hides the commands your program/game is running)

Examples:


Without @echo off: C:\Users\Home\Desktop>echo 1) Start new

With @echo off: 1) Start new
1
10/01/2012 11:53 am
Level 24 : Expert Artist
Oldman_Jankins
Oldman_Jankins's Avatar
here is a sample out of one of my old games feel free to use it in your game
Click to reveal
:menu
cls
echo what do you want to do?
echo.
echo 1) Start new
echo 2) Login
echo 3) Exit
set /p a=
if %a% EQU 1 goto createuser
if %a% EQU 2 goto login
if %a% EQU 3 exit

:createuser
echo What would you like your Username to be?
set /p username1=
set v1f=0
goto checkforspaces


:checkforspaces
set x=!v1f!
set Letter%v1f%=!username1:~%x%,1!
if "!Letter%v1f%!" EQU " " (
echo.
echo.
echo Sorry you cant use spaces in your Username.
pause>nul
goto start
)
echo What would you like your Password to be?
set /p password1=
goto start2


:login
cls
set /p name1=Username:
if not exist "%name1%.bat" (
echo That is not a valid Username.
pause>nul
goto start
)
set /p pass1=Password:
call %name1%.bat
if not %password1% EQU %pass1% (
echo That is not a valid Password.
pause>nul
goto start
)
goto main

:save
(
echo set username1=%username1%
echo set password1=%password1%
)>%username1%.bat
goto menu
1
10/01/2012 11:59 am
Level 23 : Expert Modder
some1epic123
some1epic123's Avatar
You forgot @echo off at the start of your game.
1
10/01/2012 11:49 am
Level 1 : New Miner
tommy 121314
tommy 121314's Avatar
Can anyone let me know how to make a login system because my one is very unsecure
My login system
Click to reveal
@echo off
color 0a
:username
cls
echo Username?
set /p username=

if %username% == admin goto password_id1
if %username% == bob goto password_id2

:password_id1
cls
echo Password?
set /p password=

if %password% == admin goto end

:password_id2
cls
echo Password?
set /p password=

if %password% == bobspassword goto end

:end
cls
echo You have sucessfully logged in!
pause
exit
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome