Jump to content
  • Advertisement
Sign in to follow this  
antoder

Help with RPG game

This topic is 4059 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

Hi, Im pretty new to game programing in general and would like to break out a few things i wanna know more about. :D First, whats the best way to make an "animated" walk with an character in a game (2d)? My goal is to make an simple rpg game, and i want to make an nice animation when you walk, Ive seen it before done with 4-5 pictures of the char backwards / leg up backwards / leg down middle forward leg up forward leg down I got no idea how to do it in an nice way tho, any ideas? My second problem is how to structure up the "map" I'm not going to add any 3d stuff just plane simple 2d, but you should be able to move up / down to.. So my first idea was to build an checked map, so i could add events to each square on the map. This i have no idea to do either, i came up with a few examples but they didn't quite work so good in the end. Thanks! :) [Edited by - antoder on November 1, 2007 2:57:06 PM]

Share this post


Link to post
Share on other sites
Advertisement
If you're using 2d then I think you should look into a sprite engine. Basically you would have an image that contained a frame for each position that you described. In your case 5 frames. For example the frame 'backwards/leg up' could be at (100,20) width=15, height=20 inside the image. Every cycle of the game loop you would change what frame was displayed.

I'm assuming you will be using tiles for your maps. Maps in their simplist form are just 2d arrays


struct TILE
{
int type;
int walkable;
...
}

struct MAP
{
TILE map[100][100]; // a 100 by 100 tile map
}


Share this post


Link to post
Share on other sites
What exactly do you find puzzling about creating animations? Drawing them? Displaying them? Or something else?

The first aspect is purely artistic - it will take some artistic talent and lots of practice to create good-looking sprites. You can learn some from tutorials, but the real work still needs to be done by yourself - unless you can find an artist willing to help you out, of course. ;)

firstelder_d provided some information on the second aspect: a common approach includes creating so-called sprite-sheets, large images containing all animation frames of a certain character, and then drawing only a part of that image every time - for every different frame, you draw a different part of the image (usually, each frame is equally large, which simplifies the process somewhat). Creating seperate images for the different frames works too, but it's generally more of a hassle and has some more drawbacks than the sprite-sheet approach.


As for triggers and maps, there are many ways to handle this, and they highly depend on what you want and need. So... what do you want? :)

Share this post


Link to post
Share on other sites
Thanks for the replies!

"What exactly do you find puzzling about creating animations? Drawing them? Displaying them? Or something else?

The first aspect is purely artistic - it will take some artistic talent and lots of practice to create good-looking sprites. You can learn some from tutorials, but the real work still needs to be done by yourself - unless you can find an artist willing to help you out, of course. ;)

firstelder_d provided some information on the second aspect: a common approach includes creating so-called sprite-sheets, large images containing all animation frames of a certain character, and then drawing only a part of that image every time - for every different frame, you draw a different part of the image (usually, each frame is equally large, which simplifies the process somewhat). Creating seperate images for the different frames works too, but it's generally more of a hassle and has some more drawbacks than the sprite-sheet approach.


As for triggers and maps, there are many ways to handle this, and they highly depend on what you want and need. So... what do you want? :)"

Well i just want to do a simple map which you can walk , up / down / left / right
strictly 2d, but i also want to be able to make my own maps easy so i can put them in, i guess tiles are the only option here, beside that, should i code my own sprite engine, or is it a good one out there, I'm currently coding in C#.

Share this post


Link to post
Share on other sites
I'm currently doing a 2D platformer using XNA (C# with .Net libraries) for fun. Got some cool features and saves alot of time. One downside is it is DirectX 9 so if people want to play your game they need a compatable video card. On the upside you can use DX9 functionality and shaders with ease.

heres a couple links:

http://msdn2.microsoft.com/en-us/xna/default.aspx

http://www.ziggyware.com/articles.php?cat_id=6

http://www.riemers.net/

Share this post


Link to post
Share on other sites
Quote:
Original post by antoder
First, whats the best way to make an "animated" walk with an character in a game (2d)?

I got no idea how to do it in an nice way tho, any ideas?

My second problem is how to structure up the "map" I'm not going to add any 3d stuff just plane simple 2d, but you should be able to move up / down to..
So my first idea was to build an checked map, so i could add events to each square on the map.
This i have no idea to do either, i came up with a few examples but they didn't quite work so good in the end.
Thanks! :)


When I make a 2D tile game, or anything that uses animated sprites, I usually write several classes that become the core of the game engine. These core classes I use are Tile, TileManager, Animation, AnimationManager, and Map.

The Tile class represents a single tile, or single frame in an animation. It usually holds information like filename of the image, xoffset/yoffset (If the file is a tile map), width, and height. Sometimes it'll hold the actual image data... Anyways, the idea is I'll have a tile object for each frame in a sprite, each map tile, etc...

The TileManager class is what I use to organize all the tile objects. Bascially, it's an associative array or hashtable that's implemented as a singleton. It will store a unique String/TileName for each tile object it holds (TileManager.addTile("manWalkUp1", mwut1); TileManager.addTile("manWalkUp2", mwut2); and so on...) If my tile objects don't hold the actual image data, then this class is responsible for loading the images.

The Animation class is basically an array that holds the named tile sequences for an animation. For example, it might hold something like ["manWalkUp1", "manWalkUp2"]. Sometimes it'll hold timing sequences for the particular animation.

The AnimationManager class is basically the same thing as the TileManager class, but it deals with animation objects.

This way, you can grab an animation from the AnimationManager, get the tile name in the animation sequence, and get the tile data from the TileManager object. This can get kinda tedious, so I usually wrap that functionality up in a SpriteManager class. It would keep a list of active units in the game, and would have functionality similar to SpriteManager.getNextTileFromUnit("theBadGuy"); That would automate the process of looking up the information in the AnimationManager and TileManager classes.


For the map, I usually implement it as a 3D array which makes use of the TileManager. The first two dimensions are coordinates into your map, and the 3rd is the map data for that particular room/tile/area. When I instantiate the map, I pass in an array which a map into the TileManager. For example, I might pass it something like ["grass", "sand", "water"]. A 0 index in that array would be the name for a tile I have stored in the TileManager. The actual 3D array which is used for the map would hold a 0 somewhere in the tile data to represent that the tile is a grass tile.

Anyways, I hope this gives you some ideas as what you can do. If you have any questions, don't be afraid to ask.

Share this post


Link to post
Share on other sites
There really is a lot of good information on the theory of creating 2D maps on this site an on the net in general. They generally come in only 2 flavors, square tiles and isometric tiles. So yes, tiles really are just about the only option here. If you want to be able to make varied levels you will probably find an editor an invaluable and productive use of your time.

Since you are using C# I'm going to second the XNA thing and say spritebatch your heart out. If you were C++ then maybe SDL or something of that nature.

The formating of a map firstelder_d nailed it. For a simple map it is nothing more than a 2D array.

As a small tweak I would say define a "Tile" as 2 unsigned bytes over ints.

First a byte for what "Type" of tile or more specifically what Image that tile is using. You will have 256 unique tile values which is a heck of a lot for most people and will save you a little RAM over an int.

Second byte would be a what you can do on the tile. For example maybe the tile isn't walkable, or maybe its ice and the player slips. Or it could be sticky and slow you down. 256 possible events, which should about cover it.

Your map would just be your basic
TileObject[,] WorldMap = new TileObject[height, width];

The animation part is a little more tricky because there are many ways to skin that cat. Mostly though all 2D animation is, is one image after another. You can blit parts of a larger image(sprite sheet) or load 100's of little images(not recommended). You could even load one big image then have the game hack it up into many little images. Whatever you do you must show one image after another. Everything else is just about managing your resources.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!