Advertisement
IssyPutchy

Shooter game - Code Golf

Dec 13th, 2019
461
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.46 KB | None | 0 0
  1. -- Game start
  2.  
  3. tweens.bullet_y = 180
  4. var_s_bullet_x = 0
  5.  
  6. var_zone = 15
  7.  
  8. var_s_target_a_x = math.random(-200,200)
  9. var_s_target_a_y = math.random(-200,200)
  10.  
  11. function ship_pos()
  12.  var_ms_ship_x_pos = wm_tag(-{sax})*19
  13. end
  14.  
  15. function bullet()
  16.  wm_schedule {
  17.    { action='tween', tween='bullet_y', from=180, to=-250, duration=1, easing=linear },
  18.  }
  19. end
  20.  
  21. var_ms_score = 0
  22.  
  23. function on_millisecond(dt)
  24.  ship_pos()
  25.   if (var_s_target_a_x >= (var_ms_ship_x_pos - var_zone) and var_s_target_a_x <= (var_ms_ship_x_pos + var_zone)) then
  26.    var_ms_x_hit = 1
  27.   else
  28.    var_ms_x_hit = 0
  29.   end
  30.  if (var_s_target_a_y >= (tweens.bullet_y - var_zone) and var_s_target_a_y <= (tweens.bullet_y + var_zone)) then
  31.   var_ms_y_hit = 1
  32.  else
  33.   var_ms_y_hit = 0
  34.  end
  35.  if (var_ms_x_hit == 1 and var_ms_y_hit == 1) then
  36.   var_ms_score = var_ms_score + 1
  37.   wm_vibrate(1,30)
  38.   bullet()
  39.  end
  40.  if (var_s_target_a_x >= (var_ms_ship_x_pos - var_zone) and var_s_target_a_x <= (var_ms_ship_x_pos + var_zone) and var_s_target_a_y > 160 ) then
  41.   var_ms_score = var_ms_score - 5
  42.   wm_vibrate(1,50)
  43.  end
  44. end
  45.  
  46. function on_second(h,m,s)
  47.   if s%3==0 then
  48.    var_s_target_a_x = math.random(-200,200)
  49.    var_s_target_a_y = math.random(-200,200)
  50.   end
  51.  var_s_bullet_x = var_ms_ship_x_pos
  52.  bullet()
  53. end
  54.  
  55. function on_display_bright()
  56.  var_ms_score = 0
  57. end
  58.  
  59. var_highscore = 0
  60. function on_display_not_bright()
  61.  if var_ms_score > var_highscore then
  62.    var_highscore = var_ms_score
  63.  end
  64. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement