player.h 1.78 KB
#ifndef __PLAYER_H__
#define __PLAYER_H__

#include "list.h"
#include "vector.h"
#include "body.h"
#include "color.h"
#include "custom_utils.h"
#include "string.h"
#include <stdlib.h>
#include <stdio.h>
#include <math.h>

typedef struct player {
  size_t player_id;
  list_t *meta_bodies;

  // physics state
  double *ph_applied_force_magnitude;

  // stats
  size_t stats_kills;
  size_t stats_food;

  // settings
  char st_left_key;
  char st_right_key;
  char st_boost_key;
  char st_shoot_key;
  color_t st_color;

  // player specific state
  bool turn_left;
  bool turn_right;
  
  // cooldowns
  double cd_dash;
  double cd_shoot;
  double cd_collide_player;
  
  // powerups
  size_t pu_base_speed;
  size_t pu_bullet_speed;
  size_t pu_rotate_rate;
  size_t pu_dash_boost;
} player_t;

player_t *player_init(size_t player_id, vector_t pos, char left_key, char right_key, char boost_key, char shoot_key);

void player_add_glow(player_t *player, size_t glow_radius);

body_t *player_get_head(player_t *p);

body_t *player_get_tail(player_t *p);

void player_set_velocity(player_t *p, double vel);

void player_turn(player_t *p);

void player_dash(player_t *p);

body_t *player_shoot(player_t *p);

void player_eat(player_t *p, body_t *food);

body_t *player_body(player_t *p);

vector_t player_head_pos(player_t *p);

vector_t player_tail_pos(player_t *p);

double player_get_score(player_t *p);

void player_update_kills(player_t *p);

void player_update_food(player_t *p);

body_t *player_add_body(player_t *p);

void player_free(void *p);

bool player_moves_on_key(player_t *p, char key);

void player_update_cd(player_t *p, double dt);

void player_update_pu(player_t *p, double dt);

void player_refresh_cd_dash(player_t *p);

void player_refresh_cd_collide_player(player_t *p);


#endif // #ifndef __PLAYER_H__