Can anyone think of an effective way of motion mapping a sprite that moves around?
I'm trying to do this for my robotics team but since I'm unable to attend the meeting today I'm trying to simulate it in scratch :p
Basically, our robot travels a certain path. If the enemy robot gets in its way, we want it to do that same path in reverse so it doesn't start going in the wrong direction. If it does the same thing but reverse, it'll go back to its original starting position and it can try again.
We have special sensors to know if the enemy robot is in front so don't worry about that.
I'm just trying to think of an easy way to make it reverse it's path...
Let's say I have three movement functions. Pressing space bar will be like the enemy robot hitting our robot, so that'll trigger the reverse function.
The three functions..
Go forward for 2 seconds
Go right 3 seconds
Go forward again for 2 seconds
Let's say that the enemy robot "hits" our robot in the middle while going right. Our robot should instantly stop and go left for the same amount of time it went right, then go backwards for 2 seconds. Get it?
I really need help with this! I'm thinking of using a table to track it's movement, but the problem is I need to convert everything to C after.
C has arrays, which is basically like lists in scratch, but I don't think I can add values to it (like adding another item to a list in scratch).
Thank you to anyone who can help me! I really appreciate it
Offline
You can do something like this:
This stores the robot's positions as it moves forward, then goes to those positions in revers order when the variable "Direction" is anything but "forward."
The only setback to this method is that it will not respond to changes in it's environment (say it's reversing and a wall appears in it's way, it will go through that wall). To fix this, instead of storing it's positions you can store preset motions it can take.
_________
Motions: Say you have a motion which you name "Move Forward". This can be defined as "repeat 10 move 2 steps". In your robot when you want it to move forward you can do this:
Now when reversing you can do this:
Except with this method you would have to program in a few set courses of action the robot can take (one being MoveForward, another could be TurnRight, etc.)
Last edited by Kileymeister (2011-04-24 16:55:05)
Offline