You are viewing our Forum Archives. To view or take place in current topics click here.
Need CMD game help (batch)
Posted:
Need CMD game help (batch)Posted:
Status: Offline
Joined: Mar 18, 201212Year Member
Posts: 860
Reputation Power: 35
My code (so far)
What happens?
[ Register or Signin to view external links. ]
It list option 3 and 4 when you only choose one of them.
I may be stupid.
this is a school project
@echo off
title Hunger Games Game
cls
:menu
echo.
echo Welcome to the Hunger Games game!
echo press 1 to enter the arena!
echo.
SET /P M= Enter Symbol=
IF %M%==1 GOTO arena
IF %M%==2 GOTO timer
IF %M%==3 GOTO Backpack
IF %M%==4 GOTO woods
:arena
echo Welcome to the arena!
echo there is 35 seconds till the games start press 2 if ready!
SET /P M= Enter Symbol=
:timer
echo The games will begin in 35 seconds.
echo.
echo 35
ping -n 2 127.0.0.1>nul
echo 34
ping -n 2 127.0.0.1>nul
echo 33
ping -n 2 127.0.0.1>nul
echo 32
ping -n 2 127.0.0.1>nul
echo 31
echo 30
ping -n 2 127.0.0.1>nul
echo 29
ping -n 2 127.0.0.1>nul
echo 28
ping -n 2 127.0.0.1>nul
echo 27
ping -n 2 127.0.0.1>nul
echo 26
echo 25
ping -n 2 127.0.0.1>nul
echo 24
ping -n 2 127.0.0.1>nul
echo 23
ping -n 2 127.0.0.1>nul
echo 22
ping -n 2 127.0.0.1>nul
echo 21
echo 20
ping -n 2 127.0.0.1>nul
echo 19
ping -n 2 127.0.0.1>nul
echo 18
ping -n 2 127.0.0.1>nul
echo 17
ping -n 2 127.0.0.1>nul
echo 16
echo 15
ping -n 2 127.0.0.1>nul
echo 14
ping -n 2 127.0.0.1>nul
echo 13
ping -n 2 127.0.0.1>nul
echo 12
ping -n 2 127.0.0.1>nul
echo 11
echo 10
ping -n 2 127.0.0.1>nul
echo 9
ping -n 2 127.0.0.1>nul
echo 8
ping -n 2 127.0.0.1>nul
echo 7
ping -n 2 127.0.0.1>nul
echo 6
echo 5
ping -n 2 127.0.0.1>nul
echo 4
ping -n 2 127.0.0.1>nul
echo 3
ping -n 2 127.0.0.1>nul
echo 2
ping -n 2 127.0.0.1>nul
echo 1
echo BOOM! The games have began should I run for a backpack or run for the woods?
echo 3= Go for backpack 4= Run to woods
echo.
SET /P M= Enter Symbol=
:Backpack
echo you run towards the middle and you grab the backpack.
echo as you grab it a girl from district to has spotted you.
echo you run towards the woods and she throws a knife.
echo luckly it hits you in the back pack and you escape into freedom.
echo you run until you think you are safe and you sit and see whats in your pack.
echo you find many useful things.
echo now do you sit and rest or do you continue on?
echo 5= Continue wandering through the woods.
echo 6= Stay and rest and hope no one will find you.
echo.
:woods
echo You straight away run towards the woods trying to not be seen.
echo you make it to the edge of the trees when you turn your sprint into a jog.
echo as you continue to wander around in the woods you find a small cave.
echo you have been walking for hours and the sun is about to set.
echo on your hike you have found nothing. no food, water oor weapons
echo you diecide to stay in the cave for the night.
echo as you lay there trying to get to sleep in the coldness.
echo when al of a sudden you hear some voice's and see some people soming your way.
echo you try to hide.
echo when they finally walk close enough they see you and kill you.
echo Game over. Return to menu? Yes enter /.
echo.
pause
What happens?
[ Register or Signin to view external links. ]
It list option 3 and 4 when you only choose one of them.
I may be stupid.
this is a school project
#2. Posted:
Status: Offline
Joined: Jul 15, 201212Year Member
Posts: 329
Reputation Power: 14
Status: Offline
Joined: Jul 15, 201212Year Member
Posts: 329
Reputation Power: 14
add me on skype and i will help you kieren.bamford69
- 0useful
- 0not useful
#3. Posted:
Status: Offline
Joined: Oct 31, 201014Year Member
Posts: 2,084
Reputation Power: 95
Status: Offline
Joined: Oct 31, 201014Year Member
Posts: 2,084
Reputation Power: 95
Easy fix, at the end of the Backpack part, there wasn't a PAUSE statement, so it would continue onto the next part of the code which would be the woods: part.
I also added the IF statements needed to check the user input, and some CLS's to clear it up a bit.
If you have skype & need any more batch or coding help, add me: XBLToothPik
Here is the fixed version:
I also added the IF statements needed to check the user input, and some CLS's to clear it up a bit.
If you have skype & need any more batch or coding help, add me: XBLToothPik
Here is the fixed version:
@echo off
title Hunger Games Game
cls
:menu
echo.
echo Welcome to the Hunger Games game!
echo press 1 to enter the arena!
echo.
SET /P M= Enter Symbol=
IF %M%==1 GOTO arena
IF %M%==2 GOTO timer
IF %M%==3 GOTO Backpack
IF %M%==4 GOTO woods
:arena
cls
echo Welcome to the arena!
echo there is 35 seconds till the games start press 2 if ready!
SET /P M= Enter Symbol=
:timer
cls
echo The games will begin in 35 seconds.
echo.
echo 35
ping -n 2 127.0.0.1>nul
echo 34
ping -n 2 127.0.0.1>nul
echo 33
ping -n 2 127.0.0.1>nul
echo 32
ping -n 2 127.0.0.1>nul
echo 31
echo 30
ping -n 2 127.0.0.1>nul
echo 29
ping -n 2 127.0.0.1>nul
echo 28
ping -n 2 127.0.0.1>nul
echo 27
ping -n 2 127.0.0.1>nul
echo 26
echo 25
ping -n 2 127.0.0.1>nul
echo 24
ping -n 2 127.0.0.1>nul
echo 23
ping -n 2 127.0.0.1>nul
echo 22
ping -n 2 127.0.0.1>nul
echo 21
echo 20
ping -n 2 127.0.0.1>nul
echo 19
ping -n 2 127.0.0.1>nul
echo 18
ping -n 2 127.0.0.1>nul
echo 17
ping -n 2 127.0.0.1>nul
echo 16
echo 15
ping -n 2 127.0.0.1>nul
echo 14
ping -n 2 127.0.0.1>nul
echo 13
ping -n 2 127.0.0.1>nul
echo 12
ping -n 2 127.0.0.1>nul
echo 11
echo 10
ping -n 2 127.0.0.1>nul
echo 9
ping -n 2 127.0.0.1>nul
echo 8
ping -n 2 127.0.0.1>nul
echo 7
ping -n 2 127.0.0.1>nul
echo 6
echo 5
ping -n 2 127.0.0.1>nul
echo 4
ping -n 2 127.0.0.1>nul
echo 3
ping -n 2 127.0.0.1>nul
echo 2
ping -n 2 127.0.0.1>nul
echo 1
echo BOOM! The games have began should I run for a backpack or run for the woods?
echo 3= Go for backpack 4= Run to woods
echo.
SET /P V= Enter Symbol=
IF %V%==3 GOTO Backpack
IF %V%==4 GOTO woods
:Backpack
cls
echo you run towards the middle and you grab the backpack.
echo as you grab it a girl from district to has spotted you.
echo you run towards the woods and she throws a knife.
echo luckly it hits you in the back pack and you escape into freedom.
echo you run until you think you are safe and you sit and see whats in your pack.
echo you find many useful things.
echo now do you sit and rest or do you continue on?
echo 5= Continue wandering through the woods.
echo 6= Stay and rest and hope no one will find you.
echo.
pause
goto timer
:woods
cls
echo You straight away run towards the woods trying to not be seen.
echo you make it to the edge of the trees when you turn your sprint into a jog.
echo as you continue to wander around in the woods you find a small cave.
echo you have been walking for hours and the sun is about to set.
echo on your hike you have found nothing. no food, water oor weapons
echo you diecide to stay in the cave for the night.
echo as you lay there trying to get to sleep in the coldness.
echo when al of a sudden you hear some voice's and see some people soming your way.
echo you try to hide.
echo when they finally walk close enough they see you and kill you.
echo Game over. Return to menu? Yes enter /.
echo.
pause
goto timer
- 0useful
- 0not useful
#4. Posted:
Status: Offline
Joined: Mar 18, 201212Year Member
Posts: 860
Reputation Power: 35
Thank you for the help i now understand what i have done wrong
- 0useful
- 0not useful
#5. Posted:
Status: Offline
Joined: Mar 05, 201113Year Member
Posts: 668
Reputation Power: 26
Status: Offline
Joined: Mar 05, 201113Year Member
Posts: 668
Reputation Power: 26
Also, if you want it to look professional, I would suggest fixing your grammar.
- 1useful
- 1not useful
You are viewing our Forum Archives. To view or take place in current topics click here.