Advertisement
Guest User

obj_en_plat New Step Code

a guest
Jun 29th, 2013
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* AESTHETICS */
  2. thr=scr_basicshot(x,y,obj_en_thr,random_range(3,5),random_range(direction+100,direction+260));
  3. thr.image_xscale = 4;
  4. thr.image_yscale = 4;
  5. thr.image_angle = random(360);
  6.  
  7. /* CREATION OF TURRETS */
  8. if y > yview-(sprite_height/2) && made = 0
  9.     {
  10.     // Creation of turrets
  11.     tur1 = instance_create(x-18,y-18,obj_en_platTUR);// Top-left
  12.     tur2 = instance_create(x+18,y-18,obj_en_platTUR);// Top-right
  13.     tur3 = instance_create(x-18,y+18,obj_en_platTUR);// Bottom-left
  14.     tur4 = instance_create(x+18,y+18,obj_en_platTUR);// Bottom-right
  15.     tur1.parent = (self).id;
  16.     tur2.parent = (self).id;
  17.     tur3.parent = (self).id;
  18.     tur4.parent = (self).id;
  19.     tur_count = 4;
  20.     made = 1;
  21.     }
  22.  
  23. /* POSITIONING OF TURRETS */
  24. if made = 1
  25.     {
  26.     tur1.x = x - 18; // Top-left
  27.     tur1.y = y - 18;
  28.     tur2.x = x + 18; // Top-right
  29.     tur2.y = y - 18;
  30.     tur3.x = x - 18; // Bottom-left
  31.     tur3.y = y + 18;
  32.     tur4.x = x + 18; // Bottom-right
  33.     tur4.y = y + 18;
  34.     }
  35.  
  36. /* ATTACK PATTERNS */
  37. if tur_count > 0
  38.     {
  39.     // Pattern Duration/Reset of timers
  40.     timer += 1;
  41.     atk_timer += 1;
  42.     if timer = 120
  43.         {
  44.         timer = 0;
  45.         atk_timer = 0;
  46.         if atk_phase = 1 then atk_phase = 2 else atk_phase = 1;
  47.         }
  48.    
  49.     // First Pattern
  50.     if atk_phase = 1
  51.         {
  52.         if atk_timer = 30
  53.             {
  54.             with tur1 event_user(1);
  55.             with tur2 event_user(1);
  56.             with tur3 event_user(1);
  57.             with tur4 event_user(1);
  58.             scr_playsnd(global.enemyshot2,1);
  59.             atk_timer = -30; // 90 steps after first call
  60.             }
  61.         }
  62.    
  63.     // Second Pattern
  64.     if atk_phase = 2
  65.         {
  66.         if atk_timer = 4
  67.             {
  68.             with tur1 event_user(2);
  69.             with tur2 event_user(2);
  70.             with tur3 event_user(2);
  71.             with tur4 event_user(2);
  72.             scr_playsnd(global.enemyshot1,1);
  73.             atk_timer = 0;
  74.             }
  75.         }
  76.     }
  77.    
  78. // Final pattern - Only occurs if all turrets are destroyed
  79. if tur_count = 0
  80.     {
  81.     timer += 1;
  82.     if timer >= 4
  83.         {
  84.         scr_playsnd(global.enemyshot3,1);
  85.         scr_basicshot(x,y,obj_bullet4,4,aim);
  86.         aim += 45;
  87.         if aim >= 360 then aim = 0;
  88.         timer = 0;
  89.         }
  90.     }    
  91.  
  92. /* MOVEMENT BEHAVIOUR */
  93. switch phase
  94.     {
  95.     case 1: // Moving down
  96.         {
  97.         if y > yview+160
  98.             {
  99.             // if x == 160 do nothing
  100.             if x > 160 then direction = 180;
  101.             if x < 160 then direction = 0;
  102.             speed = 1;
  103.             phase = 2;
  104.             }
  105.         break;
  106.         }
  107.     case 2: // Moving left/right
  108.         {
  109.         if x < 40 || x > 280
  110.             {
  111.             direction = 90;
  112.             speed = 0.5;
  113.             phase = 3;
  114.             }
  115.         break;
  116.         }
  117.     case 3: // Moving up, then left/right
  118.         {
  119.         if y < yview+40
  120.             {
  121.             if x > 160 then direction = 0;
  122.             if x < 160 then direction = 180;
  123.             speed = 0.35;
  124.             }
  125.         break;
  126.         }
  127.     }
  128.    
  129. /* DEATH HANDLING */
  130. if x < -(sprite_width/2)
  131. || x > 320+(sprite_width/2)
  132. || y > yview+320+(sprite_height/2)
  133. then instance_destroy();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement