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 / Gravity...

Author
Message
Bizar Guy
19
Years of Service
User Offline
Joined: 20th Apr 2005
Location: Bostonland
Posted: 8th Feb 2006 23:20
Hi, I've been trying to convert a few of my games from dbc into dbpro. So far everything has gone smootly, exept my gravity code from dbc doesn't work in dbpro.

Could some people please post how to do basic 3D gravity in dbpro?

here's the code I used in dbc... maybe someone can figure out why it isn't working.
posx#=object position x(1)
posy#=object position y(1)
posz#=object position z(1)
playergrav#=playergrav#-0.26
posy#=posy#+playergrav#
position object 1,posx#,posy#,posz#

PLEASE help; I'd relly like to get back to programing these games...

UFO
19
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 8th Feb 2006 23:33
What happens when that code is run with the other code in your game? Nothing at all?


Hippopotomonstrosesquippedaliophobia-Fear of long words
Bizar Guy
19
Years of Service
User Offline
Joined: 20th Apr 2005
Location: Bostonland
Posted: 9th Feb 2006 00:00
Yes. For some reason the code has no effect at all.

These two lines of code are the only two that are spesific to gravity though...
playergrav#=playergrav#-0.26
posy#=posy#+playergrav#

UFO
19
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 9th Feb 2006 00:31
Hm...the only thing I can guess is that the playergrav# variable might be the wrong numbers or that it is used in a function and it relies on getting a value outside of the function that will be used inside the function. Otherwose, I don't know because I don't have DBP


Hippopotomonstrosesquippedaliophobia-Fear of long words
Peter H
20
Years of Service
User Offline
Joined: 20th Feb 2004
Location: Witness Protection Program
Posted: 9th Feb 2006 18:19 Edited at: 9th Feb 2006 18:19
Quote: "playergrav#=playergrav#-0.26"

so the rate that you move down is constantly accelerating???

that seems a bit odd... it seems like you would do something more like
posy#=posy#-0.26


but i don't see any reason why that code wouldn't work in DBPro if it worked in DBC... unless it's in a function like UFO said....

"We make the worst games in the universe..."
FROGGIE!
21
Years of Service
User Offline
Joined: 4th Oct 2003
Location: in front of my computer
Posted: 9th Feb 2006 19:14 Edited at: 9th Feb 2006 19:15
Quote: "that seems a bit odd... it seems like you would do something more like
posy#=posy#-0.26"


I think that constantly accelerating is fine.

Again i cant see any reason why its not working, but try printing some of the variables to the screen to see exactly which parts arent working:



Another thing i would reccomend is declaring variables at the start of the program rather than putting a '#' symbol in:




While we're on the subject - How would it be fixed if it is in a function?
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 16th Feb 2006 05:43
i have had trouble with things like this. is it possible that your ground is too thin? Sometimes, you will fall so fast that you will jump past your ground object without colliding with it. Also, do you have it so that playergrav# is set to 0 when the object hits the ground or another object? That could also be your problem
Image All
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: Home
Posted: 16th Feb 2006 08:24
Quote: "so the rate that you move down is constantly accelerating???"


Ever jump off a cliff or on a trampoline? Yes, the rate of descent increases I guess it's becuase of the earths pull, it pulls you down a bit, and then you have a downward velocity. Add that to the earths pull again, and you have a greater velocity. loop.

FunkyStickmen: Battle of the Races (1%)
Bizar Guy
19
Years of Service
User Offline
Joined: 20th Apr 2005
Location: Bostonland
Posted: 20th Feb 2006 07:54
Quote: "i have had trouble with things like this. is it possible that your ground is too thin? Sometimes, you will fall so fast that you will jump past your ground object without colliding with it. Also, do you have it so that playergrav# is set to 0 when the object hits the ground or another object? That could also be your problem "

um... I haven't had problems like those in two years, and yes whenever the player has a y collision, the gravity=0. Just so you know, this has worked perfectly until imported from dbc into dbpro.

Quote: "so the rate that you move down is constantly accelerating???"

just like real gravity.

And FROGGIE!, thanks. I'll be sure to do that.

Joh
20
Years of Service
User Offline
Joined: 5th Jul 2004
Location: Malaysia
Posted: 20th Feb 2006 21:27
On the point of acceleration and collision. Like newbie said
Quote: "Sometimes, you will fall so fast that you will jump past your ground object without colliding with it."

I read this somewhere on th e forums. It was about weapon projectiles. Its about your syncrate/fps, object speed.

At slower speeds, the object position is updated more, thus collision is more likely to happen.
---------|----
But at certain speeds the update maybe to slow.
- - - | - -
So the object is completely missed.

Something to consider.

!
Bizar Guy
19
Years of Service
User Offline
Joined: 20th Apr 2005
Location: Bostonland
Posted: 21st Feb 2006 15:58
Yes, and as I've said that's not my problem (I KIND OF THINK THAT AFTER TWO YEARS OF PROGRAMING I MIGHT KNOW ABOUT THE PROBLEMS WITH ACCELERATION, HMM?). Look, I figured out that you can fall through objects if you move too fast a long time ago. I'm not a newb, ok? I've just been having trouble converting some of my games into dbpro, because not all the commands from dbc work in dbpro exactly the same way (yes I'm aware of which commands don't work in dbpro, and no I don't use those commands).

Please, if you're not going to bother even reading the entire short first post, I don't see how you think can help me.

I'm very sorry to have to post that, but I'm tired, and I can't believe I've got people telling me that my problem is with my collision, which if you think about what I've posted, works just as well as it did in dbc.

I'll try the helpful suggestions I was given once I get back to converting some of my games.

The Nerd
20
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Denmark
Posted: 21st Feb 2006 19:02
Hmmm... That code should work in dbpro... I didn't read through all the other postes in this thread, but could I may get a code of a small game where you use the gravity code, and where it works in dbc?

-The Nerd

Free Particle Engine for DarkBasic Pro:
http://forum.thegamecreators.com/?m=forum_view&t=60141&b=5
Joh
20
Years of Service
User Offline
Joined: 5th Jul 2004
Location: Malaysia
Posted: 21st Feb 2006 21:32
I apologise. I misunderstood what you meant by the code doesn't work. I tried it and the object falls, but I couldn't get it to stop properly( but I'm a newb coder). So I assumed your trouble was with collision. My fault.
Again sorry to cause you any aggravation. I'll go away now.

!
Bizar Guy
19
Years of Service
User Offline
Joined: 20th Apr 2005
Location: Bostonland
Posted: 21st Feb 2006 22:19
@The Nerd, sure. I'll post a small jumping program source as soon as I have the time, with some of the other suggestions I've been given.

@Joh, that's alright, I was just very tired and I get annoyed when people post suggestions without making sure they actualy know what the problem is (happens quite a lot, actualy).

Joh
20
Years of Service
User Offline
Joined: 5th Jul 2004
Location: Malaysia
Posted: 22nd Feb 2006 06:38
Okay, I havent gone away yet . Is this close to what you're asking?


!
Bizar Guy
19
Years of Service
User Offline
Joined: 20th Apr 2005
Location: Bostonland
Posted: 23rd Feb 2006 19:42
heh, not quite.

I'll post a small bit of jumping code before the day ends (hopefuly).

Login to post a reply

Server time is: 2024-11-27 03:29:44
Your offset time is: 2024-11-27 03:29:44