Computer Science Canada Creating Mario-Like Game, Need Help |
Author: | FearSonic [ Sat Apr 10, 2004 9:57 am ] | ||
Post subject: | Creating Mario-Like Game, Need Help | ||
I'm creating a Mario-like platformer game, and I'm having trouble having gravity implemented. I'm moving things around using Input.KeyDown, and using whatdotcolour for collision detection, since I don't know any other way. I just have a few questions: 1) How do I put gravity in, if my code is somewhat like this:
2) Is there another way to implement collision detection using a more efficient way? I found that if I didn't use the elsif with the 'and' operator, that it would work on one side, but not on the other. 3) How do I implement sprites? I've looked at Dan's Sprite program, but it was WAYYY too confusing for me. Thanks in advance! It's for my Grade 10 Computer Science ISU! |
Author: | FearSonic [ Sat Apr 10, 2004 10:02 am ] | ||
Post subject: | |||
Also, I'm wondering if I can make the ball go in a diagonal direction, I tired using:
And it doesn't work, any suggestions? |
Author: | Tony [ Sat Apr 10, 2004 10:05 am ] |
Post subject: | |
gravity is acceleration. It is applied to unit's velocity variable. When unit is in the air, each time though the loop, gravity (usually negative) is applied to the velocity and velocity moves the unit in the direction. When you first jump, velocity is set to a positive value and unit begins to rise up, but as gravity reduces the value of the velocity, unit slows down and eventually stops (that is the highest point of the jump). At that point unit begins to fall down, picking up speed as gravity turns velocity variable into a negative value. As for sprites, it's ether Sprite module in v3.1 or DanSprite in v4.* Which are preaty much the same. DanSprite is not complicated. You don't have to understand the coding behind it, just use methods exported (same way as you don't have to understand how Draw.Box works) |
Author: | FearSonic [ Sat Apr 10, 2004 10:17 am ] |
Post subject: | |
Thanks Tony! Would you happen to have an equation for gravity that would work? The other equations I've seen were all conflicting, and I couldn't tell which to use! |
Author: | Tony [ Sat Apr 10, 2004 10:35 am ] | ||
Post subject: | |||
|
Author: | FearSonic [ Sat Apr 10, 2004 10:46 am ] | ||
Post subject: | |||
Thanks again Tony! I tried implementing it so that it did it everytime I pressed the Up arrow, but it doesn't work for some reason. Heres the code:
|
Author: | FearSonic [ Sat Apr 10, 2004 4:02 pm ] | ||
Post subject: | |||
I changed up your program a bit, so instead of just going up and going straight down, I made it kinda bounce going lower and lower. It isn't the correct physics, but hey it's a start.
My only problem now is implementing it into the game! |
Author: | the_short1 [ Sun Apr 11, 2004 1:08 am ] |
Post subject: | |
man... if i had known it was this simple... also now they i have finished physics in science... it makes more sense... hehehe nice code there tony..... im sure itll come in handy eventually.... so i saved to HD., |