generated from 32blit/32blit-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kart.hpp
80 lines (53 loc) · 1.99 KB
/
kart.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#pragma once
#include "items.hpp"
#include "sprite3d.hpp"
#include "types/point.hpp"
#include "types/vec2.hpp"
#include "types/vec3.hpp"
class RaceState;
struct TimeTrialSaveData;
class Kart final {
public:
Kart();
void update();
void set_race_state(RaceState *race_state);
// position helpers
const blit::Vec3 &get_pos() const {return sprite.world_pos;}
blit::Vec2 get_2d_pos() const {return blit::Vec2(sprite.world_pos.x, sprite.world_pos.z);}
blit::Point get_tile_pos() const {return blit::Point(sprite.world_pos.x / 8.0f, sprite.world_pos.z / 8.0f);}
const blit::Vec3 &get_vel() const;
void set_vel(const blit::Vec3 &vel);
float get_radius() const;
int get_current_lap() const {return current_lap;}
bool has_finished() const;
uint32_t get_finish_time() const {return finish_time;}
int get_lap_time(int lap) const;
int get_race_time() const;
float get_route_estimate() const;
void collect_item();
ItemType get_current_item() const {return current_item;}
void disable();
void set_time_trial_data(TimeTrialSaveData *data);
bool is_ghost() const {return time_trial_data && !is_player;}
Sprite3D sprite;
bool is_player = false;
int current_place = 0;
int kart_index = 0; // index into kart_info
private:
void auto_drive();
void use_item();
blit::Vec3 vel, acc;
float turn_speed = 0.0f;
int boost_time = 0, disable_time = 0;
float return_to_track_timer = 0.0f;
blit::Vec3 return_pos_v, return_look_v;
int current_lap = -1; // -1 because we start behind the finish line
uint32_t lap_start_time[3]{0};
uint32_t finish_time = 0;
unsigned int current_route_segment = 0;
float current_route_frac = 0.0f;
ItemType current_item = ItemType::None;
TimeTrialSaveData *time_trial_data = nullptr; // if this is set we're either recording a time trial (is_player), or a ghost
int ghost_timer = 0; // read/write every 10 updates
RaceState *race_state = nullptr;
};