• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Nausea

Animated tiles, need some input

10 posts in this topic

Hey,

So I was thinking of how I would go about creating tiles which will be animated. I think I have a pretty good idea, but I just wanted to see what some more well versed people think about it.

My thought is to have a Tileframe class that will just have X/Y coordinate for where from the image the picture will be drawn. The tile class will then have a list (vector) of tileframes that animation will loop over. The map class will then have a list of tiles. The map will handle all the saving and loading of map information to and from a binary file.

Does this sound like a good approach?

For map editing will I have to have one of each available tile hardcoded into the game that a new placed tile will copy it´s information from (animation etc) ?

Would be great to have some input, and maybe some alternative ways. And if this would be bad for performance in any way or if it´s a bad idea to save so much for a pretty simple tile map.

Thanks Edited by Nausea
0

Share this post


Link to post
Share on other sites

One thing to bear in mind is that different animations have different delays between frames - you need some way to specify the delay per frame of different animations loaded in your game. Some animations even have different delays between each frame (this is less common, though, and can be ignored)

0

Share this post


Link to post
Share on other sites
One thing to bear in mind is that different animations have different delays between frames - you need some way to specify the delay per frame of different animations loaded in your game. Some animations even have different delays between each frame (this is less common, though, and can be ignored)

Ye this I know already, might not do different speed between the frames. However, I will maybe try to do it just for the learning experience.

0

Share this post


Link to post
Share on other sites
I was thinking something like having a way to tell the tile renderer to update a tile (assuming you dont resend all the data every frame), causing it to ask the tile class what it currently looks like (uvs/texture) given the context (position, world, data the tile instance contains)
0

Share this post


Link to post
Share on other sites
I was thinking something like having a way to tell the tile renderer to update a tile (assuming you dont resend all the data every frame), causing it to ask the tile class what it currently looks like (uvs/texture) given the context (position, world, data the tile instance contains)

Could you expand on what you are saying? Not very clear to a noob like me. :I

0

Share this post


Link to post
Share on other sites

Well, not much information given.
Your using c++ i see that, any library/engines ? that would greatly narrow our approach towards the problem.

 

Use one variable for position instead of two

Also Saving X and Y for each image instead of one variable like (int pos) and use it to get image from TileSheet?

EX:
[code]//Tile size 32x32
//Tilesheet size 128x128   class Tile
{
public:
    int pos = 6;
};

int TileSheetSize = Image_Tile_Sheet.getSize().x / TILE_SIZE; // This would provide size of tilesheet.x as tiles

draw(Tile_List[My_Tile_To_Draw_From_Vector].pos % Tile_Sheet_Size,
     Tile_List[My_Tile_To_Draw_From_Vector].pos / Tile_Sheet_Size)//x, y[/code]

Now if you wandering what did this do?

Let me try to explain.

 

Image was 128x128 we divided by 32 we get 4x4

[code]00 01 02 03 04 05 06 07 08 08 10 11 12 13 14 15[/code]

We grab the 06 witch would evaluate to 2 ints (x = 3 or x = 64, y = 2 or y = 32)

 

Tip for animated tiles

Also considering the animated tiles.
Point all tiles to one pointer / reference / sprite / texture that will hold the animation image, so in process of changing animated tile you just change one tile and all using this data instead of looping true all tiles, looking for specified ones and updating them all.

 

My thought on your approach

[quote]
My thought is to have a Tileframe class that will just have X/Y coordinate for where from the image the picture will be drawn. The tile class will then have a list (vector) of tileframes that animation will loop over. The map class will then have a list of tiles. The map will handle all the saving and loading of map information to and from a binary file.

Does this sound like a good approach?

[/quote]

Define good. Most efficient No, Able to work this way YES, Would i do it this way NO.

But have in mind that (Thinking of something on your own, creating on your own) will allow you to develop a sense of (oh this is good, oh this is bad)

 

When i was starting to program my cousin shown me how to output to console and told me to output 100 times same text onto console.

After i finished that he shown me 'for' loop (hes asshole), doing something hard way is not without it benefits, you will find creative ways of dealing with code even then, and learning to do stuff efficiently comes much on its own.

I mean who wants to write same code 10 times? make a function for it and use it 10 other places to save up to 10x in time - function creation time = profit.

 

Am pretty sure most of "Experienced" programers would be able to improve your idea / design, but experience gained from you doing it the way you thought off, priceless. Am most sure you will notice flaws and think of better ideas as you progress.

Good luck!

2

Share this post


Link to post
Share on other sites
Tip for animated tiles
Also considering the animated tiles.
Point all tiles to one pointer / reference / sprite / texture that will hold the animation image, so in process of changing animated tile you just change one tile and all using this data instead of looping true all tiles, looking for specified ones and updating them all.
How do you mean? I will be loading a big sprite sheet into a asset manager and all the tiles will use this surface. I won't load it for every tile, just once and then point to it. Could you expand on how you mean I will update all by changing one, if I understand you correctly? Won't I have to go through all tiles and update the animated ones on every frame?

Or I what i meant was that the map class will hold what tileset (spritesheet) to use and then all the tiles will use that one.

And I will use SDL btw. Edited by Nausea
0

Share this post


Link to post
Share on other sites

If you wont have performance issues it will be fine to do it the way you intent to.

Didn't do SDL in long time...

What i meant to do is

Declaration
SDL_Surface* water_Tile; // Surface that can load images and will be base that all tiles will point to
class TileBase{
public:
int type;
SDL_Surface** img;
};
Setup
if(Tile_Base.type_of_tile == enu_water_tile)
    Tile_Base.img = &water_Tile; // I know SDL uses allot of pointers, don't remember if this would be valid so you can access what water_Tile holds
//So you could do following when drawing tiles
SDL_BlitSurface( *Tile.img , NULL, Screen , Position);
The game loop
if(1 second passed)
{
water_Tile.update_Next_Frame(); //Here just grab next frame / image for water_Tile
}

water_Tile would be updated once and all tiles therefore would be updated.

NOTE::
This may not be the valid way to use in SDL, am unsure if doing SDL_Surface** and then using memory adress of another SDL_Surface* would provide you results your striving to achieve. Just trying to provide you with concept.

Edited by BaneTrapper
0

Share this post


Link to post
Share on other sites

I apologize if the code is in mess, but editing the post totally replaces each newline with space character :(

0

Share this post


Link to post
Share on other sites
I apologize if the code is in mess, but editing the post totally replaces each newline with space character sad.png

Ok, well thank you for your input anyway. Looks like I'm not totally lost on the subject after all. Well, guess I will have to test it out and see how it performs if I can manage to get it working.

 

Again, thank you :)

0

Share this post


Link to post
Share on other sites

OK so I've declared some classes, namely: CMap, CTile and CTileFrame.
If someone could just take a quick look at the declarations and tell me if this is a total clusterf*** or if I am on the right track.
 

class CMap {

    public:

                            CMap();

                            CMap(std::string _mapName, std::string _tileImageFile, TPUINT32 _numTilesX, TPUINT32 _numTilesY, TPUINT32 _numLayers);

                            ~CMap();


    public:

        TPBOOL TPE_CALL     m_saveMap(std::string _file);

        CMap* TPE_CALL      m_loadMap(std::string _file);

    public:

        void TPE_CALL       m_setMapName(std::string _mapName);

        std::string TPE_CALL m_getMapName();

    public:

        void TPE_CALL       m_setSizeX(TPUINT32 _sizeX);

        void TPE_CALL       m_setSizeY(TPUINT32 _sizeY);

        TPUINT32 TPE_CALL   m_getSizeX();

        TPUINT32 TPE_CALL   m_getSizeY();

    public:

        void TPE_CALL       m_setNumTilesX(TPUINT32 _tilesX);

        void TPE_CALL       m_setNumTilesY(TPUINT32 _tilesY);

        TPUINT32 TPE_CALL   m_getNumTilesX();

        TPUINT32 TPE_CALL   m_getNumTilesY();

        TPUINT32 TPE_CALL   m_getNumTiles();

    public:

        void TPE_CALL       m_setNumLayers(TPUINT32 _numLayers);

        TPUINT32 TPE_CALL   m_getNumLayers();

    public:

        void TPE_CALL       m_setCurrentLayer(TPUINT32 _layer);

        TPUINT32 TPE_CALL   m_getCurrentLayer();

    public:

        void TPE_CALL       m_addTile(TPUINT32 _posX, TPUINT32 _posY);

        void TPE_CALL       m_deleteTile(TPUINT32 _posX, TPUINT32 _posY);

    public:

        std::list    v_tileList;

    private:

        std::string         s_mapName;

        TPUINT32            ui_sizeX;

        TPUINT32            ui_sizeY;

        TPUINT32            ui_numTilesX;

        TPUINT32            ui_numTilesY;

        TPUINT32            ui_numLayers;

        TPUINT32            ui_currentLayer;

};
class CTile {

    public:

                            CTile();

                            ~CTile();

    public:

        void TPE_CALL       m_addTileFrame(TPUINT32 _imgPosX, TPUINT32 _imgPosY);

    public:

        std::string TPE_CALL m_getName();

    public:

        void TPE_CALL       m_setLayer(TPUINT32 _layer);

        TPUINT32 TPE_CALL   m_getLayer();

    public:

        void TPE_CALL       m_setPosX(TPUINT32 _posX);

        void TPE_CALL       m_setPosY(TPUINT32 _posY);

        TPUINT32 TPE_CALL   m_getPosX();

        TPUINT32 TPE_CALL   m_getPosY();

    public:

        TPUINT32 TPE_CALL   m_getType();

    public:

        TPUINT32 TPE_CALL   m_getNumFrames();

        TPUINT32 TPE_CALL   m_getCurrentFrame();

        TPUINT32 TPE_CALL   m_getFrameDelay();

        TPBOOL TPE_CALL     m_isAnimated();

    public:

        std::vector<CTileFrame> v_tileFrameList;


    private:

        std::string         s_tileName;

        TPUINT32            ui_layer;

        TPUINT32            ui_posX;

        TPUINT32            ui_posY;

        TPUINT32            ui_type;

        TPUINT32            ui_numTileFrames;

        TPUINT32            ui_currentFrame;

        TPUINT32            ui_frameDelay;

        TPBOOL              b_animated;

};
class CTileFrame {

    public:

                            CTileFrame();

                            CTileFrame(TPUINT32 _imgPosX, TPUINT32 _imgPosY);

                            ~CTileFrame();

    public:

        TPUINT32 TPE_CALL   m_getPosX();

        TPUINT32 TPE_CALL   m_getPosY();

    private:

        TPUINT32            ui_imgPosX;

        TPUINT32            ui_imgPosY;

};

 

 

The CMap class is still missing a image pointer for what tile sprite sheet to use.

The idea is to have the map store the tiles, the tiles will have a list of frames for animation.
I guess the map class will handle the animation of every frame in each tile.

Any input would be appreciated. Thanks

Edited by Nausea
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0