/apps/demos/crawl: new tile texture, solid walls

This commit is contained in:
veclavtalica 2025-02-21 01:36:46 +03:00
parent 66c525a0d4
commit b6347996f9
3 changed files with 19 additions and 11 deletions

BIN
apps/demos/crawl/data/assets/mossy_rock.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -13,19 +13,20 @@
-- Defines classes under symbols, which could have properties attached. -- Defines classes under symbols, which could have properties attached.
# stone_wall # stone_wall
wall_texture : /assets/brick.png wall_texture : /assets/brick.png
solid : 1
. stone_floor . stone_floor
tile_texture : /assets/pebbles.png tile_texture : /assets/mossy_rock.png
@ player_spawn @ player_spawn
unique : unique : 1
face : south face : south
hold : torch hold : torch
tile_texture : /assets/pebbles.png tile_texture : /assets/mossy_rock.png
X door X door
open_on_signal : sg_torch0 open_on_signal : sg_torch0
tile_texture : /assets/pebbles.png tile_texture : /assets/mossy_rock.png
/ lever / lever
on_interact_emit : sg_torch0 on_interact_emit : sg_torch0
tile_texture : /assets/pebbles.png tile_texture : /assets/mossy_rock.png
@meta @meta
-- Arbitrary sections could be defined with value pairs. -- Arbitrary sections could be defined with value pairs.

View File

@ -36,15 +36,19 @@ function game_tick()
ctx.udata.player.direction = { x = -ctx.udata.player.direction.z, y = ctx.udata.player.direction.y, z = ctx.udata.player.direction.x } ctx.udata.player.direction = { x = -ctx.udata.player.direction.z, y = ctx.udata.player.direction.y, z = ctx.udata.player.direction.x }
end end
local direction = { x = 0, z = 0 } local move = { x = 0, y = 0 }
if input_action_just_released { name = "walk_forward" } then if input_action_just_released { name = "walk_forward" } then
direction = { x = direction.x + ctx.udata.player.direction.z, z = direction.z + ctx.udata.player.direction.x } move = { x = move.x + ctx.udata.player.direction.z, y = move.y + ctx.udata.player.direction.x }
end end
if input_action_just_released { name = "walk_backward" } then if input_action_just_released { name = "walk_backward" } then
direction = { x = direction.x - ctx.udata.player.direction.z, z = direction.z - ctx.udata.player.direction.x } move = { x = move.x - ctx.udata.player.direction.z, y = move.y - ctx.udata.player.direction.x }
end end
ctx.udata.player.position = { x = ctx.udata.player.position.x + direction.x, y = ctx.udata.player.position.y + direction.z } if ctx.udata.level.grid[ctx.udata.player.position.y + move.y][ctx.udata.player.position.x + move.x].solid ~= nil then
move = { x = 0, y = 0 }
end
ctx.udata.player.position = { x = ctx.udata.player.position.x + move.x, y = ctx.udata.player.position.y + move.y }
ctx.udata.player.position_lerp.x = qlerp(ctx.udata.player.position_lerp.x, ctx.udata.player.position.x, ctx.frame_duration * 30) ctx.udata.player.position_lerp.x = qlerp(ctx.udata.player.position_lerp.x, ctx.udata.player.position.x, ctx.frame_duration * 30)
ctx.udata.player.position_lerp.y = qlerp(ctx.udata.player.position_lerp.y, ctx.udata.player.position.y, ctx.frame_duration * 30) ctx.udata.player.position_lerp.y = qlerp(ctx.udata.player.position_lerp.y, ctx.udata.player.position.y, ctx.frame_duration * 30)
@ -53,9 +57,9 @@ function game_tick()
draw_camera { draw_camera {
position = { position = {
x = ctx.udata.player.position_lerp.y * 2 + 1, x = ctx.udata.player.position_lerp.y * 2 + 1 - ctx.udata.player.direction.x / 2,
y = 1, y = 1,
z = ctx.udata.player.position_lerp.x * 2 + 1, z = ctx.udata.player.position_lerp.x * 2 + 1 - ctx.udata.player.direction.z / 2,
}, },
direction = ctx.udata.player.direction_lerp, direction = ctx.udata.player.direction_lerp,
} }