473,396 Members | 2,009 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Animation problems

im doing an applet and this is what i have so far

Expand|Select|Wrap|Line Numbers
  1. import java.awt.*;
  2. import java.awt.event.*;
  3. import java.applet.*;
  4. import javax.swing.*;
  5. public class Applet1 extends JApplet
  6. {
  7.  Thread t = new Thread();;
  8. int p1;
  9. int p2;
  10. int a=0;
  11. int b=50; 
  12. int c=125;
  13. int d=115;
  14. int e=50;
  15. int f=300;
  16. int j=300;
  17. int h=325;
  18. int i=325;
  19. int ani=480;
  20. int [] x = {b+a,c+a,d+a,e+a};
  21. int [] y = {f+a,j+a,h+a,i+a};
  22. public void paint(Graphics g)
  23. {
  24. g.setColor(Color.black);
  25. g.fillRect(0,0,500,300);
  26. g.setColor(Color.blue);
  27. g.fillRect(0,300,500,500);
  28.  
  29. g.setColor(Color.white);
  30. for(int a=1;a<=342;a=a+2)
  31. {
  32.  
  33.  p1=1+(int) (Math.random()*600);
  34. p2=1+(int) (Math.random()*254);
  35. g.fillOval(p1,p2,1,1);
  36. }
  37. g.fillOval(450,30,25,25);
  38. {
  39. ani=ani-1;
  40. g.setColor(Color.gray);
  41. g.fillOval(ani,70,60,40);
  42. g.fillOval(ani,90,70,30);
  43. g.fillOval(ani-20,105,60,30);
  44. try{t.sleep(100);} catch(Exception e){}
  45. g.setColor(Color.gray);
  46. g.fillOval(ani,85,50,20);
  47. if(ani<500)repaint();
  48. }
  49. }
  50. }
  51.  
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
Feb 26 '08 #1
2 936
Heres two hints...
1) Look at your Paint Method.
2) Decide where your Math.Rand should be.
Feb 26 '08 #2
BigDaddyLH
1,216 Expert 1GB
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
Feb 26 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
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...
5
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...
11
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...
6
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...
3
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...
2
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...
1
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. ...
0
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>...
4
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...
8
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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...
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.