Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.71 KB | None | 0 0
  1. function _init()
  2.     frame = 0
  3.     boss = create_enemy(nil, STAGE_CENTER_X, STAGE_TOP + 40)
  4.    
  5.     boss:set_movement_decelerating(STAGE_CENTER_X, STAGE_TOP + 120, 90)
  6.    
  7.     count = 0
  8.     bangle = 0
  9.     distance_x = 90
  10.     distance_y = 90
  11. end
  12.  
  13. function _update()
  14.    
  15.     count = count + 1
  16.    
  17.     if(count == 30) then
  18.         count = 0
  19.     end
  20.  
  21.     if(frame % 360 >= 90 and frame % 2 == 1) then -- shoots leaves
  22.         leaf = create_bullet(1000, boss.x + distance_x * maths.sin(PI * count / 15), boss.y + distance_y * maths.cos(PI * (count / 15)), { colour1 = { 0.0, 1.0, 0.0 }, angle = bangle, velocity = 1})
  23.         bangle = bangle + PI / 1.3495
  24.         distance_x = distance_x - 1
  25.         distance_y = distance_y - 1
  26.     end
  27.    
  28.     if(frame % 360 == 30 and frame > 30) then -- shoots aimeds
  29.         for j = 1, 5, 1 do
  30.             for i = 1, 9, 1 do
  31.                 local aimed = create_bullet(0, boss.x, boss.y, {velocity = 0.5, acceleration = 0.001 * j, colour2 = { 0.0, 0.0, 1.0 }})
  32.                 aimed:set_angle_to(player_x(), player_y())
  33.                 aimed.angle = aimed.angle + (i * 0.07 * PI) - 0.35 * PI
  34.             end
  35.         end
  36.     end
  37.        
  38.    
  39.     if(frame > 0 and frame % 360 == 0) then -- boss moves, shit resets
  40.         move()
  41.         distance_x = 90
  42.         distance_y = 90
  43.     end
  44.    
  45.     frame = frame + 1
  46. end
  47.    
  48. function move()
  49.     local left = STAGE_LEFT + 48.0
  50.     local right = STAGE_RIGHT - 48.0
  51.     local top = STAGE_TOP + 96.0
  52.     local bottom = STAGE_TOP + 150.0
  53.     local xd = random(40.0, 80.0)
  54.     local yd = random(-40.0, 40.0)
  55.     local x;
  56.     if(player_x() < boss.x) then
  57.         x = boss.x - xd
  58.     else
  59.         x = boss.x + xd
  60.     end
  61.     if(x < left) then
  62.         x = boss.x + xd
  63.     elseif(x > right) then
  64.         x = boss.x - xd
  65.     end
  66.     local y = boss.y + yd
  67.     if(y < top) then
  68.         y = top
  69.     elseif(y > bottom) then
  70.         y = bottom
  71.     end
  72.     boss:set_movement_decelerating(x, y, 90)
  73. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement