A 2D tile-based sandbox game.
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.

common.h 651B

1234567891011121314151617181920212223242526272829303132333435
  1. #pragma once
  2. #include <SFML/Graphics.hpp>
  3. #include <SFML/System/Vector2.hpp>
  4. #include "Vector2.h"
  5. namespace Swan {
  6. static constexpr int TILE_SIZE = 32;
  7. static constexpr int TICK_RATE = 20;
  8. static constexpr int CHUNK_HEIGHT = 32;
  9. static constexpr int CHUNK_WIDTH = 32;
  10. using TilePos = Vector2<int>;
  11. using ChunkPos = Vector2<int>;
  12. struct Win {
  13. public:
  14. sf::RenderWindow *window_;
  15. sf::Transform transform_;
  16. Vec2 cam_;
  17. Win(sf::RenderWindow *win): window_(win) {}
  18. void setPos(const Vec2 &pos) {
  19. transform_ = sf::Transform().translate(pos - cam_);
  20. }
  21. void draw(const sf::Drawable &drawable) {
  22. window_->draw(drawable, transform_);
  23. }
  24. };
  25. }