mirror of
https://github.com/DramaticShape/DramaticShapeVoxelMod.git
synced 2026-08-12 07:50:53 +02:00
add third person mode
This commit is contained in:
+30
-10
@@ -1,11 +1,16 @@
|
||||
-- Voxel world mode: free movement for the first-person rung.
|
||||
-- Voxel world mode: free movement for the free-roam rungs.
|
||||
--
|
||||
-- The engine walks a grid: sixteen frames per cell, four directions,
|
||||
-- input locked mid-step. Inside a first-person camera that gait reads as
|
||||
-- riding a rail, so while 1ST drives, this module replaces the WALK and
|
||||
-- nothing else: the player's position becomes continuous, steered by the
|
||||
-- camera's own yaw -- push forward and you go where you look, at any
|
||||
-- angle, sliding along whatever you graze.
|
||||
-- input locked mid-step. Inside a camera that stands with the player that
|
||||
-- gait reads as riding a rail, so while 1ST or 3RD drives, this module
|
||||
-- replaces the WALK and nothing else: the player's position becomes
|
||||
-- continuous, steered by the camera's own yaw -- push forward and you go
|
||||
-- where you look, at any angle, sliding along whatever you graze.
|
||||
--
|
||||
-- Both rungs walk identically: the boom behind the shoulder (3RD) changes
|
||||
-- where the eye stands, not which way it points, and the walk was always
|
||||
-- rotated by the YAW. The one thing it does change is which way the body
|
||||
-- POINTS while it moves -- see bodyFacing in the tick.
|
||||
--
|
||||
-- THE GRID IS STILL THE GAME. Every fact the world cares about is a fact
|
||||
-- about cells -- what blocks, what warps, what rustles, what bites -- and
|
||||
@@ -73,6 +78,11 @@ end
|
||||
|
||||
function FreeMove.drop()
|
||||
pos = nil
|
||||
-- and the body with it: while something else is walking the player --
|
||||
-- a scripted move, a ledge hop, the grid walk off the rung -- the
|
||||
-- engine's own four-direction facing is the whole truth about which way
|
||||
-- they point, so the card must stop reading our finer one
|
||||
FirstPerson.releaseBody()
|
||||
end
|
||||
|
||||
-- named for the suite: the module's live position, nil while dropped
|
||||
@@ -231,8 +241,12 @@ function FreeMove.tick(state)
|
||||
local input = Game.input
|
||||
|
||||
-- the head is the facing: what A talks to, what the sun's card shows,
|
||||
-- which way a bonk points
|
||||
p.facing = FirstPerson.compassFacing()
|
||||
-- which way a bonk points. (A body that is WALKING may turn along its
|
||||
-- travel instead -- see below, once there is a travel to turn along; a
|
||||
-- standing one always faces where the camera looks, which is what makes
|
||||
-- A predictable.) pointBody rather than compassFacing, so the card also
|
||||
-- gets the CONTINUOUS bearing behind that compass point.
|
||||
p.facing = FirstPerson.pointBody(0, 0)
|
||||
|
||||
if input:wasPressed("a") then
|
||||
state:interact()
|
||||
@@ -266,6 +280,12 @@ function FreeMove.tick(state)
|
||||
|
||||
if not moving then return end
|
||||
|
||||
-- and once there IS a direction of travel, the body may point along it
|
||||
-- rather than along the head: on the boom (3RD) you can see yourself, so
|
||||
-- a strafe has to look like walking sideways. In the head it is the head
|
||||
-- either way -- bodyBearing says so.
|
||||
p.facing = FirstPerson.pointBody(wx, wz)
|
||||
|
||||
state.bumpCooldown = math.max(0, (state.bumpCooldown or 0) - 1)
|
||||
|
||||
local speed = (Game.save and Game.save.onBike) and FreeMove.BIKE
|
||||
@@ -307,8 +327,8 @@ function FreeMove.tick(state)
|
||||
FreeMove.drop()
|
||||
return
|
||||
end
|
||||
-- the push handlers may have turned the facing; the head still rules
|
||||
p.facing = FirstPerson.compassFacing()
|
||||
-- the push handlers may have turned the facing; the walk still rules
|
||||
p.facing = FirstPerson.pointBody(wx, wz)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user