[Background]
id = 100
flags = 0
-pos.x = 0.0000
-pos.y = 0.0000
-size.x = 0.0000
-size.y = 0.0000
+pos.x = 404.0000
+pos.y = 310.5000
+size.x = 941.0000
+size.y = 751.0000
+:BackgroundComponent
+texture_path = "./assets/images/background.png"
:RenderComponent
layer = 0
color.r = 1.0000
id = 152
flags = 2
pos.x = 276.7525
-pos.y = 229.4652
+pos.y = 229.4651
size.x = 16.0000
size.y = 32.0000
:MovementComponent
controls.pick_up = 46
facing = 1
velocity.x = 0.0000
-velocity.y = -0.0000
+velocity.y = 0.0000
:PlayerComponent
holding = 155
:RenderComponent
[Player]
id = 12
flags = 2
-pos.x = 334.4180
+pos.x = 334.4179
pos.y = 246.6519
size.x = 16.0000
size.y = 32.0000
controls.interact = 70
controls.pick_up = 71
facing = 3
-velocity.x = -0.0000
+velocity.x = 0.0000
velocity.y = 0.0000
:PlayerComponent
holding = 150
[Item_Entity]
id = 150
flags = 6
-pos.x = 334.4180
+pos.x = 334.4179
pos.y = 222.6519
size.x = 16.0000
size.y = 16.0000
id = 155
flags = 0
pos.x = 276.7525
-pos.y = 205.4652
+pos.y = 205.4651
size.x = 16.0000
size.y = 16.0000
:RenderComponent
[Background]
id = 100
flags = 0
-pos.x = 0.0000
-pos.y = 0.0000
-size.x = 0.0000
-size.y = 0.0000
+pos.x = 404.0000
+pos.y = 310.5000
+size.x = 941.0000
+size.y = 751.0000
+:BackgroundComponent
+texture_path = "./assets/images/background.png"
:RenderComponent
layer = 0
color.r = 1.0000
[Player]
id = 152
flags = 2
-pos.x = 276.7493
-pos.y = 229.5119
+pos.x = 276.7525
+pos.y = 229.4651
size.x = 16.0000
size.y = 32.0000
:MovementComponent
controls.interact = 44
controls.pick_up = 46
facing = 1
-velocity.x = 0.0268
-velocity.y = -0.3748
+velocity.x = 0.0000
+velocity.y = 0.0000
:PlayerComponent
holding = 155
:RenderComponent
[Player]
id = 12
flags = 2
-pos.x = 334.4181
-pos.y = 246.6520
+pos.x = 334.4179
+pos.y = 246.6519
size.x = 16.0000
size.y = 32.0000
:MovementComponent
controls.interact = 70
controls.pick_up = 71
facing = 3
-velocity.x = -0.0001
-velocity.y = -0.0000
+velocity.x = 0.0000
+velocity.y = 0.0000
:PlayerComponent
holding = 150
:RenderComponent
[Item_Entity]
id = 150
flags = 6
-pos.x = 334.4181
-pos.y = 222.6520
+pos.x = 334.4179
+pos.y = 222.6519
size.x = 16.0000
size.y = 16.0000
:RenderComponent
[Item_Entity]
id = 155
flags = 0
-pos.x = 276.7484
-pos.y = 205.5248
+pos.x = 276.7525
+pos.y = 205.4651
size.x = 16.0000
size.y = 16.0000
:RenderComponent
--- /dev/null
+
+use package core
+
+BackgroundComponent :: struct {
+ use component: Component;
+
+ texture_path: str;
+
+ added :: (use this: ^BackgroundComponent, entity: ^Entity) {
+ scene->modify_component(entity, RenderComponent) {
+ comp.func = BackgroundComponent.render;
+ }
+ }
+
+ render :: (entity: ^Entity) {
+ background_comp := entity->get(BackgroundComponent);
+ background_texture, _ := texture_lookup(background_comp.texture_path);
+ texture_wrap(^background_texture, .Repeat);
+
+ r := entity->get_rect();
+ immediate_subimage(^background_texture, r.x, r.y, r.w, r.h, 0, 0, r.w, r.h);
+ }
+}
\ No newline at end of file
#local handle_placing_entities :: () {
if active_index < 0 do return;
- mouse_pos := mouse_get_position_vector() - scene_render_offset;
+ mouse_raw := mouse_get_position_vector();
+ mouse_pos := mouse_raw - scene_render_offset;
- if is_button_just_up(GLFW_MOUSE_BUTTON_LEFT) && mouse_pos.x < ~~window_width - sidebar_width {
+ if is_button_just_up(GLFW_MOUSE_BUTTON_LEFT) && mouse_raw.x < ~~window_width - sidebar_width && mouse_raw.x >= 0 {
schematic := scene.schematics.entries[active_index].value;
entity := schematic.create(^scene);
entity.schematic = schematic.type;
}
#local handle_entity_selction_and_dragging :: (dt: f32) {
- mouse_pos := mouse_get_position_vector() - scene_render_offset;
+ mouse_raw := mouse_get_position_vector();
+ mouse_pos := mouse_raw - scene_render_offset;
- if mouse_pos.x < ~~window_width - sidebar_width {
+ if mouse_raw.x < ~~window_width - sidebar_width && mouse_pos.x >= 0 {
if is_button_just_down(GLFW_MOUSE_BUTTON_LEFT) || is_button_just_down(GLFW_MOUSE_BUTTON_RIGHT) {
if active_tab == .Edit do active_index = -1;
selected_entity_id = Entity_Nothing;
use package core
-#local background_texture: Texture;
+// #local background_texture: Texture;
Background :: struct {
#struct_tag Entity_Schematic.{
this.pos = .{0, 0};
this.size = .{0, 0};
- scene->modify_component(this, RenderComponent) {
- comp.func = Background.render;
+ scene->modify_component(this, BackgroundComponent) {
+ comp.texture_path = "./assets/images/background.png";
}
- background_texture', _ := texture_lookup("./assets/images/background.png");
- texture_wrap(^background_texture, .Repeat);
-
return this;
}
}
-
- render :: (this: ^Entity) {
- size :: 10000.0f
- immediate_set_color(.{1, 1, 1});
- immediate_subimage(^background_texture, this.pos.x, this.pos.y, size, size, 0, 0, size / 2, size / 2);
- }
}
\ No newline at end of file
if !editor_shown() {
view_rect = Rect.{0, 0, ~~window_width, ~~window_height};
} else {
+ // view_rect.x = math.lerp(editor_open_percent(), cast(f32) ((window_width - scene_canvas.width) / 2), 0);
view_rect.x = math.lerp(editor_open_percent(), cast(f32) ((window_width - scene_canvas.width) / 2), cast(f32) ((window_width - scene_canvas.width - 400) / 2));
view_rect.y = ~~ ((window_height - scene_canvas.height) / 2);
view_rect.w = ~~ scene_canvas.width;