stuff
This commit is contained in:
		@@ -1,6 +1,26 @@
 | 
			
		||||
#include <SDL.h>
 | 
			
		||||
#include <map>
 | 
			
		||||
#include <string>
 | 
			
		||||
#include <vector>
 | 
			
		||||
 | 
			
		||||
enum CBUTTONS
 | 
			
		||||
{
 | 
			
		||||
    DPAD_UP = SDL_CONTROLLER_BUTTON_DPAD_UP,
 | 
			
		||||
    DPAD_DOWN = SDL_CONTROLLER_BUTTON_DPAD_DOWN,
 | 
			
		||||
    DPAD_LEFT = SDL_CONTROLLER_BUTTON_DPAD_LEFT,
 | 
			
		||||
    DPAD_RIGHT = SDL_CONTROLLER_BUTTON_DPAD_RIGHT,
 | 
			
		||||
    A = SDL_CONTROLLER_BUTTON_A,
 | 
			
		||||
    B = SDL_CONTROLLER_BUTTON_B,
 | 
			
		||||
    X = SDL_CONTROLLER_BUTTON_X,
 | 
			
		||||
    Y = SDL_CONTROLLER_BUTTON_Y,
 | 
			
		||||
    BACK = SDL_CONTROLLER_BUTTON_BACK,
 | 
			
		||||
    GUIDE = SDL_CONTROLLER_BUTTON_GUIDE,
 | 
			
		||||
    START = SDL_CONTROLLER_BUTTON_START,
 | 
			
		||||
    LEFTSTICK = SDL_CONTROLLER_BUTTON_LEFTSTICK,
 | 
			
		||||
    RIGHTSTICK = SDL_CONTROLLER_BUTTON_RIGHTSTICK,
 | 
			
		||||
    LEFTSHOULDER = SDL_CONTROLLER_BUTTON_LEFTSHOULDER,
 | 
			
		||||
    RIGHTSHOULDER = SDL_CONTROLLER_BUTTON_RIGHTSHOULDER
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct Controller
 | 
			
		||||
{
 | 
			
		||||
@@ -36,4 +56,6 @@ class Input
 | 
			
		||||
    
 | 
			
		||||
    Input();
 | 
			
		||||
    void update();
 | 
			
		||||
    bool keysPressed(std::vector<SDL_Keycode> keys);
 | 
			
		||||
    bool controllerPressed(std::vector<Uint8> buttons, int controller = 0);
 | 
			
		||||
};
 | 
			
		||||
@@ -32,19 +32,20 @@ class Animation
 | 
			
		||||
    private:
 | 
			
		||||
    std::vector<std::string> frames;
 | 
			
		||||
    Sprite* sprite;
 | 
			
		||||
    int currentFrame = 0;
 | 
			
		||||
    int frameDuration = 0;
 | 
			
		||||
    int frameCounter = 0;
 | 
			
		||||
    std::string currentFrameName;
 | 
			
		||||
    int frameIndex = 0;
 | 
			
		||||
    int frameDirection = 1;
 | 
			
		||||
 | 
			
		||||
    public:
 | 
			
		||||
    bool end = false;
 | 
			
		||||
    int frameDirection = 1;
 | 
			
		||||
    int frameIndex = 0;
 | 
			
		||||
    bool loop = true;
 | 
			
		||||
    bool pingpong = false;
 | 
			
		||||
    Animation(std::map<std::string, SDL_Rect> frames, Sprite* sprite, int frameDuration);
 | 
			
		||||
    void update();
 | 
			
		||||
    void draw(SDL_Renderer* renderer, bool autoRect = true, bool flip = false);
 | 
			
		||||
    void reset();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
class AnimationManager
 | 
			
		||||
@@ -54,12 +55,14 @@ class AnimationManager
 | 
			
		||||
    std::map<std::string, bool> flip;
 | 
			
		||||
    std::map<std::string, bool> autoRect;
 | 
			
		||||
    std::string currentAnimation;
 | 
			
		||||
    bool playing = false;
 | 
			
		||||
    Sprite* sprite;
 | 
			
		||||
 | 
			
		||||
    public:
 | 
			
		||||
    AnimationManager(Sprite* sprite);
 | 
			
		||||
    void addAnimation(std::string name, std::map<std::string, SDL_Rect> animation, int frameDuration = 10, bool flip = false, bool autoRect = true, bool loop = true, bool pingpong = false);
 | 
			
		||||
    void setAnimation(std::string name);
 | 
			
		||||
    void playAnimation(std::string name);
 | 
			
		||||
    void update();
 | 
			
		||||
    void draw(SDL_Renderer* renderer);
 | 
			
		||||
};
 | 
			
		||||
		Reference in New Issue
	
	Block a user