Compare commits

...

1 Commits

Author SHA1 Message Date
Simon From Jakobsen
89cea44086 fix and stub errors 2025-10-29 12:38:39 +01:00
8 changed files with 54 additions and 4 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
build/ build/
a.out a.out
.vscode/

View File

@ -1,4 +1,6 @@
#include "Arrow.hpp" #include "Arrow.hpp"
#include <cmath>
#include <numbers>
Arrow::Arrow(GameRenderer *renderer, const double x, const double y, const double angle) Arrow::Arrow(GameRenderer *renderer, const double x, const double y, const double angle)
: renderer(renderer), x(x), y(y), angle(angle) : renderer(renderer), x(x), y(y), angle(angle)
@ -12,7 +14,7 @@ void Arrow::draw(const double player_x, const double player_y) const
sprite, sprite,
(int)(x - sprite.width / 2 + renderer->screen_width / 2 - player_x), (int)(x - sprite.width / 2 + renderer->screen_width / 2 - player_x),
(int)(y - sprite.height / 2 + renderer->screen_height / 2 - player_y), (int)(y - sprite.height / 2 + renderer->screen_height / 2 - player_y),
angle * 180 / M_PI angle * 180 / std::numbers::pi
); );
} }

View File

@ -3,6 +3,7 @@
#include "GameRenderer.hpp" #include "GameRenderer.hpp"
#include "Player.hpp" #include "Player.hpp"
#include "Game.hpp" #include "Game.hpp"
#include <chrono>
using namespace std::literals::chrono_literals; using namespace std::literals::chrono_literals;

View File

@ -3,6 +3,7 @@
#include <thread> #include <thread>
#include <vector> #include <vector>
#include <mutex>
#include "Arrow.hpp" #include "Arrow.hpp"
#include "GameRenderer.hpp" #include "GameRenderer.hpp"
#include "Player.hpp" #include "Player.hpp"

View File

@ -2,7 +2,7 @@
#define GAME_RENDERER_HPP #define GAME_RENDERER_HPP
#include <string> #include <string>
#include <SDL2/SDL.h> // #include <SDL2/SDL.h>
#include "Sprite.hpp" #include "Sprite.hpp"
class GameRenderer class GameRenderer

View File

@ -1,5 +1,7 @@
#include "GameRenderer.hpp" #include "GameRenderer.hpp"
#include "Player.hpp" #include "Player.hpp"
#include <cmath>
#include <numbers>
Player::Player(GameRenderer *renderer) : renderer(renderer) Player::Player(GameRenderer *renderer) : renderer(renderer)
{ {
@ -19,7 +21,7 @@ void Player::draw() const
bow_sprite, bow_sprite,
(int)(renderer->screen_width / 2 - bow_sprite.width / 2 + std::cos(angle) * 30), (int)(renderer->screen_width / 2 - bow_sprite.width / 2 + std::cos(angle) * 30),
(int)(renderer->screen_height / 2 - bow_sprite.height / 2 + std::sin(angle) * 30), (int)(renderer->screen_height / 2 - bow_sprite.height / 2 + std::sin(angle) * 30),
angle * 180 / M_PI angle * 180 / std::numbers::pi
); );
} }

View File

@ -1,7 +1,8 @@
#ifndef SPRITE_HPP #ifndef SPRITE_HPP
#define SPRITE_HPP #define SPRITE_HPP
#include <SDL2/SDL_render.h> #include "Whatever.hpp"
// #include <SDL2/SDL_render.h>
typedef struct { typedef struct {
SDL_Texture *texture; SDL_Texture *texture;

42
src/Whatever.hpp Normal file
View File

@ -0,0 +1,42 @@
#ifndef WHATEVER_HPP
#define WHATEVER_HPP
using SDL_Texture = void;
using SDL_Renderer = void;
using SDL_Window = void;
enum SDL_Event_type {
SDL_QUIT,
SDL_KEYDOWN,
SDL_KEYUP,
SDL_MOUSEBUTTONDOWN,
};
enum SDL_Event_keysym_sym {
SDLK_RIGHT,
SDLK_d,
SDLK_LEFT,
SDLK_a,
SDLK_DOWN,
SDLK_s,
SDLK_UP,
SDLK_w,
};
struct SDL_Event {
SDL_Event_type type;
struct {
struct {
SDL_Event_keysym_sym sym;
} keysym;
} key;
struct {
int button;
} button;
};
void SDL_WaitEvent(SDL_Event*);
void SDL_GetMouseState(int*, int*);
#endif