forked from pyrex/chameleonic
main #21
@ -603,6 +603,7 @@ function player:reinit(x,y)
|
||||
self.x,self.y=x,y
|
||||
self.px,self.py=0,0
|
||||
self.todo={}
|
||||
self.cooldown=4
|
||||
|
||||
self.fall_frame=0
|
||||
|
||||
@ -636,6 +637,10 @@ function player:update()
|
||||
self.orienty=1
|
||||
end
|
||||
|
||||
function btncd(x)
|
||||
return (kbd:btn(x) and self.cooldown==0) or kbd:btnp(x)
|
||||
end
|
||||
|
||||
if kbd:btn(4) then
|
||||
if kbd:btnp(4) and self.rope then
|
||||
self.rope:destroy()
|
||||
@ -643,23 +648,30 @@ function player:update()
|
||||
end
|
||||
-- wait for user to release it
|
||||
else
|
||||
local x,y=self.x,self.y
|
||||
local function try_move(dx,dy,f)
|
||||
if (level:can_move(true,self.x,self.y,dx,dy,0,2)) self.todo=f return
|
||||
if level:can_move(true,x,y,dx,dy,0,2) then
|
||||
self.todo=f
|
||||
self.cooldown=3
|
||||
local t=f[#f]
|
||||
t.x=x+dx
|
||||
t.y=y+dy
|
||||
return
|
||||
end
|
||||
wrongbleep:bleep()
|
||||
end
|
||||
if kbd:btn(0) then
|
||||
try_move(-1,0,{{orientx=-1,orienty=0,px=-2},{px=-7},{x=self.x-1,px=0}})
|
||||
elseif kbd:btn(1) then
|
||||
try_move(1,0,{{orientx=1,orienty=0,px=2},{px=7},{x=self.x+1,px=0}})
|
||||
elseif kbd:btn(2) then
|
||||
try_move(0,-1,{{orienty=-1,py=-2},{py=-7},{y=self.y-1,py=0}})
|
||||
elseif kbd:btn(3) then
|
||||
try_move(0,1,{{orienty=1,py=2},{py=7},{y=self.y+1,py=0}})
|
||||
if btncd(0) then
|
||||
try_move(-1,0,{{orientx=-1,orienty=0,px=-2},{px=1}})
|
||||
elseif btncd(1) then
|
||||
try_move(1,0,{{orientx=1,orienty=0,px=2},{px=-1}})
|
||||
elseif btncd(2) then
|
||||
try_move(0,-1,{{orienty=-1,py=-2},{py=1}})
|
||||
elseif btncd(3) then
|
||||
try_move(0,1,{{orienty=1,py=2},{py=-1}})
|
||||
elseif not self.rope and kbd:btnr(4) then
|
||||
local dx,dy=self.orientx,self.orienty
|
||||
if (dy!=0) dx=0
|
||||
|
||||
local x,y=self.x,self.y
|
||||
while not level:mcoll(x,y) do x+=dx y+=dy end
|
||||
|
||||
self.rope=rope:new(
|
||||
@ -679,7 +691,9 @@ function player:update()
|
||||
end
|
||||
end
|
||||
|
||||
if (#self.todo==0) self.px=0 self.py=0
|
||||
_apply(self,self.todo)
|
||||
if (self.cooldown>0) self.cooldown-=1
|
||||
|
||||
if self.rope then
|
||||
self.rope:update()
|
||||
|
Loading…
Reference in New Issue
Block a user