im doing an applet and this is what i have so far - import java.awt.*;
-
import java.awt.event.*;
-
import java.applet.*;
-
import javax.swing.*;
-
public class Applet1 extends JApplet
-
{
-
Thread t = new Thread();;
-
int p1;
-
int p2;
-
int a=0;
-
int b=50;
-
int c=125;
-
int d=115;
-
int e=50;
-
int f=300;
-
int j=300;
-
int h=325;
-
int i=325;
-
int ani=480;
-
int [] x = {b+a,c+a,d+a,e+a};
-
int [] y = {f+a,j+a,h+a,i+a};
-
public void paint(Graphics g)
-
{
-
g.setColor(Color.black);
-
g.fillRect(0,0,500,300);
-
g.setColor(Color.blue);
-
g.fillRect(0,300,500,500);
-
-
g.setColor(Color.white);
-
for(int a=1;a<=342;a=a+2)
-
{
-
-
p1=1+(int) (Math.random()*600);
-
p2=1+(int) (Math.random()*254);
-
g.fillOval(p1,p2,1,1);
-
}
-
g.fillOval(450,30,25,25);
-
{
-
ani=ani-1;
-
g.setColor(Color.gray);
-
g.fillOval(ani,70,60,40);
-
g.fillOval(ani,90,70,30);
-
g.fillOval(ani-20,105,60,30);
-
try{t.sleep(100);} catch(Exception e){}
-
g.setColor(Color.gray);
-
g.fillOval(ani,85,50,20);
-
if(ani<500)repaint();
-
}
-
}
-
}
-
the one problem is is when i animate the cloud to move, it repaints the stars in the back round again using the math.random..
what am i doing wrong? im pretty sure every thing is inside a bracket, and dont mind all my ints and the array that i havent used yet..just need to know about the animation
2 936
Heres two hints...
1) Look at your Paint Method.
2) Decide where your Math.Rand should be.
Please enclose your posted code in [code] tags (See How to Ask a Question).
This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.
Please use [code] tags in future.
MODERATOR
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Simena Dinas |
last post by:
KToon: 2D Animation Toolkit
KToon is a 2D Animation Toolkit designed by animators (Toonka Films)
for animators, focused to the Cartoon's industry.
This project is covered by the GPL License...
|
by: Brian Angliss |
last post by:
I'm relatively new to scripting in JavaScript, so I'm not too
surprised I'm having difficulty scripting up an animation effect for
my personal site.
What I'm trying to do is the following: When...
|
by: Eugene |
last post by:
Setting backcolor for the animation control does not take
effect.
The BackStyle property is set to cc2BackstyleTransparent.
No matter what BackColor property is set to, in run time
the backcolor...
|
by: Darren |
last post by:
X-No-Archive
Hi all,
Can anyone help me with structuring the data in a small tool I have to
build? I'm trying to work out if there's a design pattern or data
structure that would remove some...
|
by: James |
last post by:
Hello,
I'm new to c# and have created an animation which draws directly
to the window, it uses the code below which all works. I would
like to know if this is the 'correct' way to do it - or...
|
by: rdemyan via AccessMonster.com |
last post by:
My application has a lot of complicated SQL statements, calculations,
processing that takes time. I've created a custom form to act like a
messagebox. It has 10 small rectangles on it that change...
|
by: jsavagedesign |
last post by:
This is a project I have been working on lately and I keep running into problems.
The idea is to be able to attaching an animation to a movie clip and call it later. Or multiple animation at once.
...
|
by: shapper |
last post by:
Hello,
I need to create the following code at runtime:
<ajaxToolkit:UpdatePanelAnimationExtender ID="upae"
BehaviorID="animation" runat="server" TargetControlID="updatePanel">
<Animations>...
|
by: Sin Jeong-hun |
last post by:
Most applications, including Windows Explorer, show some sort of
'wait' dialog with animation when a lengthy operation is going on. For
example, When the Windows Explorer is searching for...
|
by: DelphiCoder |
last post by:
As part of familiarizing myself with the Win32 API, I wrote a simple animation program in C. The program has a struct for each bitmap, holding information such as its location, visibility, mask (for...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |