Update RainbowShotsFromOuterSpace
added indentation and more comments
This commit is contained in:
parent
0dba3fc3ea
commit
a9e0be9545
|
@ -2,7 +2,9 @@
|
|||
--hold the random function and the value 128
|
||||
웃=rnd 😐=128
|
||||
enemies={}
|
||||
player_x=62♥=3◆=1✽={}function g(a,b,c,f)return abs(a-c)+abs(b-f)end
|
||||
player_x=62♥=3◆=1✽={}
|
||||
--quick little distance function
|
||||
function distance(a,b,c,f)return abs(a-c)+abs(b-f)end
|
||||
function _draw()
|
||||
--the game logic if statement instead of a state machine
|
||||
--encompasses all game logic
|
||||
|
@ -19,7 +21,7 @@ for j in all(enemies)do
|
|||
--move them down
|
||||
j.y+=1
|
||||
--check whether they touched the player
|
||||
if g(j.x,j.y,player_x,99)<5 do
|
||||
if distance(j.x,j.y,player_x,99)<5 do
|
||||
--move them off screen if they do instead of spending tokens on del()-
|
||||
--i do that later
|
||||
j.x=-9
|
||||
|
@ -35,7 +37,8 @@ for i in all(✽)do
|
|||
--move the shots up
|
||||
i.y-=1
|
||||
--check wheter they've hit any enemies,pushing them offscreen if needed
|
||||
if(g(i.x,i.y,j.x,j.y)<6)del(✽,i)j.x=-9◆+=1end
|
||||
if(distance(i.x,i.y,j.x,j.y)<6)del(✽,i) j.x=-9 ◆+=1
|
||||
end
|
||||
--finally deleting the enemies that have gotten below the screen height,on or off screen
|
||||
if(j.y>😐)del(enemies,j)
|
||||
--draw the enemies
|
||||
|
|
Loading…
Reference in New Issue