/apps/demos/crawl: new tile texture, solid walls
This commit is contained in:
parent
66c525a0d4
commit
b6347996f9
BIN
apps/demos/crawl/data/assets/mossy_rock.png
(Stored with Git LFS)
Normal file
BIN
apps/demos/crawl/data/assets/mossy_rock.png
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -13,19 +13,20 @@
|
||||
-- Defines classes under symbols, which could have properties attached.
|
||||
# stone_wall
|
||||
wall_texture : /assets/brick.png
|
||||
solid : 1
|
||||
. stone_floor
|
||||
tile_texture : /assets/pebbles.png
|
||||
tile_texture : /assets/mossy_rock.png
|
||||
@ player_spawn
|
||||
unique :
|
||||
unique : 1
|
||||
face : south
|
||||
hold : torch
|
||||
tile_texture : /assets/pebbles.png
|
||||
tile_texture : /assets/mossy_rock.png
|
||||
X door
|
||||
open_on_signal : sg_torch0
|
||||
tile_texture : /assets/pebbles.png
|
||||
tile_texture : /assets/mossy_rock.png
|
||||
/ lever
|
||||
on_interact_emit : sg_torch0
|
||||
tile_texture : /assets/pebbles.png
|
||||
tile_texture : /assets/mossy_rock.png
|
||||
|
||||
@meta
|
||||
-- Arbitrary sections could be defined with value pairs.
|
||||
|
@ -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 }
|
||||
end
|
||||
|
||||
local direction = { x = 0, z = 0 }
|
||||
local move = { x = 0, y = 0 }
|
||||
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
|
||||
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
|
||||
|
||||
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.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 {
|
||||
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,
|
||||
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,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user