Jump to content

  • Log In with Google      Sign In   
  • Create Account

Arhim's Journal



Showcase of character dialogue displaying

Posted by , 03 August 2013 - - - - - - · 608 views

Hello GameDev,

just a little something I made for displaying conversations in the game (and a perfect opportunity to try out screen recording). The following "conversation" was generated from this txt file:

[CHARACTERS]

n = 3
char1 = Neil
char2 = Andy
char3 = Olaf
texture1 = data/img/portraits/Neil.png
texture2 = data/img/portraits/Andy.png
texture3 = data/img/portraits/Olaf.png


[TEXT]

text1 = <c-Neil>Andy, do you copy?
text2 = <c-Andy>Yes Neil, what's up?
text3 = <c-Neil>We got reports of enemy forces moving in from the south.
text4 = Your job is to take them out.
text5 = <c-Andy>No problem!!!
text6 = <c-Olaf>What?!<t-1000> Orange army COs,<t-1000> this is gonna be fun.


The class loads up the file (using the config manager) and start parsing through the lines. The "<>" are used for specifying different commands. The <c-somename> is used for changing characters and <t-someint> is used for making dramatic pauses. The number of commands can be later extended if needed.

Additionally, when the mouse button is held down (or any keyboard key), the parser increases the scrolling speed and starts to skip over the 't' commands.

Cheers Posted Image





The map editor

Posted by , 31 July 2013 - - - - - - · 522 views

Hello GameDev,

today I was gonna write about the gameplay we were planning to have, but being on vacation with some/no internet connection I was unable to contact my friends about that matter. Instead I will showcase (kind of) the map editor with screenshots (yay for internet cafe). So here we go:

Posted Image

This is the map editor.Tthe top box is for inputting the name of the map (for saving and loading purposes). The two 20 boxes are the wanted dimensions. The set button clears the map with the currently selected type of terrain and commits the dimension change. Everything else is for choosing the terrain and switching between terrain and units.



Posted Image

This next screenshot shows the map editor in action (as much a picture can show). We will be probably changing the water texture, but for now it works to show the principle.



Posted Image

The last screenshot shows the map with units (or unit, the texture is from an asteroid game we did a few months back). When editing units you get an additional button X for deleting units.


This map editor should provide a nice and fast way for editing maps. Just a note: all the terrain and unit types are stored in files which we can easily edit to add more.

That's all for today, I won't make any predictions for the next entry because this seems to often backfire more than it's worth it.

Hope it was interesting :)


General project update #1

Posted by , 25 July 2013 - - - - - - · 492 views

Hello GameDev,

today I will just write out the progress made on our project.

1) We have been further improving our GUI so now we have sliders, a working text box, radio buttons (missing textures) and we started to work on scrollable lists. The way we have button callbacks implemented is not pretty so I will try to look into a better way of doing them.

2) Further progress was made on the Editor state so now we can actually make maps, save them to a file, load them from a file and move the camera around.

3) We are still trying to agree how to make the entity system. My friend and I each wrote a version of how we imagined it to work and we will try to make a final decision.

I would post a screenshot of the current editor, but I am limited with the current internet connection I have available. For future entries I will try to discuss some gameplay mechanics we will try to implement.

Happy coding till then :) (and later ofc)


The MapManager

Posted by , 19 July 2013 - - - - - - · 568 views

Hello GameDev

Arhim here with the third entry for this journal. Today I will be writing about the work done on MapManager.

The MapManager is a class that is responsible for loading, saving and drawing the Maps. As an addition we will make a MapTile class that will store tile data (like type, sprites, defence strength...).

Let's start off with the MapTile:
class MapTile
{
    public:

        MapTile();
        ~MapTile();

        void setType(std::string);

        std::string type;

        std::string preview; // will represent the tile in the editor
        std::vector<std::string> sprites;
};

This should be useful for now. Next we will define the MapManager:
 class MapManager
 {
     public:
         MapManager();
         ~MapManager();
 
        void loadMapFromFile(std::string FILE);
//        void writeMapToFile(std::string FILE);
        void setTextureForTiles();
 
        void update(double k);
        void draw();
 
     private:

        MapTile data[512][512];
        std::string texData[512][512];
 
        int n,m;
        int tileWidth, tileHeight;

 };

The setTextureForTiles function will, for each MapTile, read its type and assign a texture from the MapTiles sprite vector.
void MapManager::loadMapFromFile(std::string FILE)
{
    ConfigManager config;

    config.parseFile(FILE);

    tileWidth = config.getInt("SETTINGS","tileWidth");
    tileHeight = config.getInt("SETTINGS","tileHeight");
    n = config.getInt("SETTINGS","n");
    m = config.getInt("SETTINGS","m");

    for (int i=0; i<n; i++)
    {
        for (int j=0; j<m; j++)
        {
            data[i][j].setType(config.getString(toString(i) + "," + toString(j),"type"));
        }
    }

    setTextureForTiles();
}

void MapManager::draw()
{
    glMatrixMode(GL_MODELVIEW);

    glEnable(GL_TEXTURE_2D);

    for (int i=0; i<n; i++)
    {
        for (int j=0; j<m; j++)
        {
            glPushMatrix();
                glTranslated(i * tileWidth, j * tileHeight, 0.0);
                app->myAssetManager->useTexture(texData[i][j]);
                gl::drawTexQuad(0.0,0.0,tileWidth,tileHeight);
            glPopMatrix();
        }
    }

}

void MapManager::setTextureForTiles()
{
    for (int i=0; i<n; i++)
    {
        for (int j=0; j<m; j++)
        {
            if (data[i][j].type == "plains")
            {
                if (rand()%2==0) texData[i][j] = data[i][j].sprites[0];
            }
            if (data[i][j].type == "water")
            {
                texData[i][j] = data[i][j].sprites[0];
            }
        }
    }

    return;
}

After adding everything to the main loop, this is what we come up with:

Posted Image


I hope you had an interesting read Posted Image


The core of State management, the GUI and the Entity system

Posted by , 16 July 2013 - - - - - - · 679 views

Hello GameDev,

Arhim here with the second entry for this journal. Continuing from the last time I will write about other cores needed for the game.

The StateManager is a class that will be responsible for, as the name suggests, managing different states. We will first define a class IState which we will be extending and will provide us with a common interface for states. All states should have a way of updating, drawing and handling events. Also, to make things easier for state managing we will define two additional variables: family and ID. The family variable will store the common type of the state (GameState, MainMenuState...) and the ID will store the specific name of the object as strings.

Core of IState should look like this:
class IState
{
	public:
		IState(std::string mID = ""); // constructor will accept the unique ID
		~IState();

		virtual void update(double k); // the difference in time from the last update
		virtual void draw();

                virtual void handleEvents(const sf::Event &event); // we handle the needed SFML events

        protected:
                std::string family;
                std::string ID;

                bool isDrawing;   // needed for the StateManager
                bool isUpdating;

};
This class should provide us with the basic interface we will need for the states.

Coming back to the StateManager, we will store States as IState pointers in a vector and we will implement some basic functions for adding, removing and switching to states (here the variables isDrawing and isUpdating will help out).

The .h file:
class StateManager
{
	public:
		StateManager();
		~StateManager();

                void update(double k);
                void draw();
 
                void addState(IState* state);
                void removeState(std::string ID);

                void switchToState(std::string ID);

                void handleEvents(const sf::Event &event);

	private:

                std::vector<IState*> states;
};
For now only the switchToState function is needed which sets the updating and drawing flags to true. This should leave room for later making states draw over each other while only one state (or more) get updated.


Coming up with a nice way for doing the GUI was pretty tricky and we finally settled for the following approach: we will have a base class called Container that will implement all the low level needs for the different GUI parts. After that, every GUI part will implement its own specific functions.
class Container
{
    public:

        Container( std::string id = "", double x = 0, double y = 0, double width = 0, double height = 0 );
        virtual ~Container();

        virtual void draw();
        virtual void update( double dt );

        void handleEvents( const sf::Event& event );

        virtual bool mouseLeftDown();
        virtual bool mouseLeftUp();
        virtual void mouseMoved( int x, int y );
        virtual bool mouseWheelMoved( int delta );

        virtual bool keyPressed( unsigned int code );
        virtual bool keyReleased( unsigned int code );
        virtual bool textEntered( unsigned int code );

        void addChild( ContainerPt child );
        void setParent( ContainerPt parent );

        void setColor( const sf::Color& col );

        const bool isHovered() const;
        const bool isFocused() const;
        const bool isPressed() const;

        const std::string& getID() const;

        Vec2f getPosition() const; // absolute position

        // extend...
        virtual bool isClicked(){};
        virtual void setValue( std::string ){};
        virtual void setValue( int ){};
        virtual void setDrawing( bool );
        virtual void setSelected( bool selected ) {};
        virtual void addItem( std::string id, std::string value ) {};

        virtual std::string getStringValue() const {};
        virtual int getIntValue() const{};
        virtual bool isSelected() const{};

    protected:

        bool m_hovered;
        bool m_focused;
        bool m_pressed;

        bool m_drawing;

        double m_top;
        double m_left;
        double m_width;
        double m_height;

        ContainerPt m_parent;
        std::vector< ContainerPt > m_childs;
        std::string m_id;

        sf::Color m_color;
};
This should give us a nice foundation for making new GUI elements.

Before starting work on the Entity system we read the different resources which can be found on this wiki. I left programming of this system in the hands of my friend and he took the challenge to himself to make it work really fast (for the cost of some space which shouldn't matter because of the scope).

Anyway, the basics of this approach are the following: you have entities that have a set of components, and system which work only on entities that have the required components (you should read the papers, they are really interesting and I can hardly convey this properly). The way we currently have this implemented uses too much magic (to work fast ;) ) and we will have to clean it or rewrite it before using it in our game and posting it here.

For the end I will post a screenshot of what we have for now:

Posted Image

This is just the basic setup. The New Game, Options and Exit buttons are logical, but the Edit button will lead to the EditState where you will be able to edit maps of the terrain. The edit me box is there just for testing purposes.

I hope you had an interesting read. If you have any suggestions where I should go with this series or what I should change feel free to leave a comment. I am open to new ideas.


A beginning

Posted by , 14 July 2013 - - - - - - · 479 views

Hello GameDev,

Arhim here starting a new journal. First of all I will make some things clear:
  • I am a hobbyist programmer who works on projects for fun and learning purposes
  • English is not my first language so there will probably be grammatical errors
Having cleared that up I will, for my first post, talk about the current project I am working on with two of my friends. The basic goal for us is to make a clone of the Advance Wars game for the GBA which is an excuse for trying out an entity system for managing units. (We already made a clone of asteroids where we used hierarchy for game objects). On this project I will be mostly working on the supporting classes and system, one friend will work on the GUI and the other will be working on the entity system.

We are using SFML for the window and event handling and OpenGL for rendering in C++ with the help of CodeBlocks as the IDE. We will try to write as much of the engine and game ourselves. Because of that, this journal will be more about engine implementation than game play development. The game will be written for Windows and Linux simultaneously.

Starting of that I will write about some of the helper classes needed for the engine.
  • Config manager - mainly responsible for reading and editing config files, but will be used for loading levels, writing game states, etc.
  • Asset manager - responsible for handling loading of textures, sounds, texture maps, as well as unloading and keeping track of already loaded assets
1) The config manager accepts files of this format:
[section1]
    name1 = value
    name2 = other_value
[section2]
    name1 = value3
    name4 = some_other_value
[window]
    width = 800
    height = 600
    fullscreen = 1 // or on or true

The section name goes into brackets and everything following it up belongs to that section. The name-value pairs have to be unique for each individual section and they will be stored as strings. Because of that the ConfigManager should supply a way for reading values as other types like int and bool.

Example of use:
ConfigManager myCM;
int width;
int height;
bool fullscreen;

myCM.parseFile("config.cfg");

width = myCM.getInt("window","width");
height = myCM.getInt("window","height");

fullscreen = myCM.getBool("window","fullscreen");
Similarly to parsing config files, ConfigManager will also be able to write configs to files.
I had written a more complex version of the ConfigManager which could read in tree-like structured config files, but that was a complete overkill on my part for a test project. Following that experience this time I settled on making it much simpler.


2) The AssetManager is pretty straightforward. It implements functions for loading textures and binding them with OpenGL, for unloading textures and it keeps track of when assets need to be released.

Behind the scenes it uses SFMLs interface for loading image data from files, binds the data with OpenGL and then stores the index returned for later access in a map with string as keys (name of the file) and int as the texture index.

For fonts the AssetManager again uses SFMLs interface. For now we don't need to load any sounds or something else because we are working only on the bare core (but if the need shall present itself we will implement it).


Hope you had an interesting read Posted Image

For future entries I will be writing about managing states, a bit about the GUI and the Entity system and how we plan to implement it. I hope on getting some pictures in this because it looks dull.





August 2016 »

S M T W T F S
 123456
78910111213
14151617181920
21222324 25 2627
28293031   

Recent Comments



PARTNERS