Passing movement info through rigid bodies

101 views
Skip to first unread message

thordu...@gmail.com

unread,
Jul 6, 2016, 2:50:24 PM7/6/16
to PuzzleScript
I was struggling with the ability to pass movement through rigid bodies to other
entities when the rigid bodies cannot move, then I remembered you can have
two things in one cell thus allowing for some kind of a temporary mark of the direction that the player carried out next to the rigid body.
This is my code:

[ moving Player | Boxes ] -> [ moving Player | moving Boxes ]
+ [ moving Boxes | Boxes ] -> [ moving Boxes | moving Boxes ]
+ rigid [ moving RigidBox | RigidBox ] -> [ moving RigidBox | moving RigidBox ]

[ left Player | RigidBox ] -> [ left Player | RigidRobot markLeft ]
[ right Player | RigidBox ] -> [ right Player | RigidBox markRight ]
[ up Player | RigidBox ] -> [ up Player | RigidBox markUp ]
[ down Player | RigidBox ] -> [ down Player | RigidBox markDown ]

[ RigidBox | RigidBox markLeft ] -> [ RigidBox markLeft | RigidBox markLeft ]
[ RigidBox | RigidBox markRight ] -> [ RigidBox markRight | RigidBox markRight ]
[ RigidBox | RigidBox markUp ] -> [ RigidBox markUp | RigidBox markUp ]
[ RigidBox | RigidBox markDown ] -> [ RigidBox markDown | RigidBox markDown ]

[ RigidBox markLeft | NONRigidBox ] -> [ RigidBox markLeft | left NONRigidBox ]
[ RigidBox markRight | NONRigidBox ] -> [ RigidBox markRight | right NONRigidBox ]
[ RigidBox markUp | NONRigidBox ] -> [ RigidBox markUp | up NONRigidBox ]
[ RigidBox markDown | NONRigidBox ] -> [ RigidBox markDown | down NONRigidBox ]

[moving Player | NONRigidBox ] -> [moving Player | moving NONRigidBox ]
[moving NONRigidBox | NONRigidBox ] -> [moving NONRigidBox | moving NONRigidBox ]

late [ RigidBox markLeft ] -> [ RigidBox ]
late [ RigidBox markRight ] -> [ RigidBox ]
late [ RigidBox markUp ] -> [ RigidBox ]
late [ RigidBox markDown ] -> [ RigidBox ]

So, the code at the top does the basic rigid body stuff that does not happen if
the rigid stuff is activated.

Then we have temporary entities that get placed in a rigid body entity next to the player, and rigid body entities next to a rigid body entity with this mark get the mark as well. That way the movement info spreads and you can just check whether you are next to a rigid body entity with a mark or not.
the late rule is to remove the marks from the rigid bodies.

Hope this helps someone!

thordur

unread,
Jul 11, 2016, 9:13:25 AM7/11/16
to PuzzleScript, thordu...@gmail.com

Hey anyone that is reading, I discovered that if any rigid box of the same type can't move, other rigid blocks that _should_ be able to move can't, because rules marked as rigid disable themselves and re-simulate the turn, and since [ moving Player | Boxes ] -> [ moving Player | moving Boxes ] is in the same rule group it gets disabled as well(if I understand correctly)!
Here is a gif to demonstrate what I am talking about: https://s3.amazonaws.com/f.cl.ly/items/1d2v1x2H391B2L173f32/test.gif

So my fix is to dump the rigid keyword all together and create a new mark object called hitWall and mark stuff that gets hit by a wall(and mark connected rigid objects) so you can tell those objects not to move!

So if you just wanted to fix the situation that occurs in the GIF, the code would look like this:

[ moving Player | Crate ] -> [ moving Player | moving Crate ]
[ moving Crate | Crate ] -> [ moving Crate | moving Crate ]

[ > Crate | Wall ] -> [ Crate wallHit | Wall ]
[ Crate wallHit | Crate ] -> [ Crate wallHit | Crate wallHit ]
[ moving Crate wallHit ] -> [ Crate wallHit ]


late [ Crate wallHit ] -> [ Crate ]
late [ wallHit ] -> []

And now that box can move freely!:https://s3.amazonaws.com/f.cl.ly/items/220f41422r0R1M1j0741/test2.gif


And here is a fix for the code I posted previously:


[ moving Player | Boxes ] -> [ moving Player | moving Boxes ]

[ moving Boxes | Boxes ] -> [ moving Boxes | moving Boxes ]

[ > Boxes | Wall ] -> [ Boxes hitWall | Wall ]
[ Boxes hitWall | RigidBox ] -> [ Boxes hitWall | RigidBox hitWall ]
[ moving RigidBox hitWall ] -> [ RigidBox hitWall ]

[ left Player | RigidBox ] -> [ left Player | RigidRobot markLeft ]
[ right Player | RigidBox ] -> [ right Player | RigidBox markRight ]
[ up Player | RigidBox ] -> [ up Player | RigidBox markUp ]
[ down Player | RigidBox ] -> [ down Player | RigidBox markDown ]

[ RigidBox | RigidBox markLeft ] -> [ RigidBox markLeft | RigidBox markLeft ]
[ RigidBox | RigidBox markRight ] -> [ RigidBox markRight | RigidBox markRight ]
[ RigidBox | RigidBox markUp ] -> [ RigidBox markUp | RigidBox markUp ]
[ RigidBox | RigidBox markDown ] -> [ RigidBox markDown | RigidBox markDown ]

[ RigidBox markLeft | NONRigidBox ] -> [ RigidBox markLeft | left NONRigidBox ]
[ RigidBox markRight | NONRigidBox ] -> [ RigidBox markRight | right NONRigidBox ]
[ RigidBox markUp | NONRigidBox ] -> [ RigidBox markUp | up NONRigidBox ]
[ RigidBox markDown | NONRigidBox ] -> [ RigidBox markDown | down NONRigidBox ]

[moving Player | NONRigidBox ] -> [moving Player | moving NONRigidBox ]
[moving NONRigidBox | NONRigidBox ] -> [moving NONRigidBox | moving NONRigidBox ]

late [ Boxes hitWall ] -> [ Boxes ]
late [ Boxes markLeft ] -> [ Boxes ]


late [ RigidBox markRight ] -> [ RigidBox ]
late [ RigidBox markUp ] -> [ RigidBox ]
late [ RigidBox markDown ] -> [ RigidBox ]

late [ MARKS ] -> []

Stephen Lavelle

unread,
Jul 11, 2016, 1:20:44 PM7/11/16
to thordur, PuzzleScript
woo. rigid is really a last resort. happy you got something a bit saner :)


--
You received this message because you are subscribed to the Google Groups "PuzzleScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puzzlescript...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Connorses

unread,
Jul 14, 2016, 1:19:32 PM7/14/16
to PuzzleScript
You could make a whole game from this.
(and I'm pretty sure someone already has so I'll just leave mine here)

http://www.puzzlescript.net/play.html?p=b1557fe25c842a21a2196bd560ab1c7f

Stephen Lavelle

unread,
Jul 15, 2016, 4:22:54 AM7/15/16
to Connorses, PuzzleScript
That's pretty pleasing, connorses!

--

thordur

unread,
Jul 15, 2016, 6:48:23 AM7/15/16
to PuzzleScript
Yeah, this was a problem in my current project, which includes this sorta rigid stuff.
Stickyban is cool! Did you make it based on this post?

Connorses

unread,
Jul 15, 2016, 3:40:28 PM7/15/16
to PuzzleScript
Yes I did in fact I copied the smaller set of rules you posted and used them. Perhaps I'll try and make more levels some time.
Reply all
Reply to author
Forward
0 new messages