Jump to content

  • Log In with Google      Sign In   
  • Create Account

Herwin P

Member Since 09 Apr 2013
Offline Last Active Today, 07:53 AM

Posts I've Made

In Topic: Help with my game program architecture

09 February 2016 - 07:21 PM

Then, I'm not certain about handling game screens (game states) making games with SFML. I declared an enumeration type for representation each of the states, but it's pretty clear to me that it's not sufficient since in every game state there is a set of objects (for example a text of welcome on the initial game screen, some background etc) that are created on switching to a state and destroyed on switching off to another. I of course could re-instantiate those objects over and over again while the game cycles through processInput(), update() and draw() just by declaring those objects in the methods, but I think it's too sily and ugly way of handling things like this. Moreover, in this case I have to set the origin, position, etc of the objects. For example, if I want a text to be displayed on the screen once the player loses the game, I'd have to declare a text variable, set its font, character size, string, origin, position right in the draw() method, which again seems not a very good practice. In addtition, there are some variables that must be re-assigned when the player causes the game come out of one state and get into another.


You can make a base class for state and child classes of it for each specific state, and create and destroy its objects in its constructor and destructor. Then you can make a state handler class that contains those states, in a container of type pointer of the state base class, and handles the switching.


You can even define specific processInput(), update() and draw() methods for each state so they can have different behavior. For example, a menu state only draws play and exit buttons while the game state draws the board and handles the game commands. On the state handler class you can set these methods too, to command the active state to call its respective methods.


Also, if you need to share resources among states, like textures, fonts, etc, you can declare them in the state handler class and share them to the states.

In Topic: How to ease sprite creation for an RPG

04 December 2015 - 03:32 AM

I'm not sure what you are using for a game engine here, but I have seen a method in Unity where you draw the basic sprites and then animate them in the editor using bone/rigging techniques similar to 3D animation methods.  I'm not sure if this reduces the work load as I'm pretty new to game dev. in general, but this came to mind and I don't think anyone above mentioned it.


I'm not using an engine for this one actually. I'm using C++ and SFML for study purposes. I already made a simple top-down shooter with basic data-driven design, which we're using as the base for this RPG now. Though that shooter has a flat top-down view, so the sprites and animations are really simple.


We used Unity for our previous platformer, so we already have experience with that technique. We decided not to use for this RPG because we plan to have the character to be able to face 8-directions, and we thought using sprite sheets would be easier for that. Not sure if other people would think differently.

In Topic: C++ Classes, Hierarchy, Friends Chart

04 December 2015 - 03:11 AM

No you can't! That will cause slicing.


If you need polymorphism, you need to use pointers. So,

std::vector<Move*>, or preferably std::vector<std::unique_ptr<Move>>.


Oopsies. My bad. I wrote that example without thinking. mellow.png

In Topic: C++ Classes, Hierarchy, Friends Chart

03 December 2015 - 10:24 PM


I have 3 types of "objs" Player, Enemy, Items

Each contains a vector.


I want one loop to iterate a single vector. How can I relate all 3 in a way I can add to a single vector?

You can contain objects of those classes in a single vector of the base class of those classes, like std::vector<Move>.

In Topic: C++ Classes, Hierarchy, Friends Chart

03 December 2015 - 07:49 PM

Sorry. I don't quite understand the tree. Do all of the classes inherit from Map? And is there a class Type that inherits from Item? I think what you mean is that class Type has a script as an attribute, Item has a type as an attribute, and that a Map has a group of moving objects, again as an attribute.


The general idea of class inheritance is that classes that inherit from another class have similar functionalities and attributes with the class they inherit from. Class inheritance is an IS-A relationship, like an Enemy is a Character, and a Character is a MovingObject. An attribute is a HAS-A relationship, like an Item has a Type, and a Type has a Script.


Like Alberth suggested, I think you need to start with something simpler first. Make the map first, make sure it renders the tiles well. Then give a player that moves in it. You'll gain more understanding as you go, and you can develop it further once you get the hang of things.