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 944
Heres two hints...
1) Look at your Paint Method.
2) Decide where your Math.Rand should be.
BigDaddyLH 1,216
Recognized Expert Top Contributor
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 using G++, OpenGL and QT as
programming resources from KDevelop as the development platform.
One year later of production, it is a pleasure for Toonka Films
announces to the Free Software community the release of the KToon
|
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 I go onMouseOver on a
button in a nav bar, I want that button to switch to a different image
while at the same time another blank image changes as an animation to
an associated image. When I go onMouseOut, the bar image reverts back
to the...
|
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 is always SystemColors.Control.
|
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 of the dependencies.
I am designing an animation tool.
|
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 would an
experienced c# programmer do it another way?
This part defines the screen and the graphics pad I'm drawing to:
Graphics screen = CreateGraphics();
Graphics drawpadg = Graphics.FromImage(drawpad);
| |
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 color sequentially
to let the user know that processing is occurring. This 'animation' occurs
via the form timer event.
However, I'm having trouble getting the animation to occur for all types of
processing events. It appears that I have to...
|
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.
example:
on the stage you have a black box called: myClip
in actionscript you type:
growClip = grow(myClip);
spinClip = spin(myClip);
now when you call:
|
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>
<OnUpdating>
<Parallel duration="0">
<ScriptAction Script="onUpdating();" />
|
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 something, it
shows a small dialog with a moving flashlight. I examined the
explorer.exe and found that that was an avi file.
Now that, I would like to do similar thing in my C# application. But
what is the most efficient way to do so?
1)Manually...
|
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 transparency), etc. Then I have a separate thread running that has a WHILE loop that looks like this:
WHILE (TRUE)
{
/* update all structs (bitmap locations, etc) */
SleepEx(iSpeed, FALSE);
InvalidateRect(hwnd, lpRect, TRUE);
}
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |