Contact me to be added to this repository. Push the creations you make for D&D, and they will be displayed in a nice website. See the website for how to contribute.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
714 B

  1. #pragma once
  2. #include <string>
  3. #include "Texture.h"
  4. extern const int S_W; //screen dimensions
  5. extern const int S_H;
  6. extern int L_W; //level dimensions
  7. extern int L_H;
  8. extern const int TILE_SIZE;
  9. class Character {
  10. private:
  11. int x_,y_,vx_,vy_; //position and velocity. We dont need no second derivatives.
  12. Texture sprite_;
  13. SDL_Rect camera_;
  14. public:
  15. static const int CHAR_SPEED = 250;
  16. Character(std::string filepath, int x, int y): x_(x), y_(y), vx_(0), vy_(0), camera_({0,0,S_W,S_H}) {
  17. sprite_.loadFromFile(filepath);
  18. };
  19. ~Character() {
  20. sprite_.free();
  21. };
  22. void handleEvent(SDL_Event& e);
  23. void move();
  24. void render();
  25. SDL_Rect getCamera();
  26. };