Hello all,
I have another stupid problem that I can't get past.
Then code below is a simplified version of what I'm tring to do.
In the first working working method I am sending the direction the robot is facing and it is getting sucessfully turned 90 degrees to the left.
I don't know how to get the 2nd bit of code working. I'm getting confused with return values I think.
In the second piece of code I simply want to send the robots x, y co-ords and direction it's facing. I then want to get the return value of x+1/x-1 or y+1/y-1 depending on the facing direction.
Can someone please help me with the syntax/logic of this?
I have another stupid problem that I can't get past.
Then code below is a simplified version of what I'm tring to do.
In the first working working method I am sending the direction the robot is facing and it is getting sucessfully turned 90 degrees to the left.
I don't know how to get the 2nd bit of code working. I'm getting confused with return values I think.
In the second piece of code I simply want to send the robots x, y co-ords and direction it's facing. I then want to get the return value of x+1/x-1 or y+1/y-1 depending on the facing direction.
Can someone please help me with the syntax/logic of this?
Code:
'------This works the direction is being correctly changed
Method Left:Void()
Local direction:Int = AI_left(x, y, direction)
End Method
Method AI_left:Int(x:Int, y:Int, direction:Int)
Select direction
Case UP
direction = LEFT
Case DOWN
direction = RIGHT
Case LEFT
direction = DOWN
Case RIGHT
direction = UP
End Select
Return 0
End Method
'------I can't figure this bit out
Method forward:Void()
Local a:Int = AI_forward(x, y, direction)
End Method
Method AI_forward:Int(x:Int, y:Int, direction:Int)
Select direction
Case UP
y = y - 1
Case DOWN
y = y + 1
Case LEFT
x = x - 1
Case RIGHT
x = x + 1
End Select
Return 0
End Method
Last edited by a moderator: