Small chest

From CC Wiki
Jump to navigationJump to search

Small chests are objects in celeste classic that spawn a berry when a key is collected. during the spawning animation, the chest shakes randomly, which causes the berry to spawn at a random x position.

original code

chest={
	tile=20,
	if_not_fruit=true,
	init=function(this)
		this.x-=4
		this.start=this.x
		this.timer=20
	end,
	update=function(this)
		if has_key then
			this.timer-=1
			this.x=this.start-1+rnd(3)
			if this.timer<=0 then
			 sfx_timer=20
			 sfx(16)
				init_object(fruit,this.x,this.y-4)
				destroy_object(this)
			end
		end
	end
}