diff --git a/vacation.p8 b/vacation.p8 index 7dca67f..3f5eeed 100644 --- a/vacation.p8 +++ b/vacation.p8 @@ -473,25 +473,33 @@ phinstate_nrm = { ws=3, hs=2, p=phin_nrm_pal, - floaty=true, + idle=true, + xo=-12, + yo=-8, } phinstate_jump_full = { s={7}, ws=2, hs=3, p=phin_nrm_pal, + xo=-4, + yo=-8, } phinstate_jump_wane = { s={1}, ws=3, hs=3, p=phin_nrm_pal, + xo=-12, + yo=-8, } phinstate_crest = { s={4}, ws=3, hs=2, p=phin_nrm_pal, + xo=-12, + yo=-8, } phinstate_fall_wax = phinstate_jump_wane phinstate_fall_full = phinstate_jump_full @@ -500,26 +508,34 @@ phinstate_dive_full = { ws=2, hs=3, p=phin_uw_pal, + xo=-4, + yo=-16, } phinstate_dive_wane = { s={1}, ws=3, hs=3, p=phin_uw_pal, + xo=-12, + yo=-16, } phinstate_return = { s={4}, ws=3, hs=2, p=phin_uw_pal, + xo=-12, + yo=-8, } phinstate_rise_wax = phinstate_dive_wane phinstate_rise_full = phinstate_dive_full - +-- coordinates are the notional +-- center point of the dolphin. +-- many states are off-center. toyphin = { - x=-24, - y=56, + x=-12, + y=64, dy=0, state=phinstate_nrm } @@ -529,18 +545,45 @@ function toyphin:update() -- entry mode? if not self.entered then 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. - -- prepare for collision detection - self.w=self.state.ws*8 - self.h=self.state.hs*8 + + -- button handling + 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 function toyphin:draw() local st, y = self.state, self.y - if (st.floaty) y += wave() - spr(st.s[1+(((t()<<1)&0x0.FFFF*#st.s)&0x7FFF)], self.x, y, self.state.ws, self.state.hs) + if (st.idle) y += wave() + 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 -->8