2 Commits

Author SHA1 Message Date
6be3fd51b0 Player can only walk into pit if they want to 2022-12-20 21:57:22 -08:00
d2ee3d2078 Rewrite rope (#11)
Rope rewrite, part one

We should only care about anchors on the old path

Add comment expressing uncertainty

Add further algo notes

One final note

Well, this is closer to right!!

Elide points as needed

Save current changes

First version I couldn't immediately break

Everything _seems_ to work

Clean up some residual messes

Tidy up more loose ends

Co-authored-by: Nyeogmi <economicsbat@gmail.com>
Reviewed-on: #11
2022-12-21 05:44:15 +00:00

View File

@ -601,6 +601,9 @@ function level:can_move(
if is_player and self:win_at(mx0+dmx,my0+dmy) then
return true
end
if is_player and self:get_open_pit(mx0+dmx,my0+dmy) then
return wrongbleep:adequately_warned()
end
if self:mcoll(mx0+dmx,my0+dmy) then
return false
@ -768,7 +771,7 @@ function player:update()
}}
elseif kbd:btnp(5) then
if self.rope!=nil then
if (not self.rope:tug()) wrongbleep:bleep(7)
if (not self.rope:tug()) wrongbleep:bleep(9)
end
end
end
@ -812,8 +815,9 @@ function player:_fall()
end
function player:draw()
local px=self.x*8+self.px
local py=self.y*8+self.py
local px=self.x*8+self.px+wrongbleep:vibrate()
local py=self.y*8+self.py+wrongbleep:vibrate()
local head=1-self.orienty
@ -911,7 +915,7 @@ function rope:update()
if (self.state.frame>=3) self.state={name="latched"}
elseif self.state.name=="latched" then
if (self.latch==nil) wrongbleep:bleep(3) self:destroy() return
if (self.latch==nil) wrongbleep:bleep(5) self:destroy() return
if
self.latch!=nil and
@ -1598,15 +1602,24 @@ wrongbleep={}
add(real_modules,wrongbleep)
function wrongbleep:init()
self.duration=0
self.continuous=0
end
function wrongbleep:update()
if (self.duration>5) self.duration=5
if (self.duration>0) sfx(63,3)
self.duration=max(self.duration-1,-2)
if self.duration>0 then sfx(63,3) self.continuous+=1
else self.continuous=0 end
self.duration=max(self.duration-1,-4)
end
function wrongbleep:bleep(duration)
self.duration+=duration or 2
end
function wrongbleep:vibrate(duration)
if (self.continuous<10) return 0
return (rnd()*2-1)*min(self.continuous/10,2)
end
function wrongbleep:adequately_warned(duration)
return self.continuous>45
end
__gfx__