Download
simple platform engine n.
Skip this Video
Loading SlideShow in 5 Seconds..
Simple Platform Engine PowerPoint Presentation
Download Presentation
Simple Platform Engine

Simple Platform Engine

101 Vues Download Presentation
Télécharger la présentation

Simple Platform Engine

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Simple Platform Engine Game Maker 8 For beginner GM users

  2. The Step Event All the real stuff happens in the awesome step event. It also all happens in one simple code block, unless you choose to divide it between others. We should start with moving left/right. // Move Left and Right if keyboard_check(vk_right){ x=x+5; y=y+0; } if keyboard_check(vk_left){ x=x-5; y=y+0; } Let us examine each line of the code! if keyboard_check(vk_right){ This is just like the “Right Pressed” event, it simply checks whether right is pressed. x=x+5; y=y+0; This sets the objects x (horizontal) position to 5 pixels to the right. And not moving the y (vertical) to not move at all. This event is repeated for left pressed.

  3. The Step Event (cont.) Now in most platform games you will want the player to jump, so to do that we just add this simple code! // Jumping Event if keyboard_check(vk_up) { if!(place_free(x+0,y+1)) { vspeed-=20; } } if!(place_free(x+0,y+1)) { This line is just the same as dragging on a check collision event and setting the area below the player object. vspeed-=20; This is the same as dragging out a vspeed event and setting it to -20.

  4. The Step Event (cont.) Lastly and most importantly we need gravity. Because we wouldn’t want the player to be able to fly around. // Gravity if (place_free(x+0,y+1)) { gravity_direction=270; gravity=3; } ifgravity > 12{ gravity = 12 } The first line is already covered. Then the second line will set the direction of the gravity. 270 is down, 180 is right, 90 is up, and 0 is left. Pretty simple system. The next line sets the gravity speed, which is set to three. ifgravity > 12{ gravity = 12 This is a bit more complicated. This says that if the gravity speed is greater that 12, then we will set the gravity speed to 12. This will keep the player from falling through the platforms.

  5. Collision Event Now you’ll want the character to collide with the ground and walls. So we can use some simple code to do so! //wall collision code ifother.y>y && !place_free(x,y+vspeed){ move_contact_solid(270,8); vspeed=0; gravity=0; } ifother.y<y && !place_free(x,y+vspeed){ move_contact_solid(90,8); vspeed=0; } The code simply checks whether there is a ground object below the character, then if there is it will set the speed and gravity to zero. Which will make it appear that the character lands on the platform. The next section of code does the same thing except for it is for objects to the side of the characters.

  6. Closing Notes I hope you enjoyed this tutorial and it really helped you a lot! You can see the code in action in the .gmk file contained in the .zip file you downloaded. Also, you can use this code for any way you want as long as you credit Nikc-Nack Games and link to one of our websites. Thank you!