
-----------------------------------
happyfacelegion
Sat May 30, 2015 3:43 pm

How to make sprites move randomly?
-----------------------------------
What is it you are trying to achieve?



What is the problem you are having?



Describe what you have tried to solve this problem



Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)








Please specify what version of Turing you are using


-----------------------------------
Insectoid
Sat May 30, 2015 4:00 pm

RE:How to make sprites move randomly?
-----------------------------------
Do you know how to make sprites move non-randomly? 

And this is a pretty open question. 'move randomly' can mean a lot of things. The first step to solving a problem is deciding what you want the end result to look like. You can't write code without knowing what you want.

-----------------------------------
happyfacelegion
Sat May 30, 2015 4:16 pm

RE:How to make sprites move randomly?
-----------------------------------
I am designing a game so that the user will be chasing randomly moving objects across the screen.  So I just want to know how to get the objects/sprites to move by themselves to random locations.

-----------------------------------
Insectoid
Sat May 30, 2015 6:13 pm

RE:How to make sprites move randomly?
-----------------------------------
Can you make a sprite move to a non-random location?

-----------------------------------
happyfacelegion
Sat May 30, 2015 7:12 pm

RE:How to make sprites move randomly?
-----------------------------------
By itself? No, but I can make the sprite user controlled. That's about it

-----------------------------------
Insectoid
Sat May 30, 2015 7:24 pm

RE:How to make sprites move randomly?
-----------------------------------
All right, well, remember all that trigonometry you did in math class? Now you get to use it.

Let's say your sprite is at point P1(x,y) and you want him to move to point P(x2, y2). These two points form a right triangle. Using trigonometry with these two points you can calculate how much to add to the sprite's coordinates to move it in the direction of the goal. I'm not going to go into detail because you've probably learned all this in math class, you just need to figure out how to translate it into code.
