I Wanna Community
Fangames => Game Design => Programming Questions => Topic started 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?
-
Make the block.
Give it the "block" object for its parent.
Check the "solid" checkbox
Step Event of your block:
//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:
var L,R,h;
With this line:
var L,R;
Player's Begin Step Event:
h=0;
Some notes:
- This assumes you don't mind that the block falls at a constant speed, not affected by gravity
- If the block covers a spike, you will still die to the spike. This is true for objects with a "block" parent, and you will have to move the playerkiller collision event to the end step event (I can provide more information if this is the case)
- I just tested this in the yuuutu engine, and it seems to work just fine.
- The block moves 3 pixels at a time, like the kid, so be wary of align issues (it won't fall in a 1 block wide hole unless that hole is at the same pixel align as the starting point of the block
Let me know if you have any problems!
-
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?
-
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.
-
Thanks! Im gonna test it soon.
-
problem: you can just walk through the block :D
-
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
-
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