translate๐บ.labels,๐ฎ.โ,[[*๐ฎ.๐ค.๐(๐ฎ.โ๏ธ)].move!([0,๐ฎ.โ๏ธ*2]),"Your Last score is #{LAST}",0,1,GOLD]unlessLAST==0||๐ฎ.๐!=[0,0]
#Draw starting message, only if Direction is 0
translate๐บ.labels,๐ฎ.โ,[๐ฎ.๐ค.๐(๐ฎ.โ๏ธ),"Press any Arrow key to start",0,1,GOLD]unless๐ฎ.๐!=[0,0]
end
definput๐ฎ,๐น
#Left and Right keyboard input, only change if X direction is 0
if๐น.keyboard.key_held.left&&๐ฎ.๐.x==0
๐ฎ.๐ฆ=[-1,0]
elsif๐น.keyboard.key_held.right&&๐ฎ.๐.x==0
๐ฎ.๐ฆ=[1,0]
end
#Up and Down keyboard input, only change if Y direction is 0
if๐น.keyboard.key_held.up&&๐ฎ.๐.y==0
๐ฎ.๐ฆ=[0,1]
elsif๐น.keyboard.key_held.down&&๐ฎ.๐.y==0
๐ฎ.๐ฆ=[0,-1]
end
end
defdefaults๐ฎ
#Playing field size
๐ฎ.๐บ||=[20,20]
#Scale for drawing, screen height / Field height
๐ฎ.โ๏ธ||=720/๐ฎ.๐บ.y
#Offset, offset all rendering to the center of the screen
๐ฎ.โ||=[(1280-720).fdiv(2),0]
#Padding, make the snake body slightly smaller than the scale
๐ฎ.๐ถ||=(๐ฎ.โ๏ธ*0.2).to_i
#Snake Size
๐ฎ.๐||=3
#Snake head, the only part we are actually controlling
๐ฎ.๐ค||=[๐ฎ.๐บ.x/2,๐ฎ.๐บ.y/2]
#Snake body map, follows the head
๐ฎ.๐||=[]
#Direction the head moves to
๐ฎ.๐||=[0,0]
#Next_Direction, during input check only change this variable and then when game updates asign this to Direction