Very basic 2D RPG game

Started by
5 comments, last by alnite 9 years, 2 months ago

Hi everyone,

I'm an absolute begginner to game programming and a new member of gamedev.

I was trying to start creating a very basic 2D RPG game (pokemon style) for learning purposes but I'm stuck at modeling stage, i.e. dont know where to start. I looked everywhere on google and couldn't come across a consistent tutorial to guide me through this first step.

What I'm aiming for now is a small 2*2 map with houses that can be visited, animated character (obvious) and maybe some one reply characters to talk to.

I was wondering if someone would have some tutorials to point or could give some advice for the modeling stage.

BTW I'am an IT engineering freshman, I know C/SDL some C++ and some Ruby.

Thank you and have a great day.

Advertisement

Google for (those requires nearly no coding skill needed):

- RPGMaker

- GameMaker

- Construct2

If you want to code the whole game, I would suggest that you start here:

http://inventwithpython.com/

Very well written step by step tutorial using pygame. As for graphics, if you don't want to release your game (personal game or just show to a few friends) you can get the ripped sprites from google (just google for pokemon sprites). If you want to release your game, then you will have to find some free sprites, opengameart is a good place to start.

Currently working on a scene editor for ORX (http://orx-project.org), using kivy (http://kivy.org).

FYI, even a simple 2D RPG is quite an ambitious project and not very suitable for a beginner IMO. I was in the same position as you ten years ago and went ahead anyway. I suggest making an extremely basic game first and build up from there. Start small and work your way up instead of trying to add everything you need all at once. For example, your milestones could be something like this.

  • A single map that you can walk around in.
  • Add NPCs that randomly walk around the map
  • Add dialogue to the NPCs
  • Add random enemy encounters (with a very simple battle system where all you can do is select "Attack")
  • Add a basic character management menu
  • Add a second map

And so on. I'll second KnolanCross that if you just want to make a RPG, use one of those tools he listed above. You may think that coding a simple 2D RPG isn't that difficult, but it is. My project is currently hovering around 250K lines of code that were written (and re-written) over many years. If you want to make an RPG from scratch, be prepared for the enormous amount of time and effort it will take.

Hero of Allacrost - A free, open-source 2D RPG in development.
Latest release June, 2015 - GameDev annoucement

Thanks all for your answers, but I'm not looking te create a game with RPGMaker or any engine.

I'm just willing to practice programming and had the idea of creating a very simple RPG just to master OOP principles I'm learning with C++ and as an example for practicing UML modelling.

What I'm really looking for is help with basic classes modeling. What I had in mind is to start with a Map class containing an array of Scenes each with the objects corresponding to that scene (houses, objects...) , the same for houses...

But thinking that way, I go quickly crazy...

I'd love it if someone could give me a model example or indicate a tutorial to guide me through...

Well typically 2D RPG maps are built using layers. A layer may contain either tiles or objects (sprites). Typically you don't want to have something like a house be an object, because such a large, static structure is better constructed using tiles (since you can change up the size and display of the house more easily that way). I'll give you a simplified explanation of the class modeling in my own RPG.

We have a class called MapMode which is the highest level class and implements the main loading, update and draw code. This class got really big in the past because there's so many different things it needs to do, so we decided to create some helper classes to it that are responsible for handling specific operations on the map. Two of these classes are called TileSupervisor, which manages everything having to do with tiles and tile layers, and the ObjectSupervisor, which manages all of the sprites and the map's collision grid. Naturally, our tile layers are managed by TileSupervisor while the object layers are managed by ObjectSupervisor. We can have any number of tile/object layers and their draw order can be arranged and re-arranged in any way we like, but for simplicity let's assume we'll always have 3 tile layers and 1 object layer.

Our map is built using several layers of tiles, where each layer is like a 2D array. The same tile image may be drawn in more than one location, so it's inefficient to store several copies of the images. The TileSupervisor class maintains a vector of tile images, and our layers are nothing more than integers that index into that vector to extract the desired image to draw. Now we could either create a 2D array for every tile, or we could create a single 2D array and store the layer information for all tiles in there. We went with the latter approach. The MapTile class is a very simple wrapper around a 1D vector. This vector contains the indexes into the tile images container for each tile layer. So if we wanted to draw a tile that was located at the X, Y position on the map for a layer Z, we would access the 2D array of MapTile objects, index the X, Y element of this array, extract the Zth element from the MapTile object, and use this integer to index into the tile images container to extract the image to draw.

Now let's talk about objects. We define a MapObject as an entity with an x, y position on the map that has a height and length property, indicating how large the object is. We also have other properties we can set for objects such as whether or not to draw the object if it is on the screen (visibility toggle). We have a base class called MapObject which is abstract and contains these common properties, as well as pure virtual functions for drawing and updating the object. We have a number of classes derive from MapObject to support different types of objects on a map.

  • PhysicalObject is a static object that does not move. A tree could be a physical object, for instance.
  • TreasureObject is derived from PhysicalObject and can be interacted with by the player to extract treasure contents.
  • VirtualSprite is a sprite (moving object) with no image. This serves both as a base class for other sprites, and can also be used as a map camera (our camera is always focused on a map object).
  • MapSprite implements NPCs and player-controlled sprites. They can have dialogs, be given movement commands, etc.
  • EnemySprite is derived from MapSprite and causes a battle to occur when it collides with the player controlled sprite.

The ObjectSupervisor maintains a vector of MapObjects for each object layer. When it's time to update the map, the code will go through and call the update function on every object to update their animations, change their position, perform collision detection, etc. To improve performance, we keep the objects in this container sorted based on their draw order (you want to draw objects on the screen from top to bottom). So when we call the draw function, we already have a draw-order sorted container of objects and can simply iterate through the container and draw each object that should be visible on the screen.

------------------------

Hope that starts to get the gears moving in your head about how you can go about implementing tiles and objects and layers on a map. The map code for an RPG is probably the most complex piece of the game and it will take time and practice before things start to make sense. I didn't even get into other map aspects like dialogues, events, pathfinding, and so on. My project is reasonably well documented (certainly more so than most) and the code is open source, so you are welcome to study it and learn if you like.

http://www.allacrost.org/wiki/index.php/Map_Mode

Documents the design and structure of our map code. Somewhat incomplete, but covers the most important aspects.

https://sourceforge.net/p/allacrost/code/HEAD/tree/trunk/game/

Source code - main directory

https://sourceforge.net/p/allacrost/code/HEAD/tree/trunk/game/src/modes/map/

Source code - map directory

You can also download it and run Doxygen on the source tree. This tool will build the API documentation and can also do things like construct class hierarchy diagrams to give you a better understanding of each piece of the code and how they all tie together. Again though, this is pretty complex and is definitely above the scope of what you're aiming to do with your project. Hope you find this information helpful.

Hero of Allacrost - A free, open-source 2D RPG in development.
Latest release June, 2015 - GameDev annoucement

Thank you Roots, that was a really instructive answer.

I'm going to study your code and try to get the gist of it. I'll get back to you if I need further help.

I hope to get more answers like this.

Thanks again.

A basic 2D RPG like what you mentioned has these things:

1. Animation

2. Map/tiling/scrolling

3. Input to move the characters

4. Moving from one map to another (visiting a house takes you to another map of the inside of the house)

5. Understand the concept of layers. You need to render the tiles, houses, trees, characters, character bubbles, how they overlap, which gets drawn first, etc.

I suggest you tackle this one at a time. First, learn how animation works. Given a sprite sheet, how do you animate the characters.

Then learn about tiling maps, scrolling maps, and how do you position objects in the map and make sure they stay at where they are supposed to be when you scroll.

So you just build up your skill there.

This topic is closed to new replies.

Advertisement