remove typedefs in favor of SDL ones
This commit is contained in:
parent
3e32ebd62b
commit
b1e657abc3
54
src/main.cpp
54
src/main.cpp
@ -14,16 +14,6 @@
|
||||
#include "../assets/shader/basic_vertex_shader.h"
|
||||
#include "../assets/shader/basic_pixel_shader.h"
|
||||
|
||||
typedef uint8_t uint8;
|
||||
typedef uint16_t uint16;
|
||||
typedef uint32_t uint32;
|
||||
typedef uint64_t uint64;
|
||||
|
||||
typedef int8_t int8;
|
||||
typedef int16_t int16;
|
||||
typedef int32_t int32;
|
||||
typedef int64_t int64;
|
||||
|
||||
SDL_GPUDevice *device;
|
||||
SDL_Window *window;
|
||||
|
||||
@ -39,8 +29,8 @@ SDL_GPUBuffer *tiles_instance_buffer;
|
||||
SDL_GPUBuffer *player_instance_buffer;
|
||||
SDL_GPUBuffer *quad_instance_buffer;
|
||||
|
||||
int16 window_width;
|
||||
int16 window_height;
|
||||
Sint16 window_width;
|
||||
Sint16 window_height;
|
||||
|
||||
bool Running = true;
|
||||
|
||||
@ -59,14 +49,14 @@ Vertex vertices[] = {
|
||||
{{ 1, 1, 1, 1 }, {1, 0}},
|
||||
};
|
||||
|
||||
uint16 indices[] = {
|
||||
Uint16 indices[] = {
|
||||
0, 1, 2,
|
||||
0, 3, 1,
|
||||
};
|
||||
|
||||
struct Instance {
|
||||
V4 pos_size;
|
||||
uint32 tile_type;
|
||||
Uint32 tile_type;
|
||||
V4 uv0uv1;
|
||||
};
|
||||
|
||||
@ -77,17 +67,17 @@ Instance tiles_instances[view_width * view_height] = {
|
||||
Instance player_instance = { {0.5f, 0.5f, 1.0f / view_width, 1.0f / view_height}, 0, {0, 0, 1, 1}};
|
||||
|
||||
struct Tile {
|
||||
uint32 type;
|
||||
Uint32 type;
|
||||
};
|
||||
|
||||
uint32 map_width = view_width;
|
||||
uint32 map_height = view_height;
|
||||
Uint32 map_width = view_width;
|
||||
Uint32 map_height = view_height;
|
||||
|
||||
Tile* map_tiles;
|
||||
|
||||
struct Player {
|
||||
int64 pos_x;
|
||||
int64 pos_y;
|
||||
Sint64 pos_x;
|
||||
Sint64 pos_y;
|
||||
};
|
||||
|
||||
Player player = {
|
||||
@ -114,12 +104,12 @@ void save_map() {
|
||||
}
|
||||
defer(fclose(file));
|
||||
|
||||
if (fwrite(&map_width, sizeof(uint32), 1, file) != 1) {
|
||||
if (fwrite(&map_width, sizeof(Uint32), 1, file) != 1) {
|
||||
log_error("fwrite for map_width has failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (fwrite(&map_height, sizeof(uint32), 1, file) != 1) {
|
||||
if (fwrite(&map_height, sizeof(Uint32), 1, file) != 1) {
|
||||
log_error("fwrite for map_height has failed.");
|
||||
return;
|
||||
}
|
||||
@ -142,9 +132,9 @@ void load_map() {
|
||||
return;
|
||||
}
|
||||
|
||||
map_width = read<uint32>(file);
|
||||
map_height = read<uint32>(file);
|
||||
if (file.length != map_width * map_height * sizeof(uint32)) {
|
||||
map_width = read<Uint32>(file);
|
||||
map_height = read<Uint32>(file);
|
||||
if (file.length != map_width * map_height * sizeof(Uint32)) {
|
||||
log_error("Incorrect file.length.");
|
||||
return;
|
||||
}
|
||||
@ -166,15 +156,15 @@ void change_map_size(char direction, int amount) {
|
||||
auto old_map_width = map_width;
|
||||
auto old_map_height = map_height;
|
||||
|
||||
int32 new_x_offset = 0;
|
||||
int32 new_y_offset = 0;
|
||||
int32 old_x_offset = 0;
|
||||
int32 old_y_offset = 0;
|
||||
Sint32 new_x_offset = 0;
|
||||
Sint32 new_y_offset = 0;
|
||||
Sint32 old_x_offset = 0;
|
||||
Sint32 old_y_offset = 0;
|
||||
|
||||
int32 to_fill_width = map_width;
|
||||
int32 to_fill_height = map_height;
|
||||
int32 to_fill_x_offset = 0;
|
||||
int32 to_fill_y_offset = 0;
|
||||
Sint32 to_fill_width = map_width;
|
||||
Sint32 to_fill_height = map_height;
|
||||
Sint32 to_fill_x_offset = 0;
|
||||
Sint32 to_fill_y_offset = 0;
|
||||
|
||||
if (direction == 'W') {
|
||||
player.pos_x = player.pos_x + amount;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user