Sign in to follow this  

a few small questions

This topic is 3857 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i've been working on re-making the original mario, i figure its basic enough for me to get a handle on, but challenging enough to really push me. i have mario animated, including jumping and i have the BG scrolling till the end, but now i've hit a road block and i'm wondering if i could be pointed in the right direction. 1. how would i make mario fall in the holes? would i use collision detection? (ie. if mario's x is between the x's of the hole, and his y=< the ground level, he can continue going down) 2. how would I make it possible for him to climb on blocks? i'm assuming the same way? 3. how do i approach his fireballs? i've tried creating a fireball class, and planning a path for the fireball once it's fired, but since i have to have the methods in place, do i have to have an instance of the fireball right away? thanks, i'm trying to spitball these things as much as a i can, trying to figure it out myself rather than get help but i've been stuck on this for a few days

Share this post


Link to post
Share on other sites
I've cloned the first level of SMB myself for a personal project. Its been awhile, so I don't remember specifics, but I'm certain that I just had a simple gravity model.

Basically, at each frame, you can test the two points directly below Mario's feet (the very outer points) for what tile it contains. If one or both contain a "walkable" tile, such as brinks, metal boxes, pipes, etc you just run as normal. If both points contain a non-walkable tile, such as a pit, or "background" features such as the sky, bushes, clouds, etc then you apply whatever gravity model you choose.

Fireballs can basically be implimented the same way, except when they hit the ground they will bounce without loosing any momentum. The gravity model can give them their parabolic bounce with the right parameters. They die when they go off-screen.

You can also go with the bounding-box/bounding-circle approach.

Share this post


Link to post
Share on other sites
http://mypage.mtaloy.edu/~jjnst1/sidescroller/sidescroller.html

I wrote this in JS for a simple tutorial and because I was bored last week, the way the collision detection and things are done are solid and should be able to give you some assistance. For the falling through and jumping on blocks.


Snipped Due to Obtuse Size


Good Luck.

Share this post


Link to post
Share on other sites
oh ok, i thought it was tiling, but since tiling still baffles me, i just used a BG image with the ground included.



and i took a look at the source, i'm gonna save and really study it,


thanks guys

Share this post


Link to post
Share on other sites
Ah, if Tiling baffles you then my code might not be the best to learn from, since it's javascript.

This is a good tutorial to teach you the basics, it's written in VisualBasic but it's pretty easily portable to whatever.

http://gpwiki.org/index.php/RPG_Map

Share this post


Link to post
Share on other sites
Quote:
Original post by ravyne2001
I've cloned the first level of SMB myself for a personal project. Its been awhile, so I don't remember specifics, but I'm certain that I just had a simple gravity model.

Basically, at each frame, you can test the two points directly below Mario's feet (the very outer points) for what tile it contains. If one or both contain a "walkable" tile, such as brinks, metal boxes, pipes, etc you just run as normal. If both points contain a non-walkable tile, such as a pit, or "background" features such as the sky, bushes, clouds, etc then you apply whatever gravity model you choose.

Fireballs can basically be implimented the same way, except when they hit the ground they will bounce without loosing any momentum. The gravity model can give them their parabolic bounce with the right parameters. They die when they go off-screen.

You can also go with the bounding-box/bounding-circle approach.




umm, would it be too much to ask you to give me a very brief idea of a gravity model? psuedo code would be fine

Share this post


Link to post
Share on other sites
The absolute most basic way to do it would be:

Up Arrow Key Hit
{
player.jumping = true;
player.y = player.y - player.height; //make us jump about our height
}

//This would be in your main code so it would be executed each frame
handleJumping()
{
if(player.jumping == true)
{
//If we're higher than the floor
if(player.y + gravityConstant < floorHeight)
player.y += gravityConstant;
else
player.jumping = false; //If not then we've must have hit the floor
}else{
return; //Exit the Function
}
}


That's really basic but it works well.

Share this post


Link to post
Share on other sites
oh ok, for my jumping function, i have 2 flags, "jump" and "down",

down = false
jump = false

if jump = false
jump = true



if jump = true
y += 10

if y>= maxjumpheight
down = true

if jump && down
y -= 10


if y<= floory
y = floory
jump = false
down = false

thats the jist of it


i know there's probobly a million better ways to do it, but i'm a beginner
just trying to work through it himself.

Share this post


Link to post
Share on other sites
Yeah, that should work. There's a million ways to do anything really, and your method if you understand it and it works for you it's fine. You can always re-write it later if you want.

I didn't know how much of a grasp you had on the jumping/gravity so I didn't include smooth jumping like you did in my example. However, you've nearly got it aced.

Share this post


Link to post
Share on other sites
oh ok, thanks alot, i've been spending between 4 - 8 hours a day on average for the last.... 2 months or so(and thats from having no experience with programming) so although its slowly coming around, i still don't have a solid grasp on everything, i'm just trying to make small strides

Share this post


Link to post
Share on other sites
4-8 hours, that's great. No wonder you're progressing so quickly. You've got excellent potential with that kind of determination.

Yeah, small strides is the way to do it. When I wrote my first 3D DirectX Engine a year and a half ago, I bit off more than I could chew, but I learned a lot and now I'm re-writing it and it's a lot better.

Anyway, yeah with that kind of time and effort you'll be an solid game programmer in no time.

Good Luck!

Share this post


Link to post
Share on other sites
Sign in to follow this