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 / Total newbie wondering about controlling objects

Author
Message
Indie Rock 13
20
Years of Service
User Offline
Joined: 1st Sep 2004
Location:
Posted: 20th Oct 2004 20:50
I've been simply messing with getting objects to move when you use the arrow keys, but ran into a problem. When I attempt to get my cube to rotate while I hold the right key it rotates once when I first press the button but then stops. How come it only rotates in the direction I want it to once and then it stops no matter if I let off of the key and press it again or not?

Just wondering because I figured controlling things would be one of the first things I'd need to know to make a side scrolling game.

Thanks

Neeeeeeeewom!
Xander
21
Years of Service
User Offline
Joined: 3rd Mar 2003
Location: In college...yeah!
Posted: 21st Oct 2004 03:35
I would like to help you, but I need to see your code. Are you using a loop? This will make the program go through the commands infinitely. This is how programs usually work. Here is an example that will rotate a cube when the keys are pressed:



Xander Moser - Bolt Software - Firewall
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 21st Oct 2004 03:36
Are you doing something like


or


Chris64
20
Years of Service
User Offline
Joined: 16th Oct 2004
Location: San Diego
Posted: 21st Oct 2004 13:23
It sounds like you may need to be using the WRAPVALUE() command for your angle. If you exceed 360 it may not know how to handle it.

rotate object 1,0,0,wrapvalue(x#)
Indie Rock 13
20
Years of Service
User Offline
Joined: 1st Sep 2004
Location:
Posted: 21st Oct 2004 14:23 Edited at: 21st Oct 2004 14:39
Thank you, that works. Now my only problem is that I want it to rotate right and move right, but when it does this it also goes downward in a circle, where I just want it to stay on the x axis and spin while moving...

This is probably something menial that won't come into play in my game but I figure its best to understand problems as they arise in case it comes up in the future.



Neeeeeeeewom!
Chris64
20
Years of Service
User Offline
Joined: 16th Oct 2004
Location: San Diego
Posted: 21st Oct 2004 15:33
Use POSITION OBJECT instead of MOVE OBJECT. MOVE will base it's movement on it's current angle. Then you have to specify it's absolute x,y,z positions.
Indie Rock 13
20
Years of Service
User Offline
Joined: 1st Sep 2004
Location:
Posted: 21st Oct 2004 16:22
Awesome, I'm getting the hang of all of this now. I just wonder how I can make it slow down when u let up on the control rather than abruptly stopping. I'll fiddle a little and read on the forums, thanks for the help!

Neeeeeeeewom!
Xander
21
Years of Service
User Offline
Joined: 3rd Mar 2003
Location: In college...yeah!
Posted: 22nd Oct 2004 04:23
Do you know about the basic math of acceleration? This is how you program acceleration into your program:



Does that work okay?

Xander Moser - Bolt Software - Firewall
Indie Rock 13
20
Years of Service
User Offline
Joined: 1st Sep 2004
Location:
Posted: 22nd Oct 2004 18:22
Yeah, that works as well. To get the slowing down effect do I need to use some sort of gravity or is it more complex than that?

Neeeeeeeewom!
Xander
21
Years of Service
User Offline
Joined: 3rd Mar 2003
Location: In college...yeah!
Posted: 23rd Oct 2004 02:52
Oh yeah, oops, sorry. I forgot about the slowing down. This should work okay:



How's that?

Xander Moser - Bolt Software - Firewall
Indie Rock 13
20
Years of Service
User Offline
Joined: 1st Sep 2004
Location:
Posted: 23rd Oct 2004 05:06 Edited at: 23rd Oct 2004 05:15
Yeh, that works. Thanks again!

I don't mean to be a bother, but I figure it'd be best to ask here instead of starting a whole new post. I've been tryin to get sliding collision to work (cuz I haven't gotten the Nuclear Glory .dll yet) for quite some time, but I can't seem to get it to work. I know I need to check for the objects position, check for collision, and if there is collision than return the objects position.

If I got it to actually stop moving instead of bouncing back over and over it'd be great... any tips? I scrapped the code, which wasn't a good thing. I didn't even think about posting it on here to get help with it. Meh

Neeeeeeeewom!
Xander
21
Years of Service
User Offline
Joined: 3rd Mar 2003
Location: In college...yeah!
Posted: 23rd Oct 2004 15:50
Are you using DB Classic or Pro? I know that classic comes with some really easy to follow sliding collision examples. Take a look at those, if you can. Otherwise I can send one your way if Pro doesn't have one. Sliding collision isn't too difficult, it just has to be perfect to work.

Xander Moser - Bolt Software - Firewall
Indie Rock 13
20
Years of Service
User Offline
Joined: 1st Sep 2004
Location:
Posted: 24th Oct 2004 18:11 Edited at: 25th Oct 2004 01:00
Well, I found a collision example (I have DBPro btw), but it wasn't exactly easy to follow, or I didn't have the patience to wade through their code and short remarks. Do you know of any examples that sort of explain more in depth what the code is doing or anything such as that?

Also, I noticed in that code that causes the object to speed up with you use the arrow keys and slow down when they're released caused some strange behavior. It did work, but when you move the object to the right and then let up, the object very slowly slides to the left when it should be at rest. This doesn't happen when I move it left, it simply slows to a complete stop. Why would this be?

Thanks

Neeeeeeeewom!
Xander
21
Years of Service
User Offline
Joined: 3rd Mar 2003
Location: In college...yeah!
Posted: 25th Oct 2004 10:31 Edited at: 25th Oct 2004 10:32
It has that problem because floats aren't perfect in DB. I forgot to compensate for that...here is a fixed version:



For the collision thing, I can't really help you right now...DB Pro isn't working too well for me at the moment, I am using classic. Sorry I can't help, try looking at other threads, there are a lot of collision threads lying around.

Good Luck

Xander Moser - Bolt Software - Firewall
Indie Rock 13
20
Years of Service
User Offline
Joined: 1st Sep 2004
Location:
Posted: 28th Oct 2004 15:13 Edited at: 29th Oct 2004 05:32
That way didn't work since it was making speed# 0 if it ever went less than zero, and since speed#=-.004 when I pushed left it wasn't letting me move left anymore.

However I fixed all of the problems I was having like this:



But now, with my collision, when a collision is detected and I continue holding right the cube slowly sinks further and further into the cube its colliding with... I've heard that DBP doesn't have very good built in collision though. Is that the problem?

Thanks!

Neeeeeeeewom!

Login to post a reply

Server time is: 2024-11-27 13:08:38
Your offset time is: 2024-11-27 13:08:38