File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change 7
7
8
8
game_state_t game_state;
9
9
10
- const double PLAYER_WIDTH = TILE_WIDTH;
11
- const double PLAYER_HEIGHT = PLAYER_WIDTH;
10
+ const double PLAYER_WIDTH_METERS = 0.8 ;
11
+ const double PLAYER_WIDTH = PLAYER_WIDTH_METERS * METERS_TO_PIXELS;
12
+
13
+ const double PLAYER_HEIGHT_METERS = 1.0 ;
14
+ const double PLAYER_HEIGHT = PLAYER_HEIGHT_METERS * METERS_TO_PIXELS;
15
+
12
16
const color_t PLAYER_COLOR = rgb(150.3 , 250.5 , 20.6 );
13
- const double PLAYER_SPEED = 128 ; // in pixels per second
17
+
18
+ const double PLAYER_SPEED_METERS_PER_SECOND = 3.0 ;
19
+ const double PLAYER_SPEED = PLAYER_SPEED_METERS_PER_SECOND * METERS_TO_PIXELS;
14
20
15
21
void put_pixel (pixel_buffer_t * pixel_buffer, uint x, uint y, color_t color) {
16
22
uint offset = pixel_buffer->width * y + x;
Original file line number Diff line number Diff line change @@ -12,6 +12,9 @@ const uint WORLD_WIDTH = 2;
12
12
const uint WORLD_HEIGHT = 2 ;
13
13
const uint TILE_MAP_WIDTH = 16 ;
14
14
const uint TILE_MAP_HEIGHT = 9 ;
15
+
16
+ const double METERS_TO_PIXELS = SCREEN_WIDTH / TILE_MAP_WIDTH; // Each tile is a meter
17
+
15
18
const uint TILE_WIDTH = SCREEN_WIDTH / TILE_MAP_WIDTH;
16
19
const uint TILE_HEIGHT = SCREEN_HEIGHT / TILE_MAP_HEIGHT;
17
20
const color_t TILE_COLOR = rgb(100 , 100 , 100 );
You can’t perform that action at this time.
0 commit comments