- Sounds
- Shaders?
-
+// Draw the cursor on textboxes
#load "core/std"
#load "config"
+#load "game"
#load "main"
#load "entity/editor"
+#load "entity/items"
#load "entity/manager"
#load "entity/player"
#load "entity/store"
member_any := any.{cast(^u8) v.data + it.offset, it.type};
if is_button_just_down(GLFW_MOUSE_BUTTON_LEFT) {
+ @TODO // This should query if this field has Editor_Disabled in its tags.
+
if Rect.contains(.{x, y + 2, w, Field_Height + 2}, mouse_get_position_vector()) {
if active_index < 0 do sidebar_width += w;
active_index = i - 1;
}
}
} else {
-
+ @TODO // Add radio buttons for enum type.
}
}
}
--- /dev/null
+
+use package core
+
+Item :: struct {
+ use entity: Entity;
+
+ color: Color;
+
+ init_data :: struct {
+ pos := Vector2.{0, 0};
+ color := Color.{1, 0, 1, 1};
+ }
+
+ init :: (use this: ^Item, data: init_data) {
+ this.pos = data.pos;
+ this.size = .{16, 16};
+ this.color = data.color;
+ this.flags |= .Carryable;
+ }
+
+ get_rect :: Entity.get_rect
+
+ draw :: (use this: ^Item) {
+ immediate_set_color(this.color);
+
+ r := this->get_rect();
+ immediate_rectangle(r.x, r.y, r.w, r.h);
+ }
+}
}
-Item :: struct {
- use entity: Entity;
-
- color: Color;
-
- init_data :: struct {
- pos := Vector2.{0, 0};
- color := Color.{1, 0, 1, 1};
- }
-
- init :: (use this: ^Item, data: init_data) {
- this.pos = data.pos;
- this.size = .{16, 16};
- this.color = data.color;
- this.flags |= .Carryable;
- }
-
- get_rect :: Entity.get_rect
-
- draw :: (use this: ^Item) {
- immediate_set_color(this.color);
-
- r := this->get_rect();
- immediate_rectangle(r.x, r.y, r.w, r.h);
- }
-}
-
@Relocate
--- /dev/null
+
+use package core
+use package glfw3
+
+//
+// Game Global Variables
+//
+
+scene: Entity_Manager;
+
+game_init :: () {
+ player_texture = texture_make(#cstr "./assets/images/player.png");
+
+ scene = entity_manager_create();
+ scene->register(Player);
+ scene->register(Wall);
+ scene->register(Door);
+ scene->register(Item);
+ scene->load_from_file("scenes/quick_save.scene");
+
+ #if DEBUG {
+ println("Registered Entity types:");
+ for scene.entity_types.entries {
+ info := cast(^type_info.Type_Info_Struct) type_info.get_type_info(it.key);
+ printf(" {}\n", info.name);
+ }
+ }
+}
+
+game_update :: (dt: f32) {
+ if is_key_just_up(GLFW_KEY_F8) {
+ scene->save_to_file("scenes/quick_save.scene");
+ }
+
+ if is_key_just_up(GLFW_KEY_F9) {
+ scene->load_from_file("scenes/quick_save.scene");
+ }
+
+ if editor_shown() {
+ editor_update(dt);
+ return;
+ }
+
+ scene->update(dt);
+}
+
+game_draw :: () {
+ update_world_matrix();
+ update_model_matrix(.{0,0});
+
+ if editor_shown() {
+ editor_draw();
+ return;
+ }
+
+ scene->draw();
+}
immediate_set_color(surface_color);
immediate_rectangle(x + border_width, y + border_width, w - border_width * 2, h - border_width * 2);
+ // Draw the cursor on textboxes
+
font_set_color(theme.text_color);
font_draw(font, text_x, text_y, text); // This is technically a frame late for updating the text?
@GlobalVariable
window: GLFWwindow_p
-@GlobalVariable
-scene: Entity_Manager;
-
@GlobalVariable
window_width: u32
window_height: u32
#if DEBUG { debug_font: Font; }
-
init :: () {
- create_window();
+ window = create_window();
input_bind_glfw_events(window);
glInit(glfwGetLoadProcAddress());
fonts_init();
immediate_init();
editor_init();
+ game_init();
glfwGetWindowSize(window, ^window_width, ^window_height);
glViewport(0, 0, window_width, window_height);
update_view_matrix();
- player_texture = texture_make(#cstr "./assets/images/player.png");
-
#if DEBUG { debug_font = font_lookup(.{"./assets/fonts/calibri.ttf", 16}); }
-
- scene = entity_manager_create();
- scene->register(Player);
- scene->register(Wall);
- scene->register(Door);
- scene->register(Item);
- scene->load_from_file("scenes/quick_save.scene");
-
- #if DEBUG {
- println("Registered Entity types:");
- for scene.entity_types.entries {
- info := cast(^type_info.Type_Info_Struct) type_info.get_type_info(it.key);
- printf(" {}\n", info.name);
- }
- }
}
update :: (dt: f32) {
editor_toggle();
}
- if is_key_just_up(GLFW_KEY_F8) {
- scene->save_to_file("scenes/quick_save.scene");
- }
-
- if is_key_just_up(GLFW_KEY_F9) {
- scene->load_from_file("scenes/quick_save.scene");
- }
-
- if editor_shown() {
- editor_update(dt);
- return;
- }
-
- scene->update(dt);
+ game_update(dt);
}
draw :: () {
glfwSwapBuffers(window);
}
- update_world_matrix();
- update_model_matrix(.{0,0});
-
- if editor_shown() {
- editor_draw();
- return;
- }
-
- scene->draw();
+ game_draw();
#if false {
mx, my := mouse_get_position();
}
}
-create_window :: () {
+create_window :: () => {
#if runtime.compiler_os == .Linux {
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
}
- window = glfwCreateWindow(800, 600, #cstr "Bar simulator");
+ window := glfwCreateWindow(800, 600, #cstr "Bar simulator");
glfwMakeContextCurrent(window);
glfwSwapInterval(1);
glfwSetWindowSizeCallback(window, "on_resize");
+ return window;
}
#export "on_resize" (window: GLFWwindow_p, width, height: u32) {