midpoint based dolphin positioning
This commit is contained in:
parent
e6c48029a4
commit
61c462d560
65
vacation.p8
65
vacation.p8
@ -473,25 +473,33 @@ phinstate_nrm = {
|
|||||||
ws=3,
|
ws=3,
|
||||||
hs=2,
|
hs=2,
|
||||||
p=phin_nrm_pal,
|
p=phin_nrm_pal,
|
||||||
floaty=true,
|
idle=true,
|
||||||
|
xo=-12,
|
||||||
|
yo=-8,
|
||||||
}
|
}
|
||||||
phinstate_jump_full = {
|
phinstate_jump_full = {
|
||||||
s={7},
|
s={7},
|
||||||
ws=2,
|
ws=2,
|
||||||
hs=3,
|
hs=3,
|
||||||
p=phin_nrm_pal,
|
p=phin_nrm_pal,
|
||||||
|
xo=-4,
|
||||||
|
yo=-8,
|
||||||
}
|
}
|
||||||
phinstate_jump_wane = {
|
phinstate_jump_wane = {
|
||||||
s={1},
|
s={1},
|
||||||
ws=3,
|
ws=3,
|
||||||
hs=3,
|
hs=3,
|
||||||
p=phin_nrm_pal,
|
p=phin_nrm_pal,
|
||||||
|
xo=-12,
|
||||||
|
yo=-8,
|
||||||
}
|
}
|
||||||
phinstate_crest = {
|
phinstate_crest = {
|
||||||
s={4},
|
s={4},
|
||||||
ws=3,
|
ws=3,
|
||||||
hs=2,
|
hs=2,
|
||||||
p=phin_nrm_pal,
|
p=phin_nrm_pal,
|
||||||
|
xo=-12,
|
||||||
|
yo=-8,
|
||||||
}
|
}
|
||||||
phinstate_fall_wax = phinstate_jump_wane
|
phinstate_fall_wax = phinstate_jump_wane
|
||||||
phinstate_fall_full = phinstate_jump_full
|
phinstate_fall_full = phinstate_jump_full
|
||||||
@ -500,26 +508,34 @@ phinstate_dive_full = {
|
|||||||
ws=2,
|
ws=2,
|
||||||
hs=3,
|
hs=3,
|
||||||
p=phin_uw_pal,
|
p=phin_uw_pal,
|
||||||
|
xo=-4,
|
||||||
|
yo=-16,
|
||||||
}
|
}
|
||||||
phinstate_dive_wane = {
|
phinstate_dive_wane = {
|
||||||
s={1},
|
s={1},
|
||||||
ws=3,
|
ws=3,
|
||||||
hs=3,
|
hs=3,
|
||||||
p=phin_uw_pal,
|
p=phin_uw_pal,
|
||||||
|
xo=-12,
|
||||||
|
yo=-16,
|
||||||
}
|
}
|
||||||
phinstate_return = {
|
phinstate_return = {
|
||||||
s={4},
|
s={4},
|
||||||
ws=3,
|
ws=3,
|
||||||
hs=2,
|
hs=2,
|
||||||
p=phin_uw_pal,
|
p=phin_uw_pal,
|
||||||
|
xo=-12,
|
||||||
|
yo=-8,
|
||||||
}
|
}
|
||||||
phinstate_rise_wax = phinstate_dive_wane
|
phinstate_rise_wax = phinstate_dive_wane
|
||||||
phinstate_rise_full = phinstate_dive_full
|
phinstate_rise_full = phinstate_dive_full
|
||||||
|
|
||||||
|
-- coordinates are the notional
|
||||||
|
-- center point of the dolphin.
|
||||||
|
-- many states are off-center.
|
||||||
toyphin = {
|
toyphin = {
|
||||||
x=-24,
|
x=-12,
|
||||||
y=56,
|
y=64,
|
||||||
dy=0,
|
dy=0,
|
||||||
state=phinstate_nrm
|
state=phinstate_nrm
|
||||||
}
|
}
|
||||||
@ -529,18 +545,45 @@ function toyphin:update()
|
|||||||
-- entry mode?
|
-- entry mode?
|
||||||
if not self.entered then
|
if not self.entered then
|
||||||
self.x += 1
|
self.x += 1
|
||||||
self.entered = self.x >= 4
|
self.entered = self.x >= 16
|
||||||
|
elseif self.exiting then
|
||||||
|
if self.x > 128 then
|
||||||
|
self.exited = true
|
||||||
|
else
|
||||||
|
self.x += 1
|
||||||
end
|
end
|
||||||
-- TODO: switch states, do physics, etc.
|
end
|
||||||
-- prepare for collision detection
|
|
||||||
self.w=self.state.ws*8
|
-- button handling
|
||||||
self.h=self.state.hs*8
|
if self.entered and not self.exiting and not self.launching then
|
||||||
|
if self.state.idle then
|
||||||
|
--TODO: launch
|
||||||
|
else
|
||||||
|
--TODO: nudge momentum
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if self.launching then
|
||||||
|
--TODO: advance launch mode
|
||||||
|
end
|
||||||
|
|
||||||
|
--TODO: gravity
|
||||||
|
--TODO: crossing 64
|
||||||
|
|
||||||
|
-- test mode
|
||||||
|
--if (btn(5)) self.exiting = true
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
-- hitbox for current state
|
||||||
|
function toyphin:box()
|
||||||
|
local st = self.state
|
||||||
|
return self.x + st.xo, self.y + st.yo, st.ws * 8, st.hs * 8
|
||||||
end
|
end
|
||||||
|
|
||||||
function toyphin:draw()
|
function toyphin:draw()
|
||||||
local st, y = self.state, self.y
|
local st, y = self.state, self.y
|
||||||
if (st.floaty) y += wave()
|
if (st.idle) y += wave()
|
||||||
spr(st.s[1+(((t()<<1)&0x0.FFFF*#st.s)&0x7FFF)], self.x, y, self.state.ws, self.state.hs)
|
spr(st.s[1+(((t()<<1)&0x0.FFFF*#st.s)&0x7FFF)], self.x + st.xo, y + st.yo, self.state.ws, self.state.hs)
|
||||||
end
|
end
|
||||||
|
|
||||||
-->8
|
-->8
|
||||||
|
Loading…
Reference in New Issue
Block a user