Flying strawberries

Flying strawberries, also called winged berries, are a collectible that first appeared in Celeste Classic. They are similar to non-flying strawberries, but they have wings and fly upward once the player dashes.
Original Code
fly_fruit={
tile=28,
if_not_fruit=true,
init=function(this)
this.start=this.y
this.fly=false
this.step=0.5
this.solids=false
this.sfx_delay=8
end,
update=function(this)
--fly away
if this.fly then
if this.sfx_delay>0 then
this.sfx_delay-=1
if this.sfx_delay<=0 then
sfx_timer=20
sfx(14)
end
end
this.spd.y=appr(this.spd.y,-3.5,0.25)
if this.y<-16 then
destroy_object(this)
end
-- wait
else
if has_dashed then
this.fly=true
end
this.step+=0.05
this.spd.y=sin(this.step)*0.5
end
-- collect
local hit=this.collide(player,0,0)
if hit~=nil then
hit.djump=max_djump
sfx_timer=20
sfx(13)
got_fruit[1+level_index()] = true
init_object(lifeup,this.x,this.y)
destroy_object(this)
end
end,
draw=function(this)
local off=0
if not this.fly then
local dir=sin(this.step)
if dir<0 then
off=1+max(0,sign(this.y-this.start))
end
else
off=(off+0.25)%3
end
spr(45+off,this.x-6,this.y-2,1,1,true,false)
spr(this.spr,this.x,this.y)
spr(45+off,this.x+6,this.y-2)
end
}
Glitches
When flying berries flap up and down, they don't follow a perfect cycle due to rounding errors and problems with pico-8's implementation of sin(). Over a very long time, these errors can accumulate and make the berry drift slowly upward. Since the berry's y position is an integer, it will underflow to a positive (lower) y position if the berry drifts any higher than y=-32768. While flying berries also drift slightly in emuulated versions of the game, the drift is much slower, and eventually stops happening altogether; as a result, this is usually considered a PICO-8 only glitch.
This slow drift takes a very long time; it takes 9 years for the berry to underflow. If you can't dash to make it rise back quickly, it takes another 9 years for the flying berry to drift back up into the main map. This glitch is used mainly in minimalist challenge runs, like getting the berry in 700m without jumping. It is also the primary technique in longleste, a challenge to make the longest beatable level.