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 / weird jumping problem

Author
Message
Night Giant
21
Years of Service
User Offline
Joined: 26th Jul 2003
Location:
Posted: 15th Nov 2003 21:49
hey all,
ok, i am trying to make a platformer and for some reason the jumping is all screwed up, the model just goes up a bit (like 3 units) and back down really quick (like 1/2 second). it doesn't even go as high as it should. i have no idea what the problem is, here's the relevant code if anyone thinks they can help me, this is so damn frustrating, well thanks all.



and here's the y_normal function:


thanx all.
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 16th Nov 2003 05:07
In your for next loop, do you realise tha tyou are reseeding the value for xt# and yt# over and over...?

I think what you're trying to do is something like set the value for x1# up to x4# or whatever aren't you?

If so... you can't do it like that... you have to use an array...

Hope I Helped...


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
Night Giant
21
Years of Service
User Offline
Joined: 26th Jul 2003
Location:
Posted: 16th Nov 2003 05:17
well, the for next loop reseeds the xt# and yt# values like you said, but not to increment them. maybe i should've explained the tile# array, what that is an array to keep track of the x and y positions of each object in the level. what the for next loop does is assign the values for the current tile being checked (t) to the variables, and then check whether a normal force is produced by the current tile (t). and if there is an upward normal force (1) it breaks out of the loop, with the current values for the variables set in the loop for that object/tile. at least i hope that's what it does, heh. hopefully that'll help to understand my code and perhaps my problem. thanx Jess.
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 16th Nov 2003 12:24 Edited at: 16th Nov 2003 12:28
Quote: "it breaks out of the loop"


Hmmm, i think your coding is a bit dodgy then... lol... (I don't mean to be harsh, it was a joke...)

Where you have;

if ny#=1 then t=numberoftiles+1

I am assuming that is where you are meant to be brakeing from the loop?
If so ( i may be wrong in my assumption again here ), that will not work...

Ok... here is the lengthy explination that i wrote out, which is indeed completely wrong... lol:

#### Start incorrect explination ####

What the For...Next Loop does, is it takes the variable, gives a value equal to the starting value that you provide ( in your case, the variable is t and the value is 1 ).
It then goes through the code to the next Loop command ( in this case, Next ), using that variable the entire way through it...

Once it hits that Next Loop command, the "read head" ( the part of the code that is being executed ) returns to the last For command that was read.

When it get's to this command, it incriments the variable by a value of one, checks to see if it exceedes the limit value of your To command ( in your case the limit is equal to the value of numberoftiles ), and if it does, it skips the code untill after the Next command, and continues from there.
If it doesn't exceed the value of the limit you asigned then it does the loop again...

Where you have assigned the variable t = numberoftiles + 1 , the For...Next Command will ignore that when it comes time to incriment the value of t for the next loop, it will incriment t compared to the last value it was incrimented to at the start of the loop.

#### End incorrect explination ####

Ok, to hopefuly fix your problem.. change this:



To this:



Hope I Helped...


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
Night Giant
21
Years of Service
User Offline
Joined: 26th Jul 2003
Location:
Posted: 16th Nov 2003 23:09
ahh, fantastic. thank you, i haven't tried it yet, but it seems like it should help. i was looking for something like that in the help files, actually i was looking for a break command and when i couldn't find it i figured it would have to jimmy-rig something. thanks again. i shall tell you if it works.
Night Giant
21
Years of Service
User Offline
Joined: 26th Jul 2003
Location:
Posted: 17th Nov 2003 03:09
alas, no luck, it still has the same problem. this is very frustrating, i hope i don't have to go back and rework my entire way of constructing levels and testing for collisions.
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 17th Nov 2003 09:03
Having another look over your code, i can't realy see anythign wrong with it.

There is a small point, which shouldn't make any difference, but ill mentuion it anyway,
Where you have:


Try changing that to:




and in the other section, change:




To:



Then, at the start of your program, declare ny as a global, by putting this in:


Note:
You will notice that i have chenged the variable of ny# to ny. I did this for two reasons. 1) becasue the number is never going to need a decimal point, it is wiser to declare it as an integer rather than a Floating point, mainly because floating points take up more memory (only minutely though, but still worth it in the long run); and 2) When i personally set GLobals, it has a fit if i put in a # symbol, dunno what's up with that...

Second Note:
The global commandmay not work ( i am assuming you are useing DrakEDIT which has support for Globals, but doesn't always work )
To get by this (if it doesn't work) just change:




To:



And change the other instances of ny to ny(1)...



Hope I Helped...


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
Night Giant
21
Years of Service
User Offline
Joined: 26th Jul 2003
Location:
Posted: 18th Nov 2003 05:21
hm, well, the globals don't work, i am using DarkEdit, not DrakEdit (or maybe that was typo?). and changing


to


did not work, ny just stays zero because nothing is changing it in the function. well, i changed the function back to what it was, and changed the reals back to integers. still the same problem. arrghh! thanks for trying to help me, i really appreciate it.
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 18th Nov 2003 09:09 Edited at: 18th Nov 2003 09:10
Sorry, sorry, my fault, i made a couple-a mistakes... lol.

It was meant to be DarkEDIT, lol, damn typo's, i need a new keyboard, really...

and the function, i stuffed up...

This should be what you need to have (just cut and paste into the appropriate sections of your code):



Also, seen as your function cal is really long, why not do away with the function, and just put the code straight in?... Like:



That way, you know that there is not a problem with the function call, and the code is now only one line rather than 7 (including the function, and calling it)...

Hope I Helped...


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
Night Giant
21
Years of Service
User Offline
Joined: 26th Jul 2003
Location:
Posted: 19th Nov 2003 04:35
*laughs maniacally* it works! haha! i am very grateful Jess, i think it was getting rid of that function call that did it. Thank you, you will be in my credits for all the help. Hazzah! um, thanks again, heh.
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 19th Nov 2003 09:10
lol... You're a killer (funny)...

Glad to help NightGiant, i seriously must be in about ten people's credits by now... lol... i keep helping people... i should start charging for such quality services... lol...




Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy

Login to post a reply

Server time is: 2025-05-21 16:17:56
Your offset time is: 2025-05-21 16:17:56