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 Professional Discussion / DBPro showing weird error when I try to declare a type

Author
Message
YoshiDoshi
14
Years of Service
User Offline
Joined: 11th May 2012
Location:
Posted: 11th Jul 2012 21:26
Well I was working on a Lunar Lander game and for some reason I can't even declare a type lol... I think my code is fine but sometimes dbpro gives random errors and I usually just restart it but that didn't work in this case.

Code:

The ship is uploaded and the background is just a black image atm.

If anyone could figure out why it wont let me declare a type then that would be nice :3

Cheese
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 11th Jul 2012 21:35 Edited at: 11th Jul 2012 21:36
Two As?................y AS AS INTEGER

Maybe it caused your program to stutter!

YoshiDoshi
14
Years of Service
User Offline
Joined: 11th May 2012
Location:
Posted: 12th Jul 2012 03:07
Lol wow epic fail on my part :/
Now that I got it to compile I see some really weird problems with the ship itself :S I can't seem to get the movement to work because it goes off the screen as soon as I press a button. I know that the first time writing the code with the gravity wouldn't go smooth but I just don't know how to make it realistic and simulate the moon and spacecraft.

Cheese
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 12th Jul 2012 03:54
Timer based movement...

Dark Source has a sample code which would help... Along with anyspeedmachine...

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 12th Jul 2012 14:13
Quote: " I can't seem to get the movement to work because it goes off the screen as soon as I press a button. "


Probably because you are moving it too far each sync. You've set the sync rate to 60 so the main loop is executed about 60 times a second. The other thing to remember is that when you press a key the PC will perform the checks each loop so your variables get updated each loop till you release the key which could be several times through the loop.

The simplest solution is to make smaller adjustments to the angle and thrust. Before doing that though, just try changing the sync rate to 15. That will slow things down a bit and you will then see how your program is working, albeit more slowly, and it'll be easier for you to decide which things need to be adjusted. Once you've got the main movement fixed you can then run the game at full speed using sync rate 60.

If you want the angle and position to update only once when you press a key you'll need to add some variables and logic to detect when a key has been released. You'll then need to press a key multiple times if you want the angles, etc to be updated several times. In this case you might prefer your present method though (I probably would) in which case you'll need to do what I suggested above.

You might like to think about this line:



Is that really what you intended? Why is the angle in there?

Have a look at this code where I've made a few changes to your sample code. For example, I've put the ship in the middle of the screen initially to make it easier to see what's happening. You will obviously need to change a few things but I hope this will get you started.

Login to post a reply

Server time is: 2026-07-08 01:56:33
Your offset time is: 2026-07-08 01:56:33