-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame.c
More file actions
59 lines (50 loc) · 1.66 KB
/
game.c
File metadata and controls
59 lines (50 loc) · 1.66 KB
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
#include "engine.h"
#include "game.h"
#include "gfx.h"
#include "3d.h"
#include "world.h"
#include "player.h"
#include "input.h"
#include "console.h"
#include "ff_vector2.h"
#include "ff_color.h"
#include "ff_point2.h"
Game game;
Vector2f FORWARD_DIRECTION = vector2f( 0.0f, 1.0f);
Vector2f BACKWARD_DIRECTION = vector2f( 0.0f, -1.0f);
Vector2f RIGHT_DIRECTION = vector2f( 1.0f, 0.0f);
Vector2f LEFT_DIRECTION = vector2f(-1.0f, 0.0f);
float TURN_DIRECTION_RIGHT = 1.0f;
float TURN_DIRECTION_LEFT = -1.0f;
//Relates an Action to a function (And its data)
Action game_actions[] =
{
{ACTION_QUIT, signal_quit, &engine, 0},
{ACTION_TOGGLE_CONSOLE, toggle_console, &console, 0},
{ACTION_CONFIRM_CONSOLE, enter_console, &input.text_input_character_loc, 0},
{ACTION_FORWARD, move_player, &FORWARD_DIRECTION, ACT_FLAG_CONTINUOUS},
{ACTION_BACKWARD, move_player, &BACKWARD_DIRECTION, ACT_FLAG_CONTINUOUS},
{ACTION_STRAFE_RIGHT, move_player, &RIGHT_DIRECTION, ACT_FLAG_CONTINUOUS},
{ACTION_STRAFE_LEFT, move_player, &LEFT_DIRECTION, ACT_FLAG_CONTINUOUS},
{ACTION_TURN_RIGHT, turn_player, &TURN_DIRECTION_RIGHT, ACT_FLAG_CONTINUOUS},
{ACTION_TURN_LEFT, turn_player, &TURN_DIRECTION_LEFT, ACT_FLAG_CONTINUOUS}
};
const static uint32_t game_actions_size = sizeof(game_actions)/sizeof(Action);
void init_game()
{
set_input_actions(game_actions, game_actions_size);
}
void quit_game()
{
}
void update_game()
{
}
void draw_game()
{
render_level(&world.player.camera);
if(engine.debug_flag)
{
GFX_draw_string_color_f(point2(4, 220), 3, DEBUG_TEXT_COLOR, "px= %+-4.2f py= %+-4.2f", world.player.position.x, world.player.position.y);
}
}