Author Topic: pushable blocks  (Read 3287 times)

cl0udi

  • Wannabe
  • Posts: 16
  • OS:
  • Linux Linux
  • Browser:
  • Safari 4.0 Safari 4.0
    • View Profile
  • Playstyle: Keyboard
pushable blocks
« 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?

klazen108

  • Administrator
  • The Kid
  • Posts: 286
  • your a kid now your a squid now
  • OS:
  • Windows 8.1/Server 2013 Windows 8.1/Server 2013
  • Browser:
  • Firefox 30.0 Firefox 30.0
    • View Profile
    • Delicious-Fruit
  • Playstyle: Keyboard
Re: pushable blocks
« Reply #1 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:
  • 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!

Derpyhoovesiwbtg

  • Spike Dodger
  • Posts: 176
  • ''My hands hurt''
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 35.0.1916.153 Chrome 35.0.1916.153
    • View Profile
    • Clickity click!
  • Playstyle: Keyboard
Re: pushable blocks
« Reply #2 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?
I have no idea what to put here.

Anyway, a lot of things have changed to myself in the past. I wont visit the forum much, but i will check out the streams once in a while.

infern0man1

  • ~(=^・ω・^)ψ
  • Global Moderator
  • Oatmeal Killer
  • Posts: 1.021
  • Dear sir stroke madam, fire exclamation point
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 35.0.1916.153 Chrome 35.0.1916.153
    • View Profile
    • Twitter
  • Playstyle: Keyboard
Re: pushable blocks
« Reply #3 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.

Derpyhoovesiwbtg

  • Spike Dodger
  • Posts: 176
  • ''My hands hurt''
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 35.0.1916.153 Chrome 35.0.1916.153
    • View Profile
    • Clickity click!
  • Playstyle: Keyboard
Re: pushable blocks
« Reply #4 on: June 19, 2014, 12:37:37 PM »
Thanks! Im gonna test it soon.
I have no idea what to put here.

Anyway, a lot of things have changed to myself in the past. I wont visit the forum much, but i will check out the streams once in a while.

cl0udi

  • Wannabe
  • Posts: 16
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Firefox 30.0 Firefox 30.0
    • View Profile
  • Playstyle: Keyboard
Re: pushable blocks
« Reply #5 on: June 23, 2014, 12:28:30 PM »
problem: you can just walk through the block :D

pieceofcheese87

  • Global Moderator
  • The Kid
  • Posts: 346
  • Personal Text
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 35.0.1916.153 Chrome 35.0.1916.153
    • View Profile
    • Twitch Tv Channel
  • Playstyle: Keyboard
Re: pushable blocks
« Reply #6 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
Signature

cl0udi

  • Wannabe
  • Posts: 16
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Firefox 30.0 Firefox 30.0
    • View Profile
  • Playstyle: Keyboard
Re: pushable blocks
« Reply #7 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