I Wanna Community

Fangames => Game Design => Programming Questions => Topic started by: cl0udi on June 18, 2014, 06:25:31 PM

Title: pushable blocks
Post by: cl0udi on June 18, 2014, 06:25:31 PM
so how do i make those blocks that you can push around and they fall when pushed off an edge?
Title: Re: pushable blocks
Post by: klazen108 on June 18, 2014, 09:58:54 PM
Make the block.
Give it the "block" object for its parent.
Check the "solid" checkbox

Step Event of your block:
Code: [Select]
//step event of block
fallSpd=3;

//pushable
if      (place_meeting(x-3,y,player) && player.h == 1) move_contact_solid(0,3);
else if (place_meeting(x+3,y,player) && player.h == -1) move_contact_solid(180,3);

//fallable
if (place_meeting(x,y+1,block)) vspeed=0;
else move_contact_solid(270,fallSpd);

Player's Step Event:
Replace this line:
Code: [Select]
var L,R,h;With this line:
Code: [Select]
var L,R;
Player's Begin Step Event:
Code: [Select]
h=0;

Some notes:

Let me know if you have any problems!
Title: Re: pushable blocks
Post by: Derpyhoovesiwbtg on June 19, 2014, 09:53:23 AM
Something else, in Dark Blue, theres that room with the pushable block and the button that activates a trigger. How do you let the pushable block activate the button?
Title: Re: pushable blocks
Post by: infern0man1 on June 19, 2014, 10:35:22 AM
Though it may not be the most effective way to make this happen, this is what I would do:


In the button, create a trigger variable and set it to 0. Then have the trigger variable set to 1 when the block collides with the button. In the object triggered, make it so the object does whatever it should do when the variable is set to 1.


Hopefully that makes some sense; I'm not the best with GM.
Title: Re: pushable blocks
Post by: Derpyhoovesiwbtg on June 19, 2014, 12:37:37 PM
Thanks! Im gonna test it soon.
Title: Re: pushable blocks
Post by: cl0udi on June 23, 2014, 12:28:30 PM
problem: you can just walk through the block :D
Title: Re: pushable blocks
Post by: pieceofcheese87 on June 23, 2014, 02:05:57 PM
problem: you can just walk through the block :D

Mark it as a solid object, and make the parent 'block'.
That should fix any problems
Title: Re: pushable blocks
Post by: cl0udi on June 23, 2014, 02:25:42 PM
problem: you can just walk through the block :D

Mark it as a solid object, and make the parent 'block'.
That should fix any problems

Making it solid (why didn't I think of that) fixed that problem, but now it still doesn't move lol