Locked 4-way movement.

Is there a way to make top down movement locked to make it only possible to walk up, down, left and right. The normal top down movement in the help page allows diagonal movement, and that ruins the feel of my game. Any help?

Then you get 1 when Up is pressed, and for Down you get … 1.
That would require adding number blocks and switches again?
On phone now, can’t test. The editor layout does not adjust to small screens :frowning:

cant you just XOR gate?

Aehm … here the updated one


Was just testing if everyone pays attention and left on purpose 2 wires out cough

And another update :slight_smile:

Inspired by @Broseph 's question I now added a 8 way version.
Link: https://flowlab.io/game/play/1401064

First half is the same as the OneWay one, I just added another equation to calculate the angle. More details in my answer in Broseph’s thread.

P.S. I used -B in that equation, because in Javascript the Y axis is the other way around (positive goes up).

Try @grazer 's other example:
is their a link to the game? There is a more complex alternate way…

If you want a complete locking mechanism for control, I made a 2 layer switch system.

Here a version I use, I think easier to read and understand.
Yes, @“JR 01” , it does not block opposing movements, LOL. Love the neural network look of yours though :slight_smile:


Link, grab it fast I have no slots left: https://flowlab.io/game/play/1391142

P.S. You could delete the Filters and connect the Number Outputs directly to the Switches. I used them because I needed their outputs for other purposes too and just left them ( a compass display )

Nice lol, I was focus on a way to only allow 1 input.
That is better and easier


Now it blocks opposing movements :slight_smile:


P.S. it nearly got me. I was not aware the the expression block keeps the last used values, that’s why I had to reset them with the zero block too.

Question @“JR 01” , should I use ‘Always’ to trigger the Expression Block, or is it better the way I did it? Just wondering if ‘Always’ would create more lag.

I dont think it would lag, it takes a lot to cause lag on Flowlab (such as too many objects on a long level).

And expressions remember there numbers and it can loop back into itself (to like keep adding B loop with A input)

@“JR 01” and @TinkerSmith

AHA! This is exactly what I like to see. After the minimal game jam, I would like to see some sort of group exercise where everyone tries to make the SAME game in their own way and you can compare the programming style and individual solutions in each. My wires tend to look a lot more like JR 01’s than TinkerSmith’s final example above.

But how in the world is anyone supposed to know to use that equation. LOL!

Is there any way to explain what that expression is saying? What is it doing exactly?
(A to the power of B) unknown value (A compared to 1unknown value minus 5:5 ratio) ratio 0

Also, RE: Flowlab lag with too many objects. That must be what’s bogging (pun intended) everything down in Gator Panic. By the time the player gets to the end the boat is moving at a crawl.

ooops. accidental emoji. hahaha

I explained it somewhere else … forgot where, LOL

It is a shortform for a single line ‘IF…THEN…ELSE’ command.
Google Javascript Ternary Operator.
Beside the math functions that @grazer listed in the Flowlab reference the Expression block understands many other javascript operators.

The syntax is:
(condition)?True value:False value

The (A?B) in Javascript is actually the logical XOR function, not A to the power of B.
That part gives me a TRUE if only A or B are 1, if both are 0 or 1 if gives a FALSE.
The trick now, in the ‘True value’ part of the operation I now use a second IF…THEN to check if A was 1, then output is -5, else it was B, then output is 5.

… I just love to tinker :slight_smile:

If not clear, just ask ahead