Logo Image





How-Tos


Simple Platform Engine By: DJ Coco [E] [W]
Works in Game Maker 7 and 8.

Contains:
*Basic Movement
*Jump-through platforms
*Slippery Surfaces
*Swimming
*Falling platforms
*Moving platforms (horizontal and vertical)

No credit needed. Code is uncommented, so you'd better have some basic knowledge. If you want slopes, you gotta check my slope example on my homepage:

http://djcoco.site11.com/
Target Applications: GM7 GM8

Update History
 
No History
 
[O] Created: Jan 12 2012, 7:56 PM
[O] Updated: Never
[O] File Size: 63.83 KB
[O] Views: 8788
[O] Downloads: 2064
View / Download

Comments
Jaden1291 Jan 22 2012, 1:34 PM
Cool! I would make a 5-level game with this...
But please make support for the Game Maker Lite edition 8.0 and 8.1?
 
DJ Coco Jan 22 2012, 3:14 PM
Quote (Jaden1291 on Jan 22 2012, 1:34 PM)
Cool! I would make a 5-level game with this...
But please make support for the Game Maker Lite edition 8.0 and 8.1?

The only thing that keeps it pro is the draw_sprite_ext function in the Draw Event.

Just dublicate all the sprites for Mario and mirror them. Then you'd need to select the fitting sprite by checking xscale.

if (xscale == 1) {sprite_index = spr_mario_right...;}

Of course you also need to replace the draw_sprite_ext function with draw_sprite and remove all the arguments after y.

Ya know... If you need help just PM me ;)
 
Jaden1291 Jan 23 2012, 5:09 AM
Great. Now I will create my 5 level game for MFGG.
Just one more thing: I might download Game Maker Pro as a torrent. For sure.
 
DJ Coco Jan 23 2012, 6:51 PM
Quote (Jaden1291 on Jan 23 2012, 5:09 AM)
Great. Now I will create my 5 level game for MFGG.
Just one more thing: I might download Game Maker Pro as a torrent. For sure.

Are you trying to flame me? This engine is for learning purposes only anyway, as it's very incomplete. And I told ya I'd help ya out. But not like that.
 
danimario9 Jan 26 2012, 9:49 PM
I'll might test it.
 
Jaden1291 Jan 28 2012, 1:31 PM
Quote (DJ Coco on Jan 23 2012, 6:51 PM)
Are you trying to flame me? This engine is for learning purposes only anyway, as it's very incomplete. And I told ya I'd help ya out. But not like that.

Sorry DJ Coco. But how can I add sounds to my game when Mario swims, jumps, skids, and more?
 
Colton564 Jan 28 2012, 2:40 PM
Might use this sometime for a game I'm making.
 
DJ Coco Jan 28 2012, 10:38 PM
Quote (Jaden1291 on Jan 28 2012, 1:31 PM)
Sorry DJ Coco. But how can I add sounds to my game when Mario swims, jumps, skids, and more?

You simply put "sound_play(yoursoundname);" to where the code for the event is executed. As for jumping and skidding, it'd be the "if (keyboard_check(ord('X'))..." part in the Step Event of Mario. In the first if condition you put the one for swimming, in the second the one for jumping.

Skidding is only in the Draw Event, so I recommend you put

if ((xspeed > 0 && keyboard_check(vk_left) && !keyboard_check(vk_right)) || (xspeed < 0 && keyboard_check(vk_right) && !keyboard_check(vk_left))) {sound_play(yourskiddingsound);}

into the Step Event. If you need help with that, just ask.
 
Jaden1291 Feb 7 2012, 1:06 PM
Quote (DJ Coco on Jan 28 2012, 10:38 PM)
You simply put "sound_play(yoursoundname);" to where the code for the event is executed. As for jumping and skidding, it'd be the "if (keyboard_check(ord('X'))..." part in the Step Event of Mario. In the first if condition you put the one for swimming, in the second the one for jumping.

Skidding is only in the Draw Event, so I recommend you put

if ((xspeed > 0 && keyboard_check(vk_left) && !keyboard_check(vk_right)) || (xspeed < 0 && keyboard_check(vk_right) && !keyboard_check(vk_left))) {sound_play(yourskiddingsound);}

into the Step Event. If you need help with that, just ask.

Are you sure you want to change your engine's name and add enemies, blocks, items, and other movements?
 
DJ Coco Feb 8 2012, 6:56 PM
Quote (Jaden1291 on Feb 7 2012, 1:06 PM)
Are you sure you want to change your engine's name and add enemies, blocks, items, and other movements?

Huh? I never said that. If you're asking whether I'm going to do so, I'm afraid I have to disappoint you. This engine is, as I stated before already, for learning purposes. So is my help I'm offering. If you want an engine where you just have to design levels, I recommend the Supernova Engine to you. If you want to actually program it yourself try it, based on what's in the engine already and feel free to ask if something's not working/you're stuck somewhere. I refuse to make an entire engine, though.
 
Jaden1291 Feb 10 2012, 3:29 PM
But Supernova's engine has no powerups, blocks, and other stuff! What a hassle!
 
DJ Coco Feb 10 2012, 5:49 PM
Quote (Jaden1291 on Feb 10 2012, 3:29 PM)
But Supernova's engine has no powerups, blocks, and other stuff! What a hassle!

Umm, from what I can tell it has. Did you find the right engine?
 
darkyoshi222 Feb 11 2012, 9:11 PM
This is an amazing example! I have a question though, how can I change the buttons for the movement? cus the right arrow key on my laptop is ripped off xD
 
DJ Coco Feb 12 2012, 2:08 PM
Quote (darkyoshi222 on Feb 11 2012, 9:11 PM)
This is an amazing example! I have a question though, how can I change the buttons for the movement? cus the right arrow key on my laptop is ripped off xD

xD You can do it in the Step Event. The part where it says "vk_right". If you want to use WASD controls, you got to type "ord('D')" instead of "vk_right" for example. You can also simply type "keyright" for example, and define those variables when the game starts. For example put

keyright = ord('D');

into some Game Start Event. Hope I could help ^,^
 
darkyoshi222 Feb 12 2012, 6:42 PM
Quote (DJ Coco on Feb 12 2012, 2:08 PM)
xD You can do it in the Step Event. The part where it says "vk_right". If you want to use WASD controls, you got to type "ord('D')" instead of "vk_right" for example. You can also simply type "keyright" for example, and define those variables when the game starts. For example put

keyright = ord('D');

into some Game Start Event. Hope I could help ^,^

Thanks! I have another question, when I was adding sound (taking advice from your comment about the sound) when I click the jump button with a jump sound effect it constantly plays the sound when i just pressed it once, how do i fix that?
 
DJ Coco Feb 12 2012, 10:35 PM
Quote (darkyoshi222 on Feb 12 2012, 6:42 PM)
Thanks! I have another question, when I was adding sound (taking advice from your comment about the sound) when I click the jump button with a jump sound effect it constantly plays the sound when i just pressed it once, how do i fix that?

I can't quite explain that. Did you put it where the yspeed is set? Can you show me the code please?
 
darkyoshi222 Feb 13 2012, 12:09 AM
Quote (DJ Coco on Feb 12 2012, 10:35 PM)
I can't quite explain that. Did you put it where the yspeed is set? Can you show me the code please?

"if (keyboard_check(ord('L'))) { sound_play(jump);
if (swim) {
if (!place_meeting(x,y-24,obj_water) && keyboard_check(vk_up)) {yspeed = -3;}
else {yspeed = -1;}
swimsprite = 1;
alarm[1] = 15;
}
else if (ground && yspeed >= 0) {yspeed = -5.5;}"
 
DJ Coco Feb 13 2012, 3:49 PM
Quote (darkyoshi222 on Feb 13 2012, 12:09 AM)
"if (keyboard_check(ord('L'))) { sound_play(jump);
if (swim) {
if (!place_meeting(x,y-24,obj_water) && keyboard_check(vk_up)) {yspeed = -3;}
else {yspeed = -1;}
swimsprite = 1;
alarm[1] = 15;
}
else if (ground && yspeed >= 0) {yspeed = -5.5;}"

Yeah, I see the problem now. You need to put the "sound_play" part into the brackets which surround the part where yspeed is set. As for swimming, putting it into the brackets after "if (swim)" should work fine. Let me quickly fix it up for you.

if (keyboard_check(ord('L'))) {
if (swim) {
if (!place_meeting(x,y-24,obj_water) && keyboard_check(vk_up)) {yspeed = -3;}
else {yspeed = -1;}
swimsprite = 1;
alarm[1] = 15;
sound_play(snd_swim);
}
else if (ground && yspeed >= 0) {
yspeed = -5.5;
sound_play(snd_jump);
}
 
the midjet Apr 21 2012, 3:54 PM
great engin but i am having some troubles making a slope. can you help me?
 
DJ Coco Apr 21 2012, 7:09 PM
Quote (the midjet on Apr 21 2012, 3:54 PM)
great engin but i am having some troubles making a slope. can you help me?

Did you check out my simple slope engine?
www.djcoco.site11.com/sse.php

Just look through the different events. The code is even commented here. If you should encounter problems, feel free to ask again.
 
the midjet Apr 21 2012, 8:17 PM
Quote (DJ Coco on Apr 21 2012, 7:09 PM)
Did you check out my simple slope engine?
www.djcoco.site11.com/sse.php

Just look through the different events. The code is even commented here. If you should encounter problems, feel free to ask again.

ok thanks. I have one question though. I was able to make the slope but the charcter keeps on doing the jumping image. how would I make the walking image
 
DJ Coco Apr 22 2012, 11:00 AM
Quote (the midjet on Apr 21 2012, 8:17 PM)
ok thanks. I have one question though. I was able to make the slope but the charcter keeps on doing the jumping image. how would I make the walking image

The walking image is set by checking if there is a block below. You now need to make it also check for slopes (&& place_meeting(x,y+1,par_slope)). The code should be in the Draw Event.
 
the midjet Apr 22 2012, 4:49 PM
when I tried to implant the code it said an error unexpected symbol. After that I tried (&& place_meeting(x,y+1,obj_slope_parent)) {sprite_index = spr_mario;} Am I suppose to make a command after because (&& place_meeting(x,y+1,obj_slope_parent)) by its self is not working. I am so sorry if I am bothering you.
 
DJ Coco Apr 22 2012, 5:02 PM
Quote (the midjet on Apr 22 2012, 4:49 PM)
when I tried to implant the code it said an error unexpected symbol. After that I tried (&& place_meeting(x,y+1,obj_slope_parent)) {sprite_index = spr_mario;} Am I suppose to make a command after because (&& place_meeting(x,y+1,obj_slope_parent)) by its self is not working. I am so sorry if I am bothering you.

Of course that doesn't work ;) && stands for and. Since there's nothing before it Game Maker doesn't know what to do. You need to add it to the existing collision checks. Wherever it checks for blocks or jumpthrough blocks below. (The lines where it says collision_line). I'm sorry if I made that unclear. Also don't worry, you're not bothering me ;)
 
the midjet Apr 22 2012, 8:07 PM
im not sure what I am doing wrong. when I put it the darw event under it still has en errorI tried putting t nder e statement.
if (ground) {
if (run) {sprite_index = spr_mario_run;}
else if ((xspeed > 0 && keyboard_check(ord('A')) && !keyboard_check(ord('D'))) || (xspeed < 0 && keyboard_check(ord('D')) && !keyboard_check(ord('A')))) {sprite_index = spr_mario_skid;}
else {sprite_index = spr_mario;

}
}
have tried putting it in in almost every space but it keeps on saying inexpected symbol. i also tried taking out the &&
 
DJ Coco Apr 22 2012, 9:28 PM
Quote (the midjet on Apr 22 2012, 8:07 PM)
im not sure what I am doing wrong. when I put it the darw event under it still has en errorI tried putting t nder e statement.
if (ground) {
if (run) {sprite_index = spr_mario_run;}
else if ((xspeed > 0 && keyboard_check(ord('A')) && !keyboard_check(ord('D'))) || (xspeed < 0 && keyboard_check(ord('D')) && !keyboard_check(ord('A')))) {sprite_index = spr_mario_skid;}
else {sprite_index = spr_mario;

}
}
have tried putting it in in almost every space but it keeps on saying inexpected symbol. i also tried taking out the &&

Do it in the Step Event. I'm sorry, I didn't remember I was using the variable "ground" here. That makes things much easier. "ground" defines whether you're on the ground or not. So simply check for slopes when defining that variable. However, I was wrong about another thing. "&&" means and, which would mean you are standing both on a flat floor or on a slope. It needs to be "||" which means or. So you simply "|| (place_meeting(x,y+1,par_slope)" (without quotation marks) to that line. I didn't test it, but it should work :)
 
the midjet Apr 22 2012, 9:58 PM
he is able to go up and down the slope but he is still doing the jump image when he touch the slope. I think "|| (place_meeting(x,y+1,par_slope)" was for going up and down slope :). am still pretty new code. so how would I make it so when maroi touches the slope it draws the walking image.
 
DJ Coco Apr 23 2012, 5:23 AM
Quote (the midjet on Apr 22 2012, 9:58 PM)
he is able to go up and down the slope but he is still doing the jump image when he touch the slope. I think "|| (place_meeting(x,y+1,par_slope)" was for going up and down slope :). am still pretty new code. so how would I make it so when maroi touches the slope it draws the walking image.

Sorry, I gave you some wrong code :( It's basically correct but you can't add it to the ground variable. Anyway, this should work for sure:

Where it says
ground = collision_rectangle(x,bbox_bottom+1,x+15,bbox_bottom+1,obj_jt_block,1,1);
you write
slope = collision_rectangle(x,bbox_bottom+1,x+15,bbox_bottom+1,par_slope,1,1);
below.

Then, wherever it says
if (ground)
you replace that with
if (ground || slope)

Hope that will do the trick :) I'm very sorry for the wrong codes again, I need to be more careful with my help... :(
 
the midjet Apr 24 2012, 12:02 AM
yess thank you so much it works! O ya you forgot to say you have to introduce the varible slope in the create event ;) but that should be common knowledge. Anyway thank you so much when I finish my game I will make sure I will give you credit.
 
DJ Coco Apr 24 2012, 5:07 PM
Quote (the midjet on Apr 24 2012, 12:02 AM)
yess thank you so much it works! O ya you forgot to say you have to introduce the varible slope in the create event ;) but that should be common knowledge. Anyway thank you so much when I finish my game I will make sure I will give you credit.

Glad it works for you now :3 You don't have to give credit, but I always appreciate it ;)
 
donotfoldspindleormutilate Aug 12 2012, 10:45 PM
I have a question on the white ground object. I don't remember what it's called(sorry!), I am not at home looking at the code/object.

It's basically the wall object and NOT the jump-through object.

So my question is on this white object. When I walk over it or jump on to it, the player automatically goes all jerky, like he's trying to swim (or jump?) And all I can do as he's being jerky is only walk but not jump. As soon as the player goes past the block he becomes normal.

What's the issue here, and what's the work-around?

By the way, I have not edited anything, this happens when I run the code as-is in GM8.1 Oh, and thank you for this example, I've learned quite a bit :-)
 
DJ Coco Aug 13 2012, 11:10 PM
Quote (donotfoldspindleormutilate on Aug 12 2012, 10:45 PM)
I have a question on the white ground object. I don't remember what it's called(sorry!), I am not at home looking at the code/object.

It's basically the wall object and NOT the jump-through object.

So my question is on this white object. When I walk over it or jump on to it, the player automatically goes all jerky, like he's trying to swim (or jump?) And all I can do as he's being jerky is only walk but not jump. As soon as the player goes past the block he becomes normal.

What's the issue here, and what's the work-around?

By the way, I have not edited anything, this happens when I run the code as-is in GM8.1 Oh, and thank you for this example, I've learned quite a bit :-)

Oh my god, sorry, it's a bug! I actually found this bug a while ago and I don't know myself why I didn't fix it!

Anyway, the fix is simple. The engine mostly only checks for the jump-through blocks (the blue ones). It should also do this for the normal blocks (the white ones) and this supposed to happen automatically, because I parented the white block to the blue one... or so I thought! Yeah, I forgot to do that. Just click on the white block and go to the section where it says "Parent:". Then pick the blue block.

I hope this clears things up ;) I'm happy you learnt from this engine. If you need help, feel free to ask again ;)
 
the midjet Jan 10 2013, 5:03 AM
Hey I just finished my game and thanks to your engin I was able to make more complex that I would have been. It is called shyguy expedition I also gave you credits. Thank you for this engin and I apologies that I am posting this s a comment but my messinging isnt working for some reason.
 
LuigiMario9 Jan 27 2013, 3:52 AM
I wish more of these had lite support
 
Bruin Mar 1 2013, 4:29 PM
This is a very good engine!
It's just what I need - a engine covering the basic platformer features you might need in a Mario game, but let me create enemies, blocks etc. myself.
Plus, it works perfect with Studio and I think I can understand pretty much all of the code.
 
DJ Coco Mar 1 2013, 4:31 PM
Quote (Bruin on Mar 1 2013, 4:29 PM)
This is a very good engine!
It's just what I need - a engine covering the basic platformer features you might need in a Mario game, but let me create enemies, blocks etc. myself.
Plus, it works perfect with Studio and I think I can understand pretty much all of the code.

Thanks for the positive feedback! If you need help with anything, just let me know.
 
CHAO95 Apr 4 2013, 9:54 PM
Dude! Your Slope engine is sooo simple and easy lol. Thank You
 
DJ Coco Apr 4 2013, 10:46 PM
Quote (CHAO95 on Apr 4 2013, 9:54 PM)
Dude! Your Slope engine is sooo simple and easy lol. Thank You

No problem, I'm always happy to help! If you have problems merging the engines let me know!
 
Pages: (1) 1 | Last Unread