lego-mindstorms

How do you make sure both variables are the same but also are in the right place


I am making a simple game in LEGO EV3 programmer (default software) and I have a code that I don't know how I'd make.

I have 2 variables -

I want to make it so it is compared, and if the variables both equal, and are in the same position, it makes another variable true.

Therefore...

if ((IF PLAYER & IF OBJECT) = SAME) & ((IF PLAYER = TRUE) & (IF OBJECT = TRUE)) then VARIABLE = TRUE;

Or something like that...


Solution

  • Your code should not have "if if" anywhere, that just looks wrong.

    What do you mean by "if player = true"? This doesn't make sense when you read it. A player cannot be true.

    The code should look like if player = bullet then shot = true. This assumes that the player and the bullet variables represent the location of these objects. (I know nothing about Mindstorms, by the way.) Maybe you need to replace the first = with ==, depending on how the programming language needs it.