-
Notifications
You must be signed in to change notification settings - Fork 14
/
worldtask.h
55 lines (37 loc) · 1.4 KB
/
worldtask.h
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
#ifndef WORLDTASK_H
#define WORLDTASK_H
#include "task.h"
#include "world.h"
#include "gl.h"
#include "aabb.h"
class WorldTask : public Task
{
public:
virtual void makeCurrent() override;
virtual void logic() override;
virtual void render() override;
void resetWorld();
GLFix x, y = World::HEIGHT * Chunk::SIZE * BLOCK_SIZE, z, xr, yr;
static constexpr GLFix player_width = BLOCK_SIZE*0.8f, player_height = BLOCK_SIZE*1.8f, eye_pos = BLOCK_SIZE*1.6f;
void setMessage(const char *message);
unsigned int frameCount() { return frame_counter; }
private:
void crosshairPixel(int x, int y);
void getForward(GLFix *x, GLFix *z);
void getRight(GLFix *x, GLFix *z);
GLFix speed();
//Player position and movement
AABB aabb;
bool can_jump = false, tp_had_contact = false;
int tp_last_x = 0, tp_last_y = 0;
GLFix vy = 0; //Y-Velocity for gravity and jumps
bool in_water = false;
static constexpr unsigned int blockselection_frames = 2;
unsigned int blockselection_frame = 0, blockselection_frame_fraction = 0;
VECTOR3 selection_pos; AABB::SIDE selection_side; VECTOR3 selection_pos_abs; bool do_test = true; //For intersectsRay
char message[40]; unsigned int message_timeout = 0;
bool draw_inventory = true;
unsigned int frame_counter = 0; // Incremented after each render
};
extern WorldTask world_task;
#endif // WORLDTASK_H