How To Make A Game #17 : Multiple Animations & Render Flipping : in C++ And SDL2 Tutorial


How to deal with multiple animations within a single game object. In this example walking left and right and idle using RenderCopyEx to deal with flipping textures. Learn how to make your own game from scratch!

Download the player_anims png to use in this video here:

Other wise if you would rather follow along/or create your own asset in pyxel edit watch a tutorial here :

If you wish to keep up with new episodes don’t forget to subscribe!

To catch up on the how to make a game series you can view the entire playlist here:

To download the up to date version of this code visit my github here:


Xem thêm bài viết khác:


  1. I'm getting an exception in the TextureManager.cpp,

    void TextureManager::Draw(SDL_Texture* tex, SDL_Rect src,SDL_Rect dest)


    SDL_RenderCopy(Game::renderer, tex, &src, &dest);

    Exception thrown at 0x6C78EC5A (SDL2.dll) in BirchEngine.exe: 0xC0000005: Access violation reading location 0xCDCDCDCD.

    Most of the stack just says about trouble reading the dll files. It all worked fine until I tried to use multiple png for different animations. Could anyone help please?

  2. I'm getting an error in Game.cpp telling me that (my line 59) map = new Map(); variable is ambiguous. I'm not sure why this has happened and I honestly don't know how to fix this at this point yet. It is the underhand "map" that is underlined in red and has the error. I think it started happening after modifying SpriteComponent.h but I'm not 100% certain.

  3. 11:52 , I was waiting a sentence like " He's not facing in the direction he's walking.." or something like that …
    And whe I " He moonwalks " so naturaly said it semmed so hilarious ! Thank you for this great moment !

    But don't be scared ! All of your tutorial are good moments !

  4. like from Hong kong!
    Nice video:) ,very useful to me!!!
    but there are few problems,
    should I rotate the image to make it look like walking on the different directions or make the new image sequence for different directions?
    also, would you like to make a menu tutorial?
    sorry for my poor grammar 😛

  5. Great tutorial man! Could you give me a hand, I am trying to create a parallax effect, I mean, I want the background to scroll forever, and over time increase the speed, could I create one using the Sprite Component ? What would you recommend? Thanks about the great work you have done so far! =]

  6. Hi again. Firstly, nice vid dude!
    I have a rather general question regarding the use of the entity component system. As I have said (at least I think I did), I am writing my own game engine using SFML and I am encoperating a good chunk of your logic as well (mainly ESC and collisions so far). My code is slightly more complex since I am trying to make my api as generix as possible (so lots of templates and inheritance there). Now the actual 'problem': Whats the best way to remove entities once they have been added and how do get them from a different module. Further, if i remove an entity, whats the best way to make sure I won't be using invalid references. Lastly, how should I manage collections of references to entities e.g. all buildings or GUIObjects? (appart from just std::reference_wrapper). I think you get the point…

    Thanks in advance!

    Adrian 🙂

  7. Nice video! These tutorials are the best I've seen so far!

    also when do you plan on completing the collision? (stopping the player from walking through it)

  8. I must say I've enjoyed this series thus far. I hadn't touched C++ in many years — I always fell back into C — and over the past several years my work has been with PHP and JavaScript. I wanted to get back into C++ and try out SDL2 as well. This series has hit that sweet spot for me.

    I take it you'll move the creation of named animations out of the SpriteComponent constructor in the future so that different entities can have different named animations?

    Also are you planning on incorporating SAT collision detection? It's not something that people usually think of when building a platformer, but it allows for a much more interesting map than relying on AABB.

  9. Awesome! Just so you know…this is my favorite series on all of youtube that I watch. When I see that you make a new video, I get excited, and you never let me down! Thank you for your videos!

  10. Really awesome video! solved a lot of problems, been waiting all week for this. Big thumbs up to you mate, looking forward for the camera one 🙂


Please enter your comment!
Please enter your name here