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.

DarkBASIC Discussion / Need help with menu

Author
Message
christoph
16
Years of Service
User Offline
Joined: 20th Mar 2009
Location:
Posted: 20th Mar 2009 19:56
I am creating a game that is similar to cuberunner on the ipod touch. I have mostly everything working except for the menu. I have a menu where you can select a level based keyboard input. When the person hits a cone they go back to the menu. The problem is that they should be able to go back to the level they did but I get an error when I delete all the objects when returning to the menu. You can view it for yourself using the code below. How can I make the level reset?

Quirkyjim
16
Years of Service
User Offline
Joined: 18th Oct 2008
Location: At my computer
Posted: 20th Mar 2009 21:57
Found it! (I think)

You're deleting the objects in a loop, so what's happening is:

Do
Do Stuff
Delete Objects
...
Do stuff (again)
Del... where'd they go??? ERROR

You delete the objects the first time, but when it loops, it tried to delete the objects again, but they aren't there.

Also, what specific error is it giving you?

~QJ
That's what they WANT you to think...
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 20th Mar 2009 22:08 Edited at: 20th Mar 2009 22:08
besides u got WAAAAAYYYYYY bigger problems than a menu, havent u ever heard of a for-next loop!?!?!?!?!?!!?!?!?!?!?

why type:



all the way t0 500 wen u can type



and be done?

same with these:



or:

BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 22nd Mar 2009 12:18
I agree with smart guy. putting in some for-next loops would clean up your code VERY quickly, though I do admire your commitment to write the same line of code 500 times

Once you put in those loops, it will become easier to track errors, but I think quirkyjim brought up a good point.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
christoph
16
Years of Service
User Offline
Joined: 20th Mar 2009
Location:
Posted: 22nd Mar 2009 16:18
Quirkyjim thanks a bunch I think that will work. I'll test it on Monday in comp sci class and repost on here.
That1smart guy, this was my first project with dark basic so I didn't know if the for next loop would work for the collision code and deleting.
And as for writing out all those lines of code, bn2 productions, I wrote a simple java program to do it for me.
Thanks for your quick replies I'll let you know how it goes.
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 22nd Mar 2009 23:12
oh sneaky! writing a program to write your programs! hahahaa

New Site! Check it out \/
christoph
16
Years of Service
User Offline
Joined: 20th Mar 2009
Location:
Posted: 24th Mar 2009 14:09
Here's my updated code with the for next loops in it.


That decreased my lines of code from thousands to about 150. Thanks for that. And yes, that java program was very sneaky. I didn't feel like wasting time on changing numbers.

I understand what Quirkyjim said about the loop executing the delete object code twice, but I am no longer getting any error. The program flashes the main menu screen for a second when you die and then it closes without any error. How can I fix this?
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 25th Mar 2009 02:44
was this pro, cuz i cant run it in DBC, gives an error at line 83
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 25th Mar 2009 02:59
if it is he's only using dbc commands what error are you getting?

New Site! Check it out \/
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 25th Mar 2009 03:15
he has a few commands called move object left, which work in pro but not in DBC

neway not sure wat ur problem was, worked fine for me xcept that the second time you played, it didnt work bcuz u never deleted the plains, so wen it tried to make them it gave an error saying they already exist.

I fixed this problem and cut a few lines form ur code, its now 130 lines, i used an array saving the x and zs for the plains (also caleb if u need to see one way to use the data command i used it to quickly load the arrays full) this allowed me to cut all those make/position/rotate plain commands down to one for-next loop

heres the new code, cool game

Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 25th Mar 2009 03:18
oh forgot about those move object left commands

New Site! Check it out \/
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 25th Mar 2009 11:36 Edited at: 25th Mar 2009 11:42
Have fun (note haven't tried, but I see no reason why it wouldn't work)





[edit]
Dang, at first I was hoping it could work with spaces instead of _'s but DBC thinks it is the move object command and doesn't recognize it

[edit 2]
Smartguy's edited code with my functions thrown in, this is now compilable in dbc.

Anyone else getting exceptionally low fps values (I even tried setting sync rate to 0)?



Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
christoph
16
Years of Service
User Offline
Joined: 20th Mar 2009
Location:
Posted: 25th Mar 2009 15:12 Edited at: 25th Mar 2009 18:32
Are you guys testing the program in Dark Basic or Dark Basic Pro? Because I did a really dumb mistake of posting this in the regular Dark Basic forum instead of the Dark Basic Pro. Thanks for all the help, the code has helped me greatly, but I'm still having the same error. As I run the program (in Dark Basic Pro) it crashes as soon as the menu tries to load when I collide with a cone or the timer runs out. I have tried the code on three computers in school, and the same thing happens on all three.


Edit: Nevermind this post, it all works now!!! Thanks a bunch, it's coming together well now.
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 25th Mar 2009 16:19
o, i thought about doing something similar to that, but never thought to use a function, nice job bn2
christoph
16
Years of Service
User Offline
Joined: 20th Mar 2009
Location:
Posted: 4th Apr 2009 23:39
Attached is the finished product! It is a .zip file with code and .exe files inside with all graphics and music needed to play our game. Thanks for helping us you guys. This was our first time ever working with Dark Basic.

Attachments

Login to view attachments

Login to post a reply

Server time is: 2025-05-16 12:13:56
Your offset time is: 2025-05-16 12:13:56