aboutsummaryrefslogtreecommitdiff
path: root/src/objs
diff options
context:
space:
mode:
authorne_mene <[email protected]>2026-03-12 19:56:53 +0100
committerne_mene <[email protected]>2026-03-12 19:56:53 +0100
commit5179c0c029487ea0107c9f9a7d879cc44b51e924 (patch)
tree9608bc7497490c74ad5e3711e5d122f3e2f070a7 /src/objs
parentd4f1856d357de241320dd6cbf66972c74784c309 (diff)
parent4828c80a92a40067d8f58922c38c4dbeeafc8403 (diff)
Merge remote-tracking branch 'refs/remotes/origin/main'
thanks
Diffstat (limited to 'src/objs')
-rw-r--r--src/objs/player.lua44
1 files changed, 31 insertions, 13 deletions
diff --git a/src/objs/player.lua b/src/objs/player.lua
index bc71ea7..0903372 100644
--- a/src/objs/player.lua
+++ b/src/objs/player.lua
@@ -14,6 +14,8 @@ function body_sys(ent, dt)
ent.y = ent.box.y
end
+local tile = 1
+
function player_movement_sys(player, dt)
local inpx, inpy = input_direction("Left", "Right", "Up", "Down")
inpx, inpy = normalize(inpx, inpy)
@@ -21,24 +23,40 @@ function player_movement_sys(player, dt)
player.vy = dlerp(player.vy, inpy * PLAYER_SPEED, 25 * dt)
-- Testicle stuff, remove when testising is no longer needed
- if is_input_pressed("Right_Click") then
- local scn = get_current_scene()
- assert(scn, "no scene set.")
+ if not im.has_focus() then
+ if is_input_pressed("Right_Click") then
+ local scn = get_current_scene()
+ assert(scn, "no scene set.")
- local mx, my = get_mouse_pos()
- local tx, ty = to_tile_coords(mx, my)
- set_tile(scn.tilemap, tx, ty, 1)
- end
- if is_input_pressed("Left_Click") then
- local scn = get_current_scene()
- assert(scn, "no scene set.")
+ local mx, my = get_mouse_pos()
+ local tx, ty = to_tile_coords(mx, my)
+ set_tile(scn.tilemap, tx, ty, tile)
+ end
+ if is_input_pressed("Left_Click") then
+ local scn = get_current_scene()
+ assert(scn, "no scene set.")
- local mx, my = get_mouse_pos()
- local tx, ty = to_tile_coords(mx, my)
- remove_tile(scn.tilemap, tx, ty)
+ local mx, my = get_mouse_pos()
+ local tx, ty = to_tile_coords(mx, my)
+ remove_tile(scn.tilemap, tx, ty)
+ end
end
end
+function player_ui_sys(_)
+ im.begin_window("Room Editor", 5, 5, 50, 50, {})
+ im.layout({0.5, 0.75, 1})
+ im.text("Tile: " .. tostring(tile))
+ if im.button(" - ") then
+ tile = math.max(tile - 1, 0)
+ end
+ if im.button("+ ") then
+ tile = tile + 1
+ end
+ im.layout()
+ im.end_window()
+end
+
function new_player(x, y)
local ent = new_entity()
add_comp(ent, "Body", x, y, 16, 16, {