|
Post by Wayne Rayner on Sept 14, 2009 5:56:50 GMT -5
Ok I have just started to continue on with my racing manager game and I have found out a problem. I want to know whether I can permanantly keep a line that tells the player the amount of money the team has on every screen that there is. I don't feel like writing the lines of code that takes so much time i only want to have it written once and nether again.
Also how would you make a button and How would you make a exit button
Thanks Wayne Rayner
|
|
|
Post by shadow008 on Sept 14, 2009 11:16:50 GMT -5
i dont have the slightest clue what ur trying to say but i think what you might want to use is a function or sub? If your trying to have certain lines of code to be executed whenever you please then use one of them. if im way off im sorry cause your post seems hard to understand.
|
|
|
Post by Wayne Rayner on Sept 14, 2009 18:39:44 GMT -5
ok I need to know say I make 5 screens for a game. One is the team HQ the other 4 are for buying parts, signing drivers, signing sponsers and race day. Can I make buttons that would go from one screen to the other.
Wayne Rayner
|
|
|
Post by shadow008 on Sept 14, 2009 19:35:20 GMT -5
well yeah. use a function or sub and call it when needed (assuming you know how they work) and make maybe a 2d sprite to make a button and add mouse collision i guess. and reset the screen to the desired output in the function/sub. thats my best guess to your problem. i take it you want 5 seperate screens not 5 screens in one cause i dont know how you do that and your probly gonna have to know how to read and write files
|
|
|
Post by Wayne Rayner on Sept 14, 2009 20:20:02 GMT -5
Well I don't know how to make subs and functions
|
|
|
Post by Nicky Peter Hollyoake on Sept 14, 2009 20:44:05 GMT -5
Heres a small example. const MENU = 1 const SHOP = 2 const OPTION = 3
dim SCREEN = MENU
TextMode (TEXT_BUFFERED) while TRUE
CLS
if ScanKeyDown (VK_F1) then SCREEN = MENU endif if ScanKeyDown (VK_F2) then SCREEN = SHOP endif if ScanKeyDown (VK_F3) then SCREEN = OPTION endif if (SCREEN = MENU) then Printr"MENU" endif if (SCREEN = SHOP) then Printr"SHOP" endif if (SCREEN = OPTION) then Printr"OPTION" endif Printr Printr Printr"F1 = MENU" Printr"F2 = SHOP" Printr"F3 = OPTION"
DrawText() wend (no subs/functions) - Nicky
|
|
|
Post by Wayne Rayner on Sept 15, 2009 5:55:06 GMT -5
Thanks nicky for helping me again - You, darkjester, djlinux andmatthew seem to be always helping me.
Also that helps me for my game as I will need a lot of keypresses.
Thanks Will post for more help in a couple of day
Wayne Rayner
|
|
|
Post by shadow008 on Sept 15, 2009 11:31:43 GMT -5
const MENU = 1 const SHOP = 2 const OPTION = 3
sub menu() 'put desired menu output here endsub
sub shop() 'put desired shop output here endsub
sub options() 'put desired options output here endsub
dim SCREEN = MENU
TextMode (TEXT_BUFFERED) while TRUE
CLS
if ScanKeyDown (VK_F1) then SCREEN = MENU endif menu() ' <-- this calls the menu sub endif
if ScanKeyDown (VK_F2) then SCREEN = SHOP endif shop() ' <-- this calls the menu sub endif
if ScanKeyDown (VK_F3) then SCREEN = OPTION endif option() ' <-- this calls the option sub endif if (SCREEN = MENU) then Printr"MENU" endif if (SCREEN = SHOP) then Printr"SHOP" endif if (SCREEN = OPTION) then Printr"OPTION" endif Printr Printr Printr"F1 = MENU" Printr"F2 = SHOP" Printr"F3 = OPTION"
DrawText() wend
basically subs are used to call code you dont wanna write many times over. just call the name of the sub. functions are similar, but i just use them for math instead of calling code
eg.
dim x,y
function addnumbers(y,z) '<-- it may look like it, but your not re-diming variables dim x 'and i dont know how that works x = y+z return x '<-- it returns the value of x endfunction
do cls input "enter x value ";x input "enter y value ";y print " the sum is: ";addnumbers(x,y) '<-- here you call the variables used, in this case x and y sleep(500) loop
: / i guess thats the best i can explain it in a short time
|
|
|
Post by twasik4 on Sept 23, 2009 15:16:53 GMT -5
now cole.. give him a working version..
|
|
|
Post by Wayne Rayner on Sept 24, 2009 22:59:40 GMT -5
oh don't worry I have postponed this for a while. I'm gonna try a little pokemon clone if I can lol. will have features I wud like that not in pokemon.
I will also have different things, but i will try and make a demo of it.
Wayne Rayner
|
|