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 / why doesn't this work?

Author
Message
New Creature Feature
20
Years of Service
User Offline
Joined: 27th May 2004
Location: Tennessee- USA
Posted: 1st Jul 2004 09:13
Okay- here's the idea. You got a character moving along the z plane (a z-scroller I suppose you'd call it). The character is flying.

You can move up down left and right. I took that part out of the code below cuz that's not what I'm focusing on now. Instead of just moving up and down, left and right, I want my character to slightly tilt in the direction you push (actually opposite I guess), so that it's a little more realistic than just being a flat object going in the 4 directions.

Only 2 of the directions work. Once I get this working (with your help), how would I make the tilt a smooth animation instead of a 2-frame move?

Thanks
Alan

Therefore if any man be in Christ, he is a new creature: old things are passed away; behold, all things are become new. II Corinthians 5:17
zenassem
22
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 1st Jul 2004 10:15
Her you go.



The reason why only to directions were working is because the else conditions for the other key presses were overwritng the change before the sync. If you need me too I'll explain it better.

It's better to reset the variables after the sync and before the loop command.


zenassem
22
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 1st Jul 2004 10:54 Edited at: 1st Jul 2004 11:33
I avoided posting the animation method, because my method might not be that great but here's one (probably poor) idea.

You need to have the tilt move in small increments to it' maximum tilt. But you only want it to move 1 increment per loop so, you could have a count of how many frames it needs to move as well as a logic to ignore other keys during that time.

Ok, so create a variable like animcycle.
animcycle=1 means that tilt frames still need to complete
animcycle=0 means that tilt frames complete process another key
move=0

Then add it to your code like this:

Sorry that it's messy and ugly brute force. I had to keep playing with it. It really needs to be streamlined better. And the if's cna be simplified, but I think it will give you the idea that I meant. If I looked at it longer i could clean it up a bit.



You may want to move it back to the original 0 position in increments as well, but i'll leave it up to you. Plus my code was off the cuff and a pretty ugly method.


thinkdigital
21
Years of Service
User Offline
Joined: 18th Oct 2003
Location:
Posted: 1st Jul 2004 11:12 Edited at: 2nd Jul 2004 02:57
There's one other thing, and it's that you're trying to rotate the cube -10 degrees on the event of the left arrow key. -10 isn't a degree, so DB will give you an error if you do it that way. Try this out:



the wrapvalue() returns the proper degree value for orz#, so DB will accept it.




2.3 Gigs. 1993 MHz. 256 MB Ram. Home Sweet Home.
zenassem
22
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 1st Jul 2004 11:27 Edited at: 1st Jul 2004 11:29
Think digital,
I can verify that the -10 works with patch 5.4 In DBpro
I'm not sure if it used to give problems or if it just doesn't work in DBC.


New Creature Feature
20
Years of Service
User Offline
Joined: 27th May 2004
Location: Tennessee- USA
Posted: 1st Jul 2004 12:28
Thank you both- thinkdigital, you're brilliant. I figured the negative degrees wouldn't work in DBC but I knew their must be a way around it. Sure enough, you found it. brilliant!

zenassem, I will have to try the other method soon in DB Pro. I just got it in the mail recently. I'm programming in Classic right now cuz to be honest, I like the instant 'run' factor you have when you hit F5. DB Pro takes a moment to compile the code and I make so many messups at this point that it would become way too frustrating having to wait so long after each attempt to get something right.

thanks again

Alan

Therefore if any man be in Christ, he is a new creature: old things are passed away; behold, all things are become new. II Corinthians 5:17

Login to post a reply

Server time is: 2025-05-24 13:44:28
Your offset time is: 2025-05-24 13:44:28