137 lines
6.5 KiB
C
137 lines
6.5 KiB
C
#include "libsuicmez/libsuicmez.h"
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <stdbool.h>
|
|
#include <string.h>
|
|
|
|
void* gc_alloc(const TypeInfo* type, size_t size);
|
|
void gc_init(void);
|
|
void gc_shutdown(void);
|
|
|
|
// Helper for allocating arrays
|
|
static void* suic_alloc_array(const TypeInfo* type, size_t elem_size, size_t len, void* init_data) {
|
|
void* ptr = gc_alloc(type, elem_size * len);
|
|
if (init_data) memcpy(ptr, init_data, elem_size * len);
|
|
return ptr;
|
|
}
|
|
|
|
// Helper for allocating structs
|
|
static void* suic_alloc_struct(const TypeInfo* type, size_t size, void* init_data) {
|
|
void* ptr = gc_alloc(type, size);
|
|
if (init_data) memcpy(ptr, init_data, size);
|
|
return ptr;
|
|
}
|
|
|
|
|
|
|
|
|
|
int suic_main(void);
|
|
|
|
|
|
int suic_main(void) {
|
|
suic_init_window(1280, 720, suic_alloc_array(NULL, sizeof(char), 27, "Soup - Voxel Battle Royale"));
|
|
suic_enable_msaa_4x();
|
|
int current_screen = 0;
|
|
char* player_name = suic_alloc_array(NULL, sizeof(char), 7, "Player");
|
|
char* server_host = suic_alloc_array(NULL, sizeof(char), 10, "127.0.0.1");
|
|
int server_port = 8888;
|
|
suic_show_fps_meter((suic_vec2){ .x = 10.000000, .y = 10.000000 });
|
|
while ((suic_window_should_close() == false)) {
|
|
suic_begin_drawing();
|
|
suic_clear_background(30, 30, 40, 255);
|
|
if ((current_screen == 0)) {
|
|
suic_draw_text(suic_alloc_array(NULL, sizeof(char), 5, "SOUP"), 450, 80, 120, 100, 200, 255, 255);
|
|
suic_draw_text(suic_alloc_array(NULL, sizeof(char), 20, "Voxel Battle Royale"), 400, 220, 40, 200, 200, 200, 255);
|
|
suic_draw_rectangle(450, 320, 380, 80, 50, 150, 255, 255);
|
|
suic_draw_rectangle_lines(450, 320, 380, 80, 100, 200, 255, 255);
|
|
suic_draw_text(suic_alloc_array(NULL, sizeof(char), 5, "PLAY"), 600, 350, 40, 255, 255, 255, 255);
|
|
suic_draw_rectangle(450, 430, 380, 80, 100, 100, 100, 255);
|
|
suic_draw_rectangle_lines(450, 430, 380, 80, 150, 150, 150, 255);
|
|
suic_draw_text(suic_alloc_array(NULL, sizeof(char), 9, "SETTINGS"), 540, 460, 40, 255, 255, 255, 255);
|
|
suic_draw_rectangle(450, 540, 380, 80, 150, 50, 50, 255);
|
|
suic_draw_rectangle_lines(450, 540, 380, 80, 200, 100, 100, 255);
|
|
suic_draw_text(suic_alloc_array(NULL, sizeof(char), 5, "QUIT"), 600, 570, 40, 255, 255, 255, 255);
|
|
suic_draw_text(suic_alloc_array(NULL, sizeof(char), 22, "v0.1.0 - Early Access"), 500, 680, 20, 150, 150, 150, 255);
|
|
int mouse_x = (int) suic_get_mouse_x();
|
|
int mouse_y = (int) suic_get_mouse_y();
|
|
int is_mouse_clicked = suic_is_mouse_button_pressed(MOUSE_BUTTON_LEFT);
|
|
if (((((mouse_x >= 450) && (mouse_x <= 830)) && (mouse_y >= 320)) && (mouse_y <= 400))) {
|
|
if ((is_mouse_clicked != 0)) {
|
|
current_screen = 1;
|
|
}
|
|
}
|
|
if (((((mouse_x >= 450) && (mouse_x <= 830)) && (mouse_y >= 430)) && (mouse_y <= 510))) {
|
|
if ((is_mouse_clicked != 0)) {
|
|
current_screen = 2;
|
|
}
|
|
}
|
|
if (((((mouse_x >= 450) && (mouse_x <= 830)) && (mouse_y >= 540)) && (mouse_y <= 620))) {
|
|
if ((is_mouse_clicked != 0)) {
|
|
break;
|
|
}
|
|
}
|
|
} else {
|
|
if ((current_screen == 1)) {
|
|
suic_draw_text(suic_alloc_array(NULL, sizeof(char), 12, "MATCHMAKING"), 450, 100, 60, 100, 200, 255, 255);
|
|
suic_draw_text(suic_alloc_array(NULL, sizeof(char), 24, "Connecting to server..."), 400, 250, 30, 200, 200, 200, 255);
|
|
suic_draw_text(suic_alloc_array(NULL, sizeof(char), 21, "Host: 127.0.0.1:8888"), 400, 310, 20, 150, 150, 150, 255);
|
|
suic_draw_text(suic_alloc_array(NULL, sizeof(char), 18, "Your Name: Player"), 400, 380, 20, 200, 200, 200, 255);
|
|
suic_draw_text(suic_alloc_array(NULL, sizeof(char), 24, "Players in Queue: 0/100"), 400, 420, 20, 200, 200, 200, 255);
|
|
suic_draw_text(suic_alloc_array(NULL, sizeof(char), 11, "Loading..."), 550, 500, 30, 100, 200, 255, 255);
|
|
suic_draw_rectangle(100, 630, 150, 60, 150, 50, 50, 255);
|
|
suic_draw_rectangle_lines(100, 630, 150, 60, 200, 100, 100, 255);
|
|
suic_draw_text(suic_alloc_array(NULL, sizeof(char), 5, "BACK"), 120, 650, 30, 255, 255, 255, 255);
|
|
int mouse_x = (int) suic_get_mouse_x();
|
|
int mouse_y = (int) suic_get_mouse_y();
|
|
int is_mouse_clicked = suic_is_mouse_button_pressed(MOUSE_BUTTON_LEFT);
|
|
if (((((mouse_x >= 100) && (mouse_x <= 250)) && (mouse_y >= 630)) && (mouse_y <= 690))) {
|
|
if ((is_mouse_clicked != 0)) {
|
|
current_screen = 0;
|
|
}
|
|
}
|
|
} else {
|
|
if ((current_screen == 2)) {
|
|
suic_draw_text(suic_alloc_array(NULL, sizeof(char), 9, "SETTINGS"), 450, 100, 60, 100, 200, 255, 255);
|
|
suic_draw_text(suic_alloc_array(NULL, sizeof(char), 13, "Player Name:"), 250, 200, 24, 200, 200, 200, 255);
|
|
suic_draw_rectangle(450, 190, 300, 50, 50, 50, 50, 255);
|
|
suic_draw_rectangle_lines(450, 190, 300, 50, 100, 100, 100, 255);
|
|
suic_draw_text(suic_alloc_array(NULL, sizeof(char), 7, "Player"), 460, 205, 20, 255, 255, 255, 255);
|
|
suic_draw_text(suic_alloc_array(NULL, sizeof(char), 13, "Server Host:"), 250, 300, 24, 200, 200, 200, 255);
|
|
suic_draw_rectangle(450, 290, 300, 50, 50, 50, 50, 255);
|
|
suic_draw_rectangle_lines(450, 290, 300, 50, 100, 100, 100, 255);
|
|
suic_draw_text(suic_alloc_array(NULL, sizeof(char), 10, "127.0.0.1"), 460, 305, 20, 255, 255, 255, 255);
|
|
suic_draw_text(suic_alloc_array(NULL, sizeof(char), 13, "Server Port:"), 250, 400, 24, 200, 200, 200, 255);
|
|
suic_draw_rectangle(450, 390, 300, 50, 50, 50, 50, 255);
|
|
suic_draw_rectangle_lines(450, 390, 300, 50, 100, 100, 100, 255);
|
|
suic_draw_text(suic_alloc_array(NULL, sizeof(char), 5, "8888"), 460, 405, 20, 255, 255, 255, 255);
|
|
suic_draw_rectangle(450, 550, 300, 70, 100, 100, 100, 255);
|
|
suic_draw_rectangle_lines(450, 550, 300, 70, 150, 150, 150, 255);
|
|
suic_draw_text(suic_alloc_array(NULL, sizeof(char), 13, "BACK TO HOME"), 495, 577, 30, 255, 255, 255, 255);
|
|
int mouse_x = (int) suic_get_mouse_x();
|
|
int mouse_y = (int) suic_get_mouse_y();
|
|
int is_mouse_clicked = suic_is_mouse_button_pressed(MOUSE_BUTTON_LEFT);
|
|
if (((((mouse_x >= 450) && (mouse_x <= 750)) && (mouse_y >= 550)) && (mouse_y <= 620))) {
|
|
if ((is_mouse_clicked != 0)) {
|
|
current_screen = 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
suic_end_drawing();
|
|
}
|
|
suic_close_window();
|
|
return 0;
|
|
}
|
|
|
|
int main(int argc, char* argv[]) {
|
|
// Initialize GC
|
|
gc_init();
|
|
// init globals
|
|
// init event loop
|
|
int result = suic_main();
|
|
// Shutdown GC
|
|
gc_shutdown();
|
|
return result;
|
|
}
|
|
|