Advertisement
mainland_china

Key and Key Spawner

Dec 19th, 2023
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Game Maker 2.35 KB | Source Code | 0 0
  1. Key Spawner
  2. --------------------------
  3. ~create
  4.  
  5. arr_size = 10;
  6. rrange = 9;
  7. numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
  8.             //number of keys
  9. for (var i = 0; i < 3; i++) {
  10.     spawn = irandom(rrange);
  11.     switch(numbers[spawn]){
  12.         case 0:
  13.             instance_create_layer(304, 416, "keys", obj_key14);
  14.             instance_create_layer(304, 416, "key_light", obj_key_light);
  15.         break;
  16.         case 1:
  17.             instance_create_layer(335, 367, "keys", obj_key14);
  18.             instance_create_layer(335, 367, "key_light", obj_key_light);
  19.         break;
  20.         case 2:
  21.             instance_create_layer(335, 462, "keys", obj_key14);
  22.             instance_create_layer(335, 462, "key_light", obj_key_light);
  23.         break;
  24.         case 3:
  25.             instance_create_layer(271, 367, "keys", obj_key14);
  26.             instance_create_layer(271, 367, "key_light", obj_key_light);
  27.         break;
  28.         case 4:
  29.             instance_create_layer(271, 462, "keys", obj_key14);
  30.             instance_create_layer(271, 461, "key_light", obj_key_light);
  31.         break;
  32.         case 5:
  33.             instance_create_layer(271, 622, "keys", obj_key14);
  34.             instance_create_layer(271, 622, "key_light", obj_key_light);
  35.         break;
  36.         case 6:
  37.             instance_create_layer(271, 175, "keys", obj_key14);
  38.             instance_create_layer(271, 175, "key_light", obj_key_light);
  39.         break;
  40.         case 7:
  41.             instance_create_layer(334, 239, "keys", obj_key14);
  42.             instance_create_layer(334, 239, "key_light", obj_key_light);
  43.         break;
  44.         case 8:
  45.             instance_create_layer(334, 623, "keys", obj_key14);
  46.             instance_create_layer(334, 623, "key_light", obj_key_light);
  47.         break;
  48.         case 9:
  49.             instance_create_layer(464, 430, "keys", obj_key14);
  50.             instance_create_layer(464, 430, "key_light", obj_key_light);
  51.         break;
  52.     }
  53.     rrange--;
  54.     arr_size--;
  55.     array_delete(numbers, spawn, 1);
  56.     array_resize(numbers, arr_size);
  57.  
  58.     image_xscale = 0.5;
  59.     image_yscale = 0.5;
  60. }
  61.  
  62.  
  63. Actual Key
  64. ----------------
  65. Create
  66. image_xscale = 0.5;
  67. image_yscale = 0.5;
  68. timer = 0;
  69. frequency = 0.1;
  70. amplitude = 0.3;
  71.  
  72. Step
  73. y = y + sin(timer*frequency)*amplitude;
  74. timer++;
  75.  
  76. Collision with player
  77. audio_sound_pitch(snd_close, 1.5);
  78. audio_play_sound(snd_close, 8, false);
  79. instance_destroy(self);
  80.  
  81. obj_player.keys++;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement