ÎÌÌÌ̈ˆˆ¬ªªª¬ˆˆˆ¬ÌÌ̬ÌÀ̬ÌÀ̬ÌÀÌÌÌìÌÀÀî̬ÀÌÀ¬ÀÀÀ¬ÀÀÀ¬ÀÀÎÌÌÌ̈ˆˆ¬ªªª¬ˆˆˆ¬ÌÌ̬ÌÌ̬ÌÀ̬ÌÀÌÌÌìÌÀÀî̬ÀÌ̬ÀÀÀ¬ÀÀÀ¬ÀÀ¬ÌÌ̬ªªª¬ª¬ª¬ªÊ̬ªªªŒˆˆˆÌÀÌÎÌÌÎ̬̪ªÀ쬪ÀÀÀÌîÀìîÌÌîî¬ÌÌ̬ªªª¬ª¬ª¬ªÊ̬ªªªŒˆˆˆÌÀÌÎÌÌÎ̬̪ªÀ쬪ÀÀÀÌîÀìîÌÌîî >Z?ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ€ˆˆˆÌÌÌÌ€ˆˆˆ€ˆˆˆ€ˆˆˆ€ˆˆˆ€ˆˆˆ€ˆˆˆ€ˆˆˆ€ˆˆˆ€ˆˆˆ€ˆˆˆ€ˆˆˆ€ˆˆˆ€ˆˆˆ€ˆˆˆ€ˆˆˆ-- title: Sample -- author: AAKASH -- desc: SIMPLE lAYOT -- license: MIT License (change this to your license of choice) -- version: 0.1 -- script: lua --player settings player_x = 64 player_y = 64 player_speed = 2 --bullet settings bullets = {} bullet_speed = 4 --enemy enemies = {} enemy_speed =1 enemy_spawn_timer = 0 --function to move player function move_player() if btn(2) then player_x = player_x - player_speed end if btn(3) then player_x = player_x + player_speed end if btn(0) then player_y = player_y - player_speed end if btn(1) then player_y = player_y + player_speed end end function spawn_enemy() if enemy_spawn_timer == 0 then local enemy = {x = math.random(0,120), y = -10} table.insert(enemies,enemy) enemy_spawn_timer = 60 else enemy_spawn_timer = enemy_spawn_timer - 1 end end function move_enemies() for i,enemy in ipairs(enemies) do enemy.y = enemy.y +enemy_speed if enemy.y >136 then table.remove(enemies,i) end end end --spawn bullet function spawn_bullet() if btnp(4)then local bulet = {x = player_x, y= player_y-4} table.insert(bullets,bullet) end end -- function to move function move_bullets() for i,bullet in ipairs(bullets) do bullet.y = bullet.y - bullet_speed if bullet.y < 0 then table.remove(bullet,i) end end end --collision function check_collisions() for i, bullet in ipairs(bullets) do for j, enemy in ipairs(enemies) do if (bullets.x > enemy.x - 8 and bullet.x < enemy.x + 8) and (bullets.y > enemy.y - 8 and bullet.y < enemy.y + 8) then table.remove(bullets,i) table.remove(enemies,j) break end end end end --main game loop function TIC() move_player() spawn_enemy() move_enemies() spawn_bullet() move_bullets() check_collisions() cls(0) rect(player_x-4,player_y-4,8,8,12) --bullets for _,bullet in ipairs(bullets) do rect(bullet.x -1,bullet.y-2,2,4,7) end --enemy for _,enemy in ipairs(enemies) do rect(enemy.x-4,enemy.y-4,8,8,8) end end