Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 12-23-2009, 11:44 PM   #11
Fully Optimized
 
vampist's Avatar
 
Join Date: Oct 2008
Location: USA
Posts: 2,404
Default Re: need help with a batch file

Quote:
Originally Posted by thevil1 View Post
wait were did you put it I wanna play
What?

EDIT: by the way I looked over you code.. Dude.. You don't need all of those echo off commands. Just one at the beginning is fine.
__________________

__________________
Everyone's Favorite Turd xD
ET: "Phone home!"
Geek: "ping 127.0.0.1"

"If that guy knew half the $h*t that I know, his fuzzy little head would explode. " - Matthew Farrell
vampist is offline   Reply With Quote
Old 12-24-2009, 12:05 AM   #12
Baseband Member
 
thevil1's Avatar
 
Join Date: Dec 2009
Posts: 36
Default Re: need help with a batch file

SET /A x=%RANDOM%%%2%

Outputs 1 or 0

It's a command in the code yes? so I was wondering were to put it.
__________________

__________________
An optimist is someone who falls off the Empire State Building, and after 50 floors says, ''So far so good!''
thevil1 is offline   Reply With Quote
Old 12-24-2009, 01:44 AM   #13
Fully Optimized
 
vampist's Avatar
 
Join Date: Oct 2008
Location: USA
Posts: 2,404
Default Re: need help with a batch file

Quote:
Originally Posted by thevil1 View Post
SET /A x=%RANDOM%%%2%

Outputs 1 or 0

It's a command in the code yes? so I was wondering were to put it.

Okay, took me a little bit because I had to rewrite almost the whole code.
But here is a working "game".
Code:
@ECHO OFF
@Color 09
:reset
@SET /A yournumber=150
GOTO :start

:start
CLS
ECHO Numbergrow -made by MaRtIn C. in 2oo9
ECHO Edited by Vampist
ECHO Try to grow your number to 5000 to win
ECHO and make sure it stays above 50 or you lose.
ECHO You start at 100 and You can type in 25 50 75 100 125 150
ECHO 175 or 200. The number you type in will either be added
ECHO or subtracted from your number.
ECHO.
ECHO Type in play to start the game or color to adjust the color
ECHO Then press ENTER
ECHO.
SET /P command1=
IF %command1% == play GOTO :play
IF %command1% == color GOTO :colorset
GOTO :start

:colorset
CLS
ECHO Type in 2 letters/numbers and then press ENTER
ECHO Color Key
ECHO 0= Black 2= Green 4= Red 6= Yellow 8= Gray
ECHO 1= Blue 3= Aqua 5= Purple 7= White 9= Light Blue
ECHO.
ECHO A= Light Green C= Light Red E= Light Yellow
ECHO B= Light Aqua D= Light Purple F= Bright Blue
ECHO The first letter/number of what you type in is the background
ECHO color, and the second letter/number is the foreground color/text color.
ECHO Example: 01 makes the background color BLACK and the foreground color BLUE.
ECHO.
ECHO Type in 2 letters/numbers and then press ENTER
ECHO.
SET /P colorcode=
Color %colorcode%
CLS
ECHO The color has been set.
ECHO.
pause
GOTO :start


:play
CLS
ECHO Your number is %yournumber%
ECHO You can type in 25 50 75 100 125 150 175 0r 200
ECHO Try to get to 5000 to win and stay above 50 or you lose.
ECHO If you want to start over type reset
ECHO.
ECHO Type in a number or letter and then press ENTER
ECHO.
SET /P toolnumber=
IF %toolnumber% == reset GOTO :reset
IF %toolnumber% == 25 GOTO :rand
IF %toolnumber% == 50 GOTO :rand
IF %toolnumber% == 75 GOTO :rand
IF %toolnumber% == 100 GOTO :rand
IF %toolnumber% == 125 GOTO :rand
IF %toolnumber% == 150 GOTO :rand
IF %toolnumber% == 175 GOTO :rand
IF %toolnumber% == 200 GOTO :rand
GOTO :play

:rand
SET /A myrand = %random%%%2%
if %myrand% == 1 GOTO :add
if %myrand% == 0 GOTO :sub
pause

:add
ECHO ADDED!
SET /A yournumber += %toolnumber%
GOTO :checknum

:sub
ECHO Subtracted!
SET /A yournumber -= %toolnumber%
GOTO :checknum

:checknum
CLS
IF %yournumber%== 5000 GOTO :win
IF %yournumber%== 5025 GOTO :win
IF %yournumber%== 5050 GOTO :win
IF %yournumber%== 5075 GOTO :win
IF %yournumber%== 5100 GOTO :win
IF %yournumber%== 5125 GOTO :win
IF %yournumber%== 5150 GOTO :win
IF %yournumber%== 5175 GOTO :win
IF %yournumber%== 5200 GOTO :win
IF %yournumber%== 5225 GOTO :win
IF %yournumber%== 5250 GOTO :win
IF %yournumber%== 5275 GOTO :win
IF %yournumber%== 5300 GOTO :win
IF %yournumber%== 50 GOTO :lose
IF %yournumber%== 25 GOTO :lose
IF %yournumber%== 0 GOTO :lose
IF %yournumber%== -25 GOTO :lose
IF %yournumber%== -50 GOTO :lose
IF %yournumber%== -75 GOTO :lose
IF %yournumber%== -100 GOTO :lose
IF %yournumber%== -125 GOTO :lose
IF %yournumber%== -150 GOTO :lose
IF %yournumber%== -200 GOTO :lose
IF %yournumber%== -225 GOTO :lose
IF %yournumber%== -250 GOTO :lose
IF %yournumber%== -275 GOTO :lose
IF %yournumber%== -300 GOTO :lose
GOTO :play

:win
CLS
ECHO YOU WIN!!!
GOTO :replay

:lose
CLS
ECHO YOU LOSE
GOTO :replay

:replay
ECHO Play again? yes/no then press ENTER
ECHO.
SET /P replay=
if %replay% == yes GOTO :reset
GOTO :EOF
__________________
Everyone's Favorite Turd xD
ET: "Phone home!"
Geek: "ping 127.0.0.1"

"If that guy knew half the $h*t that I know, his fuzzy little head would explode. " - Matthew Farrell
vampist is offline   Reply With Quote
Old 12-24-2009, 02:27 AM   #14
Baseband Member
 
MartinC.'s Avatar
 
Join Date: Nov 2009
Posts: 56
Smile Re: need help with a batch file

thank you
__________________
all your base are belong to us
MartinC. is offline   Reply With Quote
Old 12-24-2009, 07:19 AM   #15
Baseband Member
 
thevil1's Avatar
 
Join Date: Dec 2009
Posts: 36
Default Re: need help with a batch file

Thanks :P your the best.
__________________
An optimist is someone who falls off the Empire State Building, and after 50 floors says, ''So far so good!''
thevil1 is offline   Reply With Quote
Old 12-24-2009, 03:45 PM   #16
Site Team
 
root's Avatar
 
Join Date: Mar 2004
Posts: 7,999
Default Re: need help with a batch file

with batch file colour changing

0 = black
1 = Blue
2 = Green
3 = Aqua
4 = Red
5 = purple
6 = Yellow
7 = white
8 = grey
9 = light blue
A = light green
B = light Aqua
C = Light Red
D = Light purple
E = light yellow
F = Bright white



if you write color 2, the text changes to green, (with a black background)

if you write color 24, the the text changes to red on a green background.

(first number is background colour, last number is text colour), if you only put one number it changes the text colour and defaults the background to 0, black.
__________________
I didn’t fight my way to the top of the food chain to be a vegetarian…
Im sick of people saying 'dont waste paper'. If trees wanted to live, they'd all carry guns.
"The inherent vice of capitalism is the unequal sharing of blessings; The inherent vice of socialism is the equal sharing of miseries."
root is offline   Reply With Quote
Old 12-24-2009, 08:45 PM   #17
Daemon Poster
 
Join Date: Jul 2008
Posts: 810
Default Re: need help with a batch file

Python and Perl....
__________________
MSI K9N2GM-FIH motherboard AMD Phenom Agena 9600(2) Crucial Ballistix Tracer 1GB PC2 6400 Thermaltake 430W PSU
160GB Segate Barracuda HDD 19" Wide Screen Hanns-G
Raidmax Tornado ATX Case OS- Gentoo
Toshiba A135 -Vista Pentium Dual Core 1.6 ghz. 1.5gb ram
www.localtechnet.net - Support me, click the ads!!
Austinn is offline   Reply With Quote
Old 12-25-2009, 07:34 AM   #18
Site Team
 
berry120's Avatar
 
Join Date: Jul 2009
Location: England, UK
Posts: 3,425
Default Re: need help with a batch file

Quote:
Python and Perl....
What about them?

If you're saying they're much better, more flexible and modern alternatives to windows batch files these days then I completely agree. Perl especially (I'm not a huge fan of Python!)
berry120 is offline   Reply With Quote
Old 12-25-2009, 05:33 PM   #19
Baseband Member
 
MartinC.'s Avatar
 
Join Date: Nov 2009
Posts: 56
Default Re: need help with a batch file

what are python and perl?
__________________
all your base are belong to us
MartinC. is offline   Reply With Quote
Old 12-25-2009, 07:14 PM   #20
Site Team
 
berry120's Avatar
 
Join Date: Jul 2009
Location: England, UK
Posts: 3,425
Default Re: need help with a batch file

Other programming language. Python is a language that aims to accomodate lots of different styles of programming into one package (but in my opinion, ends up being a bit half hearted in all of them as a result.) Perl is a straight scripting language that's commonly used for knocking up small applications in the shortest amount of time. You can think of it as a bit like batch scripts - but far more extensive, modern, usable and worthwhile learning!

...If you go down the Perl route though, a word of caution - a lot of Perl programmers just treat Perl as one big hack. The philosophy behind it is usually "let's see how quickly we can write an application to do x", not "let's see how WELL we can write an application to do x". While that's fine if you know good concepts and can apply them already, I wouldn't recommend starting out that way - it'll do BAD BAD things to your coding in the future!
__________________

berry120 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 12:19 AM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0