Guest User

Safety Room source code

a guest
Dec 11th, 2016
73
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Player movement script:
  2. hsp = (keyboard_check(ord('D')) - keyboard_check(ord('A'))) * spd;
  3.  
  4. if place_meeting(x,y+1,obj_solid) {
  5. vsp = keyboard_check(vk_space) * -jsp;
  6. }
  7.  
  8. if place_meeting(x+(hsp / 3.5),y,obj_solid) {
  9. vsp = (keyboard_check(vk_space) * -jsp)
  10. }
  11. if vsp < 10 {
  12. vsp += grav;
  13. }
  14.  
  15. if place_meeting(x+hsp,y,obj_solid) {
  16. while !place_meeting(x+sign(hsp),y,obj_solid) {
  17. x += sign(hsp)
  18. }
  19. hsp = 0;
  20. }
  21. x += hsp;
  22.  
  23. if place_meeting(x,y+vsp,obj_solid) {
  24. while !place_meeting(x,y+sign(vsp),obj_solid) {
  25. y += sign(vsp)
  26. obj_camera.shake = vsp;
  27. sound_play(snd_hit)
  28. }
  29. vsp = 0;
  30. }
  31. y += vsp;
  32.  
  33. player animation script:
  34. if place_meeting(x,y+1,obj_solid) {
  35. sprite_index = spr_player_walk;
  36. if hsp = 0 {
  37. sprite_index = spr_player_jump;
  38. }
  39. }
  40. else {
  41. if vsp > 0 {
  42. sprite_index = spr_player_jump;
  43. }
  44. else if vsp < 0 {
  45. sprite_index = spr_player_fall;
  46. }
  47. }
  48.  
  49. if hsp < 0 {
  50. image_xscale = -1;
  51. }
  52. else if hsp > 0 {
  53. image_xscale = 1;
  54. }
  55.  
  56. gun script:
  57. if mouse_check_button_pressed(1) {
  58. instance_create(x,y,obj_bullet_p)
  59. }
  60.  
  61. sound script:
  62. if place_meeting(x+hsp / 3.5,y,obj_solid) && vsp < 0 {
  63. //sound_play(snd_slide);
  64. }
  65. if place_meeting(x,y+2,obj_solid) && vsp < 0 {
  66. sound_play(snd_jump);
  67. }
  68.  
  69. player dead script:
  70. //death animation (explosion?!?!)
  71. //delete player object
  72. //stop music (main_theme)
  73. //play music (death_theme)
  74. //create retry button (either this level or the first level... depends on difficulty nad length of the gmae...)
  75. sprite_index = spr_player_death
  76. instance_create(x,y,obj_retry)
  77. instance_create(x,y,obj_explosion)
  78. if death_timer = 0 {
  79. instance_destroy()
  80. }
  81. if death_timer > 0 {
  82. death_timer -=1;
  83. }
  84. sound_stop(main_theme)
  85. sound_play(death_theme)
  86.  
  87. camera:
  88. if instance_exists(obj_player) {
  89. view_xview[0] = obj_player.x - (view_wview / 2)
  90. view_yview[0] = obj_player.y - (view_hview / 2)
  91. }
  92. else {
  93. view_xview = view_xview;
  94. view_yview = view_yview;
  95. }
  96.  
  97. if view_xview < 0 {
  98. view_xview = 0;
  99. }
  100. else if view_xview + view_wview > room_width {
  101. view_xview = room_width - view_wview
  102. }
  103.  
  104. if view_yview < 0 {
  105. view_yview = 0;
  106. }
  107. else if view_yview + view_hview > room_height {
  108. view_yview = room_height - view_hview
  109. }
  110. view_xview += random_range(-shake,shake);
  111. view_yview += random_range(-shake,shake);
  112. shake *= 0.9;
  113.  
  114. turret:
  115. if shoot_timer > 0 {
  116. shoot_timer -= 1;
  117. }
  118. if shoot_timer = 0 {
  119. if dir = 1 {
  120. instance_create(x,y,obj_bullet_t_d)
  121. }
  122. else if dir = 2{
  123. instance_create(x,y,obj_bullet_t_r)
  124. }
  125. else if dir = 3 {
  126. instance_create(x,y,obj_bullet_t_u)
  127. }
  128. else if dir = 4 {
  129. instance_create(x,y,obj_bullet_t_l)
  130. }
  131. else {
  132. instance_create(x,y,obj_bullet_t_d)
  133. }
  134. shoot_timer = 30;
  135. }
  136.  
  137. //Managing the image rotation
  138. if dir = 1 {
  139. image_angle = 0;
  140. }
  141. else if dir = 2 {
  142. image_angle = 90;
  143. }
  144. else if dir = 3 {
  145. image_angle = 180;
  146. }
  147. else if dir = 4 {
  148. image_angle = 270;
  149. }
  150.  
  151. gun:
  152. scr_gun_shoot()
  153.  
  154. direction = point_direction(x,y,mouse_x,mouse_y)
  155. image_angle = direction;
  156. if instance_exists(obj_player) {
  157. x = obj_player.x;
  158. y = obj_player.y;
  159.  
  160. if mouse_x > x {
  161. image_yscale = 1;
  162. }
  163. else {
  164. image_yscale = -1;
  165. }
  166. }
  167. else {
  168. instance_destroy()
  169. }
  170.  
  171. explosions:
  172. if death_timer = 0 {
  173. instance_destroy()
  174. }
  175. else {
  176. death_timer -= 1;
  177. }
  178.  
  179. Portraits:
  180. portrait = irandom(7)
  181.  
  182. if portrait = 0 {
  183. sprite_index = spr_portrait_1;
  184. }
  185. else if portrait = 1 {
  186. sprite_index = spr_portrait_2;
  187. }
  188. else if portrait = 2 {
  189. sprite_index = spr_portrait_3;
  190. }
  191. else if portrait = 3 {
  192. sprite_index = spr_portrait_4;
  193. }
  194. else if portrait = 4 {
  195. sprite_index = spr_portrait_5;
  196. }
  197. else if portrait = 5 {
  198. sprite_index = spr_portrait_6;
  199. }
  200. else if portrait = 6 {
  201. sprite_index = spr_portrait_7;
  202. }
  203. else if portrait = 7 {
  204. sprite_index = spr_portrait_8;
  205. }
  206.  
  207. title screen:
  208. sound_play(title_theme);
  209. screen = 0;
  210.  
  211. if keyboard_check_pressed(vk_enter || vk_space) {
  212. sprite_index = spr_titlescreen;
  213. screen = 1;
  214. }
RAW Paste Data