Hamumu Software Hamumu Software Hamumu Software
Name
Password Register
Latest Journal update: Oct 18, 2017

Go Back   Hamumu Forum > General > Making Dumb Games

Reply
 
Thread Tools Display Modes
Old 06-04-2014, 07:05 PM   #1
Boneheads
King of the Boneheads
 
Boneheads's Avatar
 
Join Date: Apr 2009
Location: Utah, United States
Posts: 1,249
Default GM8: basic jumping & gravity for a platformer?

I used to be able to do it, and now I can't remember the code for it. Here's the .gmk file if anybody knows how to do it:
pne.gmk

EDIT: Nevermind, I got it. here it is if anyone wants it:
Code:
/* GRAVITY */
if place_free(x,y+1)      //If space below player isn't solid
{ 
gravity = 2               //Make the player fall this speed (2)
gravity_direction = 270   //And this direction (downwards)
} 
else                      //Otherwise, if the space below the player is solid
{ 
gravity=0                 //Don't make the player fall (speed of 0)
gravity_direction = 270   //But keep the gravity direction downwards
}  
/* MOVING LEFT */
if place_free(x-10,y)     //If space left of player isn't solid
and                       //and
keyboard_check(vk_left)   //The player is pressing left
{
x-=10                     //Make the player go left
} 
/* MOVING RIGHT */
if place_free(x+10,y)     //If space right of player isn't solid
and                       //and
keyboard_check(vk_right)  //The player is pressing right
{
x+=10                     //Make the player go right
}
/* JUMPING */
if !place_free(x,y+1)     //If space below player is solid
and                       //and
keyboard_check(vk_up)     //The player is pressing up
{
vspeed=-15                //Make the player jump 
}
__________________
Website

Last edited by Boneheads; 06-05-2014 at 11:54 AM. Reason: discovered it through lots of googling
Boneheads is offline   Reply With Quote
Old 06-14-2014, 02:28 PM   #2
moltanem2000
Professional Party Person
 
moltanem2000's Avatar
 
Join Date: Jan 2008
Location: Victoria BC
Posts: 999
Yerfdog Re: GM8: basic jumping & gravity for a platformer?

Just popping in to let you know you should be able to replace all the instances of place_free() with place_meeting() which takes a third parameter allowing you to check for collision with a specific object, rather than solid.
It looks like this:
Code:
place_meeting(x,y,obj)
so you could for example have an object called obj_block_parent, then have everything you want to have work as a wall have obj_block_parent as their parent. Then use
Code:
place_meeting(x,y,obj_block_parent)
instead of place_free.

What you've got there works fine but this gives you a bit more flexibility (what if you want something to be solid and not collide with the player?)
Maybe you knew this already or maybe that doesn't make any sense. Hopefully this was an interesting nugget of information rather than a confusing one
__________________
moltanem2000 is offline   Reply With Quote
Old 06-14-2014, 11:22 PM   #3
Boneheads
King of the Boneheads
 
Boneheads's Avatar
 
Join Date: Apr 2009
Location: Utah, United States
Posts: 1,249
Default Re: GM8: basic jumping & gravity for a platformer?

Quote:
Originally Posted by moltanem2000 View Post
Just popping in to let you know you should be able to replace all the instances of place_free() with place_meeting() which takes a third parameter allowing you to check for collision with a specific object, rather than solid.
It looks like this:
Code:
place_meeting(x,y,obj)
so you could for example have an object called obj_block_parent, then have everything you want to have work as a wall have obj_block_parent as their parent. Then use
Code:
place_meeting(x,y,obj_block_parent)
instead of place_free.

What you've got there works fine but this gives you a bit more flexibility (what if you want something to be solid and not collide with the player?)
Maybe you knew this already or maybe that doesn't make any sense. Hopefully this was an interesting nugget of information rather than a confusing one
Yeah, thanks. The main trouble I was having with this is most of the blocks I have that I want the player to collide with the player already have a parent, for other stuff in the game. And you could say, make those parents have the block parent object, right? well some of these have different parents pertaining to other things. It all gets really messy and tangled, and I still haven't figured out how to do it in a nice way.

I'll figure something out later if I ever trouble with this.
__________________
Website
Boneheads is offline   Reply With Quote
Old 06-19-2014, 10:35 PM   #4
moltanem2000
Professional Party Person
 
moltanem2000's Avatar
 
Join Date: Jan 2008
Location: Victoria BC
Posts: 999
Default Re: GM8: basic jumping & gravity for a platformer?

yeah it'd be pretty nice if objects could inherit from more than one parent. Or even if you could just "tag" an object as being a block or whatever you want. I've definitely had to draw big trees in the past of parents just to try and solve exactly that. Best of luck!
__________________
moltanem2000 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Gravity Falls Boneheads General Blabber 3 12-09-2013 09:55 PM
DD#28: Pixel Platformer: Voting Boneheads Total Mayhem 5 12-08-2012 12:29 PM
DD#28: Pixel Platformer Boneheads Making Dumb Games 17 12-08-2012 12:20 PM
Basic RPG Boneheads Total Mayhem 10 09-20-2010 12:35 AM
Sonic Riders (Zero-Gravity) Max Non-Hamumu Games 9 04-07-2009 05:20 AM


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2017, vBulletin Solutions Inc.
Site Map
Copyright 2017, Hamumu Games Inc.