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 / broken jumping and gravity...

Author
Message
Richard Ehtson
9
Years of Service
User Offline
Joined: 19th Apr 2014
Location:
Posted: 19th Apr 2014 13:09
ok so im trying to make a game on dark basic but some how i cannot get my character box to jump no matter how hard i try, and i have tried increasing its y position using the inc command and also just straight up putting a higher value in, but none of this seems to be working, i also cant seem to get my gravity to work. Any help is much appreciated, thanks in advance.

LBFN
16
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 19th Apr 2014 17:43 Edited at: 19th Apr 2014 17:47
Hi,

I noticed several things that needed revision in your code. First off, object positions are recorded as float variables. Yours included integers, which are not as accurate as you will need. Also, you don't need to check for collision to establish a Y position of your object when using a matrix. You had not set a SYNC RATE for the game. By not doing this, the program will run as fast as possible on the host computer. It was literally zipping around so fast I could hardly see anything. Another thing worth noting, is that you only had the matrix setup for 11 tiles across and down. Perhaps you wanted it to look like that, but it made for huge hunks of real estate. I made it 50 X 50, which IMO looks better.

To help you out, I revised your code so that it shows you what I am talking about. Hopefully you can learn from it. I created my own image as I didn't have the one you are using. I randomly tiled it, but this is only to show you how you can do it.



Hope this is helpful.

EDIT: I forgot that I replaced the SET CAMERA TO FOLLOW with code that manually does that. Set Camera To Follow was causing the camera to go too high when at a peak and too low when in a valley. The code I put in works much better.

LB

So many games to code.....so little time.
Richard Ehtson
9
Years of Service
User Offline
Joined: 19th Apr 2014
Location:
Posted: 19th Apr 2014 22:55
Hey thanks a ton that explains the problems i was having and solves some other issues with my code as well thanks LBFN

Login to post a reply

Server time is: 2024-03-28 08:54:59
Your offset time is: 2024-03-28 08:54:59