NEED Help with moving objects!!!
Author |
Message |
Waylon777
|
Posted: 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
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
|
|
|
HellblazerX
|
Posted: 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
|
Posted: 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
|
Posted: 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.
|
|
|
|
|
|
|
|