diff options
Diffstat (limited to 'src/objs/player.lua')
| -rw-r--r-- | src/objs/player.lua | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/objs/player.lua b/src/objs/player.lua index 74d28e8..4f078f0 100644 --- a/src/objs/player.lua +++ b/src/objs/player.lua @@ -19,6 +19,23 @@ function player_movement_sys(player, dt) inpx, inpy = normalize(inpx, inpy) player.vx = dlerp(player.vx, inpx * PLAYER_SPEED, 25 * dt) player.vy = dlerp(player.vy, inpy * PLAYER_SPEED, 25 * dt) + + 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) + remove_tile(scn.tilemap, tx, ty) + end end function new_player(x, y) @@ -32,3 +49,4 @@ function new_player(x, y) add_comp(ent, "Player") add_comp(ent, "Sprite", "res/img/player.ase") end + |
