Guest User

Game Maker - Kirby Abilities Tutorial Codes - Rexfurry

a guest
Jun 14th, 2014
1,702
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. Kirby Create Event:
  2.  
  3. sucking = false
  4. carry = false
  5. fire = false //not used intutorial but explained as to why it's here
  6.  
  7. Kirby Step Event:
  8.  
  9. if (distance_to_object(obj_fire)<100) && sucking = true //sets how far you need to be from the enemy to suck it up
  10. {
  11. obj_fire.suck = true //sets enemies suck variable to true
  12. }
  13. if keyboard_check(vk_left) //just movement, if you have your own you can use that, just make sure to keep the "if carry" section
  14. {
  15. if carry = true
  16. {
  17. hspeed = -3
  18. sprite_index = spr_k_hold
  19. }
  20. else
  21. {
  22. hspeed = -3
  23. sprite_index = spr_k_walk_l
  24. image_speed = 0.5
  25. }
  26. }
  27. if keyboard_check(vk_right)
  28. {
  29. if carry = true
  30. {
  31. hspeed = 3
  32. sprite_index = spr_k_hold
  33. }
  34. else
  35. {
  36. hspeed = 3
  37. sprite_index = spr_k_walk_r
  38. image_speed = 0.5
  39. }
  40. }
  41. if keyboard_check(vk_nokey) //sets regular idle sprite
  42. {
  43. hspeed = 0
  44. sprite_index = spr_k_idle
  45. }
  46. if carry = true //sets idle hold animation for when Kirby has an enemy in his mouth
  47. {
  48. sprite_index = spr_k_hold
  49. }
  50. if keyboard_check_pressed(vk_down) //absorbs enemy
  51. {
  52. if carry = true
  53. {
  54. {
  55. instance_change(obj_kirby_fire,true)
  56. }
  57. }
  58. }
  59.  
  60. Kriby Key Press Space Event:
  61.  
  62. if speed = 0 //Checks to see if you're moving or not so that when you suck in enemies you can't cheat and move whilst doing so
  63. {
  64. sprite_index = spr_k_suck
  65. image_speed = 0.5
  66. sucking = true
  67. if image_index = 4
  68. {
  69. image_speed = 0
  70. }
  71. }
  72.  
  73. Kirby Key Release Space:
  74.  
  75. sucking = false //Turns off the sucking variable
  76. obj_fire.suck = false
  77.  
  78. Fire enemy object (this same rules apply to any other enemies):
  79.  
  80. suck = false //this variable makes it so that the game can tell when the enemy is being sucked
  81.  
  82. Fire enemy Step Event:
  83.  
  84. if suck = true
  85. {
  86. sprite_index = spr_fire_roll
  87. move_towards_point(obj_kirby.x,y,3)
  88. }
  89. else
  90. {
  91. speed = 0
  92. sprite_index = spr_fire
  93. }
  94. if place_meeting(x,y,obj_kirby)
  95. {
  96. if suck = true
  97. {
  98. obj_kirby.carry = true
  99. instance_destroy()
  100. }
  101. }
Advertisement
Add Comment
Please, Sign In to add comment