Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 How to make sprites move randomly?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
happyfacelegion




PostPosted: Sat May 30, 2015 3:43 pm   Post subject: How to make sprites move randomly?

What is it you are trying to achieve?
<Replace all the <> with your answers/code and remove the <>>


What is the problem you are having?
<Answer Here>


Describe what you have tried to solve this problem
<Answer Here>


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>

Turing:


<Add your code here>



Please specify what version of Turing you are using
<Answer Here>
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Sat May 30, 2015 4:00 pm   Post subject: 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




PostPosted: Sat May 30, 2015 4:16 pm   Post subject: 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




PostPosted: Sat May 30, 2015 6:13 pm   Post subject: RE:How to make sprites move randomly?

Can you make a sprite move to a non-random location?
happyfacelegion




PostPosted: Sat May 30, 2015 7:12 pm   Post subject: RE:How to make sprites move randomly?

By itself? No, but I can make the sprite user controlled. That's about it
Insectoid




PostPosted: Sat May 30, 2015 7:24 pm   Post subject: 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.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: