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

Username:   Password: 
 RegisterRegister   
 NEED Help with moving objects!!!
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Waylon777




PostPosted: Wed Nov 26, 2008 9:58 pm   Post subject: NEED Help with moving objects!!!

I need a help to move the mouth of this happy face like open, close, and eventually want to rotate the eyes, but I can't find anything that can make it move around or rotate. I use RTP (sorry if this is a bad choice for any people). I am a bit illiterate in programming lunguage so sorry if that makes you guys harder to answer. It would be very thankful if any people can help.

// The "HappyFace" class.
import java.awt.*;
import hsa.Console;

public class HappyFace
{
static Console c; // The output console

public static void main (String[] args)
{
c = new Console ();

c.setColor (Color.yellow);
c.fillOval (100, 100, 300, 300);

c.setColor (Color.white);
c.fillOval (170, 180, 40, 40);
c.fillOval (285, 180, 40, 40);


c.setColor (Color.pink);
c.fillArc (202, 270, 100, 100, 0, -180);

// Place your program here. 'c' is the output console
} // main method
} // HappyFace class



HappyFace.java
 Description:
if you cannot copy and paste the one over there, download this one.

Download
 Filename:  HappyFace.java
 Filesize:  570 Bytes
 Downloaded:  95 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
HellblazerX




PostPosted: Wed Nov 26, 2008 10:13 pm   Post subject: RE:NEED Help with moving objects!!!

If you want animation, what you'll have to do is put your draw commands into a loop, and store the location of each object into variables. To make your objects "move", just change the values of the locations and draw the objects at the new location. Don't forget to refresh your screen with every loop (easiest way to do that is to draw a white rectangle that encompasses the whole window).
DemonWasp




PostPosted: Wed Nov 26, 2008 10:16 pm   Post subject: RE:NEED Help with moving objects!!!

To do this, you will need to separate drawing into a routine (method) that you can call as you will. You will need to base the location that the mouth (presumably the c.fillArc(...) command) on a variable, which you will change to move the eyes and mouth.

Then, you will need to have something like this:
code:

while ( still running ) {
    update variables to represent correct face / mouth positions
    blank screen
    call draw method to update the screen
}
facultyofmusic




PostPosted: Tue Feb 03, 2009 4:46 pm   Post subject: Re: NEED Help with moving objects!!!

You might want to use a for loop? Cuz that's how we learned to do simple animations. Btw I suggest you to use java syntax.
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: