Public Group

Free source code for a game?

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

Recommended Posts

What I mean by the title is does anyone know where I can get a free 2D Mega Man or Mario game clone/parody? My biggest problem in trying to move foward with my programming is trying to figure out how to get my characters to animate while they are moving.

I think that if I could just look at the code and see how someone else did it that I would be able to figure out how to do it myself (or maybe blantantly rip it off

Share on other sites
Ripping code off isn't going to help you learn. Maybe you should ask more specific questions about your problems and maybe someone here will be able to help understand a solution.

Share on other sites
do you know how to animate your character while they are not moving? If no, 2D animations can be real simple.

1: store a series of sprite in an array (std::vector or std::list are good choices), make sure you store them in order.

2: Then you have a frame variable that tells you what index in the array to use for drawing your sprites.

3: you just need another bool to tell you whether the character is being animated or not, if it is use the animation sprites if not use the normal ones.

std::vector<sprite> animSprites;DWORD currentFrame = 0;/* add the animation sprites to the vector *//* every time you update your app, update the animation so it changes frames */animDuration += frameTime;if (animDuration >= animSpeed){    animDuration -= animSpeed;    currentFrame++;    /* Make sure you frames haven't reached the end of your array */    if (currentFrame >= animSprites.size())        currentFrame = 0;}

You can use a state variable to tell what the character is doing, a simple enum would do the trick
enum CharState{    standing = 0,    walking,    jumping}

By checking the characters state you can tell wich animation you should be displaying. hopefully that helps.

Share on other sites
That should help. If I'm not mistaken, I should then map each particular animation to a direction button so that when they press it it loops through the animation.

Now another step I'm having trouble with is getting each of the pics for the animations inside the frame (if I'm saying that right). The issue is that all the pics don't divide up evenly like they did when I was learning this back in college. Some are longer than others and some are taller. Is there any way around painstakenly cropping every single one to the exact right size? Because I've got like 50 images or maybe more.

Share on other sites
Quote:
 Original post by The_GameThat should help. If I'm not mistaken, I should then map each particular animation to a direction button so that when they press it it loops through the animation.Now another step I'm having trouble with is getting each of the pics for the animations inside the frame (if I'm saying that right). The issue is that all the pics don't divide up evenly like they did when I was learning this back in college. Some are longer than others and some are taller. Is there any way around painstakenly cropping every single one to the exact right size? Because I've got like 50 images or maybe more.

I believe super street fighter II and the original mortal combat did it this way, and I'm come to adopt it. I don't think of the sprites position being the upper left corner, I make my position be the center of the sprite.

so say My sprite is at position 100x100, and it's size is 50x50, that would mean the upper left corner is at 75x75.

x1 = xposition - width / 2;

Then you just need to keep a list of the sizes and uv coordinates of your frames, try making a simple struct for this.

struct FRAME{    sprite* sprite;    float u1, u2, v1, v2;    float width, height;};

• 18
• 11
• 16
• 9
• 49
• Forum Statistics

• Total Topics
631395
• Total Posts
2999780
×