From dfcc030f4d35fd2f7ef0783113551450755a4bb8 Mon Sep 17 00:00:00 2001 From: Sara Date: Thu, 11 May 2023 19:50:14 +0200 Subject: [PATCH] removed player.c and player.h these were for testing anyway --- src/player.c | 41 ----------------------------------------- src/player.h | 16 ---------------- 2 files changed, 57 deletions(-) delete mode 100644 src/player.c delete mode 100644 src/player.h diff --git a/src/player.c b/src/player.c deleted file mode 100644 index 4fada2e..0000000 --- a/src/player.c +++ /dev/null @@ -1,41 +0,0 @@ -#include "player.h" -#include "layers.h" -#include "world.h" -#include "input.h" -#include "engine.h" -#include - -float player_move_x = 0; -float player_move_y = 0; -float player_xv = 0; -float player_yv = 0; -object_t* player_instance = NULL; - -void player_update(object_t *object) { - float m = sqrtf(player_move_x*player_move_x + player_move_y*player_move_y); - if(m == FP_NAN) m = 1; - m = 1.f/m; - player_xv = player_move_x * 3.f * m, - player_yv = player_move_y * 3.f * m; - object->sprite.x += player_xv * delta_time(); - object->sprite.y += player_yv * delta_time(); -} - -object_t* create_player() { - player_instance = make_object(); - player_instance->evt_update = &player_update; - player_instance->sprite = make_sprite("player.png", 0, 0); - - add_key_listener(SDL_SCANCODE_A, SDL_SCANCODE_D, &player_axis_horizontal); - add_key_listener(SDL_SCANCODE_S, SDL_SCANCODE_W, &player_axis_vertical); - - return player_instance; -} - -void player_axis_horizontal(int axis) { - player_move_x = axis; -} - -void player_axis_vertical(int axis) { - player_move_y = -axis; -} diff --git a/src/player.h b/src/player.h deleted file mode 100644 index 3f116e9..0000000 --- a/src/player.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef _player_h -#define _player_h - -struct object_t; - -extern float player_move_x, player_move_y, - player_xv, player_yv; -extern struct object_t* player_instance; - -void player_update(struct object_t* object); -struct object_t* create_player(); - -extern void player_axis_horizontal(int axis); -extern void player_axis_vertical(int axis); - -#endif /* _player_h */