Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / DBP-I need some help with a game creation program I'm making.

Author
Message
Getix Interactive
18
Years of Service
User Offline
Joined: 4th Nov 2005
Location: US
Posted: 4th Jul 2006 06:23
Do
if button(20,55,"New Game")=1 then goto New_game
if button(20,95,"Load Game")=1 then goto Load_game
if button(20,135,"Delete Existing Game") then goto Delete_game
if button(20,175,"Exit")=1 then end
loop

function button(x1,y1,menu_words$)
Pressed=0
x2=Text Width(menu_words$)
y2=Text Height(menu_words$)
if mousex()>x1 and mousex()<x1+x2
if mousey()>y1-y2 and mousey()<y1+y2
Pressed=1
endif
endif
if pressed=1 then ink rgb(255,0,0),0 else ink rgb(255,255,255),0
if pressed=1
Pressed=Mouseclick()
else
pressed = 0
endif
text x1,y1,menu_words$
endfunction pressed


New_game:

cls
ink rgb(255,255,255),0
print "What is the file name?"
input "Name of your game.",newgame$
print "Saving ";newgame$;" please wait."
open to write 1, newgame$
write string 1, newgame$
close file 1
open to read 1, newgame$
read string 1, newgame1$
close file 1
print newgame1$;" saved."
wait key

Load_game:
wait key
Delete_game:


How do I save a .ini file to a certain directory? I want my program to show all names of the games saved just like the Main Menu and when clicked, it will delete it. Any help would be greatly appreciated.
-Jim

Getix Interactive and Nanovision. Good Combo.
www.getixinteractive.com
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 4th Jul 2006 13:38
You need to rewind a bit first

GOTOs make for hard-to-follow code, and unfortunately you hit some of the issues already.

1. You can't add more mainline code after a function.
2. After your intended code, it will continue to run the next block. So after New_game, it will continue to Load_game and then Delete_Game.


Have a look at some code snippets that will help you with losing the GOTOs, and using GOSUBs or FUNCTIONs instead. You'll also find information on inin files and menu systems if you search the forums and the codebase on the site.



HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 4th Jul 2006 14:32
You might like to look at this it your code changed to work with functions like the buttons and a while loop that run till get a button pressed.

You may want to use this or carry on the way you are.
Its up to you but have a look.



I'm not getting you down am I, Ho Look! another fancy Door?

Login to post a reply

Server time is: 2024-09-25 03:41:01
Your offset time is: 2024-09-25 03:41:01