![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Oct 2008
Location: Geekville
Posts: 20
Rep Power: 0
![]() |
So far I am making a screensaver and it is going pretty well. WHat i have made is a picnic table with a plate and a spoon and a fork on it. I am using ready to program java. When i play my screensaver, the pinic table starts blinking and the utensils are already on it. What i cant figure out is how to make the picnic table flash for a little while and THEN the palte and spoon, fork pop up (so it looks like someone just put the utensils on). How would I do that?? What do i put in the for loop?? Or does it go in the thread.sleep thingy. Here is the code:
while (true)//create a while loop for animation { //do the opposite of the checks to make it look like they are flashing Color whitechecks= new Color (255,255,255);//get the color red wanted c.setColor (whitechecks);//set the color red c.fillRect(0,0,50,50);//fill the rectangle needed to make the checks c.fillRect(100,0,50,50);//clear the rectangle c.fillRect(200,0,50,50);//clear the rectangle c.fillRect(300,0,50,50);//clear the rectangle c.fillRect(400,0,50,50);//clear the rectangle c.fillRect(500,0,50,50);//clear the rectangle c.fillRect(600,0,50,50);//clear the rectangle c.fillRect(50,50,50,50);//clear the rectangle c.fillRect(150,50,50,50);//clear the rectangle c.fillRect(250,50,50,50);//clear the rectangle c.fillRect(350,50,50,50);//clear the rectangle c.fillRect(450,50,50,50);//clear the rectangle c.fillRect(550,50,50,50);//clear the rectangle c.fillRect(0,100,50,50);//clear the rectangle c.fillRect(100,100,50,50);//clear the rectangle c.fillRect(200,100,50,50);//clear the rectangle c.fillRect(300,100,50,50);//clear the rectangle c.fillRect(400,100,50,50);//clear the rectangle c.fillRect(500,100,50,50);//clear the rectangle c.fillRect(600,100,50,50);//clear the rectangle c.fillRect(50,150,50,50);// clear the rectangle c.fillRect(150,150,50,50);//clearthe rectangle c.fillRect(250,150,50,50);//clearthe rectangle c.fillRect(350,150,50,50);//clear the rectangle c.fillRect(450,150,50,50);//clear the rectangle c.fillRect(550,150,50,50);//clear the rectangle c.fillRect(0,200,50,50);//clear the rectangle c.fillRect(100,200,50,50);//clear the rectangle c.fillRect(200,200,50,50);//clear the rectangle c.fillRect(300,200,50,50);//clear the rectangle c.fillRect(400,200,50,50);//clear the rectangle c.fillRect(500,200,50,50);//clear the rectangle c.fillRect(600,200,50,50);//clear the rectangle c.fillRect(50,250,50,50);//clear the rectangle c.fillRect(150,250,50,50);//clear the rectangle c.fillRect(250,250,50,50);//clear the rectangle c.fillRect(350,250,50,50);//clear the rectangle c.fillRect(450,250,50,50);//clear the rectangle c.fillRect(550,250,50,50);//clear the rectangle c.fillRect(0,300,50,50);//clear the rectangle c.fillRect(100,300,50,50);//clear the rectangle c.fillRect(200,300,50,50);//clear the rectangle c.fillRect(300,300,50,50);//clear the rectangle c.fillRect(400,300,50,50);//clear the rectangle c.fillRect(500,300,50,50);//clear the rectangle c.fillRect(600,300,50,50);//clear the rectangle c.fillRect(50,350,50,50);//clear the rectangle c.fillRect(150,350,50,50);//clear the rectangle c.fillRect(250,350,50,50);//clear the rectangle c.fillRect(350,350,50,50);//clear the rectangle c.fillRect(450,350,50,50);//clear the rectangle c.fillRect(550,350,50,50);//clear the rectangle c.fillRect(0,400,50,50);//clear the rectangle c.fillRect(100,400,50,50);//clear the rectangle c.fillRect(200,400,50,50);//clear the rectangle c.fillRect(300,400,50,50);//clear the rectangle c.fillRect(400,400,50,50);//clear the rectangle c.fillRect(500,400,50,50);//clear the rectangle c.fillRect(600,400,50,50);//clear the rectangle c.fillRect(50,450,50,50);//clear the rectangle c.fillRect(150,450,50,50);//clear the rectangle c.fillRect(250,450,50,50);//clear the rectangle c.fillRect(350,450,50,50);//clear the rectangle c.fillRect(450,450,50,50);//clear the rectangle c.fillRect(550,450,50,50);//clear the rectangle Color plate= new Color (255,255,255);//get the color c.setColor (plate);//set the color c.fillOval(125,60,400,400);//fill the oval Color plateoutline= new Color (0,0,0);//get the color c.setColor (plateoutline);//set the color c.drawOval(125,60,400,400);//make the outline Color insideplateoutline=new Color (0,0,0);//get the color c.setColor (insideplateoutline);//set the color c.drawOval(170,110,300,300);//make the outline //below is the spoon Color spoonhandle= new Color (255,255,255);//get the color c.setColor (spoonhandle);//set the color c.fillRect(58,187,20,230);//draw the rectangle for the spoons handle Color spoonhandleoutline= new Color (0,0,0);//get the color c.setColor (spoonhandleoutline);//set the color c.drawRect(58,187,20,230);//draw the outline for the handle Color spoon= new Color (255,255,255);//get the color c.setColor (spoon);//set the color c.fillOval(28,100,75,95);//fill the oval for the spoons head Color spoonoutline= new Color (0,0,0);//get the color c.setColor (spoonoutline);//set the color c.drawOval(28,100,75,95);//make the outline for the spoon c.clearRect(59,187,18,18);//clear the outline of the handle that overlaps the spoons circle and makes it look fake //below is the fork Color prong=new Color (255,255,255);//get the color c.setColor (prong);//set the color c.fillRect(550,100,12,80);//fill the rectangle for the prong Color prongoutline1= new Color (0,0,0);//get the color c.setColor (prongoutline1);//set the color c.drawRect(550,100,12,80);//make the outline Color prong2=new Color (255,255,255);//get the color c.setColor (prong2);//set the color c.fillRect(570,100,12,80);//fill the rectangle for the prong Color prongoutline2= new Color (0,0,0);//get the color c.setColor (prongoutline2);//set the color c.drawRect(570,100,12,80);//make the outline Color prong3=new Color (255,255,255);//get the color c.setColor (prong3);//set the color c.fillRect(590,100,12,80);//fill the rectangle for the prong Color prongoutline3= new Color (0,0,0);//get the color c.setColor (prongoutline3);//set the color c.drawRect(590,100,12,80);//make the outline Color fork=new Color (255,255,255);//get the color c.setColor (fork);//set the color c.fillRect(550,180,52,40);//fill the rectangle for the prong c.drawRect(550,180,52,40);//make the body of the fork that holds the prongs together Color forkoutline= new Color (0,0,0);//get the color c.setColor (forkoutline);//set the color c.drawRect(550,180,52,40);//make the outline Color forkhandle= new Color (255,255,255);//get the color c.setColor (forkhandle);//set the color c.fillRect(565,195,20,230);//draw the rectangle for the forks handle Color forkhandleoutline= new Color (0,0,0);//get the color c.setColor (forkhandleoutline);//set the color c.drawRect(565,195,20,230);//draw the outline for the handle c.clearRect(565,191,21,30);//fix up the line that connects the handle to the body which makes it look fake. c.clearRect(551,178,11,10);//fix up the parts where the prongs are connected to the body. c.clearRect(571,178,11,10);//fix up the parts where the second prong is connected to the body c.clearRect(591,178,11,10);//fix up the parts where the third prong is connected to the body for (int i = 0 ; i <20 ; i++)//created a for loop that goes by three to make it match with the previous loop { Thread.sleep (30);//make the animation sleep for a little while } Color redchecks= new Color (255,102,102);//get the color red wanted c.setColor (redchecks);//set the color red c.fillRect(0,0,50,50);//fill the rectangle needed to make the checks //continue this process c.fillRect(100,0,50,50);//fill the rectangle c.fillRect(200,0,50,50);//fill the rectangle c.fillRect(300,0,50,50);//fill the rectangle c.fillRect(400,0,50,50);//fill the rectangle c.fillRect(500,0,50,50);//fill the rectangle c.fillRect(600,0,50,50);//fill the rectangle c.fillRect(50,50,50,50);//fill the rectangle c.fillRect(150,50,50,50);//fill the rectangle c.fillRect(250,50,50,50);//fill the rectangle c.fillRect(350,50,50,50);//fill the rectangle c.fillRect(450,50,50,50);//fill the rectangle c.fillRect(550,50,50,50);//fill the rectangle c.fillRect(0,100,50,50);//fill the rectangle c.fillRect(100,100,50,50);//fill the rectangle c.fillRect(200,100,50,50);//fill the rectangle c.fillRect(300,100,50,50);//fill the rectangle c.fillRect(400,100,50,50);//fill the rectangle c.fillRect(500,100,50,50);//fill the rectangle c.fillRect(600,100,50,50);//fill the rectangle c.fillRect(50,150,50,50);//fill the rectangle c.fillRect(150,150,50,50);//fill the rectangle c.fillRect(250,150,50,50);//fill the rectangle c.fillRect(350,150,50,50);//fill the rectangle c.fillRect(450,150,50,50);//fill the rectangle c.fillRect(550,150,50,50);//fill the rectangle c.fillRect(0,200,50,50);//fill the rectangle c.fillRect(100,200,50,50);//fill the rectangle c.fillRect(200,200,50,50);//fill the rectangle c.fillRect(300,200,50,50);//fill the rectangle c.fillRect(400,200,50,50);//fill the rectangle c.fillRect(500,200,50,50);//fill the rectangle c.fillRect(600,200,50,50);//fill the rectangle c.fillRect(50,250,50,50);//fill the rectangle c.fillRect(150,250,50,50);//fill the rectangle c.fillRect(250,250,50,50);//fill the rectangle c.fillRect(350,250,50,50);//fill the rectangle c.fillRect(450,250,50,50);//fill the rectangle c.fillRect(550,250,50,50);//fill the rectangle c.fillRect(0,300,50,50);//fill the rectangle c.fillRect(100,300,50,50);//fill the rectangle c.fillRect(200,300,50,50);//fill the rectangle c.fillRect(300,300,50,50);//fill the rectangle c.fillRect(400,300,50,50);//fill the rectangle c.fillRect(500,300,50,50);//fill the rectangle c.fillRect(600,300,50,50);//fill the rectangle c.fillRect(50,350,50,50);//fill the rectangle c.fillRect(150,350,50,50);//fill the rectangle c.fillRect(250,350,50,50);//fill the rectangle c.fillRect(350,350,50,50);//fill the rectangle c.fillRect(450,350,50,50);//fill the rectangle c.fillRect(550,350,50,50);//fill the rectangle c.fillRect(0,400,50,50);//fill the rectangle c.fillRect(100,400,50,50);//fill the rectangle c.fillRect(200,400,50,50);//fill the rectangle c.fillRect(300,400,50,50);//fill the rectangle c.fillRect(400,400,50,50);//fill the rectangle c.fillRect(500,400,50,50);//fill the rectangle c.fillRect(600,400,50,50);//fill the rectangle c.fillRect(50,450,50,50);//fill the rectangle c.fillRect(150,450,50,50);//fill the rectangle c.fillRect(250,450,50,50);//fill the rectangle c.fillRect(350,450,50,50);//fill the rectangle c.fillRect(450,450,50,50);//fill the rectangle c.fillRect(550,450,50,50);//fill the rectangle //added the same code as the top because the flashing checks keep on overlapping the circle and appearing on top. //below is the plate Color plate1= new Color (255,255,255);//get the color c.setColor (plate1);//set the color c.fillOval(125,60,400,400);//fill the oval Color plateoutline1= new Color (0,0,0);//get the color c.setColor (plateoutline1);//set the color c.drawOval(125,60,400,400);//make the outline Color insideplateoutline1=new Color (0,0,0);//get the color c.setColor (insideplateoutline1);//set the color c.drawOval(170,110,300,300);//make the outline //below is the spoon Color spoonhandle1= new Color (255,255,255);//get the color c.setColor (spoonhandle1);//set the color c.fillRect(58,187,20,230);//draw the rectangle for the spoons handle Color spoonhandleoutline1= new Color (0,0,0);//get the color c.setColor (spoonhandleoutline1);//set the color c.drawRect(58,187,20,230);//draw the outline for the handle Color spoon1= new Color (255,255,255);//get the color c.setColor (spoon1);//set the color c.fillOval(28,100,75,95);//fill the oval for the spoons head Color spoonoutline1= new Color (0,0,0);//get the color c.setColor (spoonoutline1);//set the color c.drawOval(28,100,75,95);//make the outline for the spoon c.clearRect(59,187,18,18);//clear the outline of the handle that overlaps the spoons circle and makes it look fake //below is the fork Color prong1=new Color (255,255,255);//get the color c.setColor (prong1);//set the color c.fillRect(550,100,12,80);//fill the rectangle for the prong Color prongoutline= new Color (0,0,0);//get the color c.setColor (prongoutline);//set the color c.drawRect(550,100,12,80);//make the outline Color prong12=new Color (255,255,255);//get the color c.setColor (prong12);//set the color c.fillRect(570,100,12,80);//fill the rectangle for the prong Color prongoutline12= new Color (0,0,0);//get the color c.setColor (prongoutline12);//set the color c.drawRect(570,100,12,80);//make the outline Color prong13=new Color (255,255,255);//get the color c.setColor (prong13);//set the color c.fillRect(590,100,12,80);//fill the rectangle for the prong Color prongoutline13= new Color (0,0,0);//get the color c.setColor (prongoutline13);//set the color c.drawRect(590,100,12,80);//make the outline Color fork1=new Color (255,255,255);//get the color c.setColor (fork1);//set the color c.fillRect(550,180,52,40);//fill the rectangle for the prong c.drawRect(550,180,52,40);//make the body part of the fork that holds the prongs together Color forkoutline1= new Color (0,0,0);//get the color c.setColor (forkoutline1);//set the color c.drawRect(550,180,52,40);//make the outline Color forkhandle1= new Color (255,255,255);//get the color c.setColor (forkhandle1);//set the color c.fillRect(565,195,20,230);//draw the rectangle for the forks handle Color forkhandleoutline1= new Color (0,0,0);//get the color c.setColor (forkhandleoutline1);//set the color c.drawRect(565,195,20,230);//draw the outline for the handle c.clearRect(565,191,21,30);//fix up the line that connects the handle to the body which makes it look fake. c.clearRect(551,178,11,10);//fix up the parts where the prongs are connected to the body. c.clearRect(571,178,11,10);//fix up the parts where the second prong is connected to the body c.clearRect(591,178,11,10);//fix up the parts where the third prong is connected to the body for (int i = 0 ; i <30 ; i++)//created a for loop that goes by 3 which is not too fast or slow { Thread.sleep (40);//make the checks sleep } } |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
Join Date: Aug 2008
Location: Ontario
Posts: 149
Rep Power: 1
![]() |
Re: Comp Sci help!
Firstly, try to use code tags, I let it slide last time but reading through all that code in regular text is a pain.
Now that that's done: Remember that your code executes at the top and works down, so to do something before something else you just have to put it before the other thing. Like this: For (5sec) Flash the plate End While (true) //your rectangles are already drawn so draw the other stuff on top Draw a thing pause Draw a thing pause ...etc Do the rest of the animations End
__________________
A man sees a bear. He walks 100m south, 100m west and 100m north, ending up right where he began. What colour is the bear? Answer (PM me if you want an explanation) |
|
|
|
|
|
#3 | |
|
Newbie
Join Date: Oct 2008
Location: Geekville
Posts: 20
Rep Power: 0
![]() |
Quote:
|
|
|
|
|
|
|
#4 |
|
Hobbyist Programmer
Join Date: Aug 2008
Location: Ontario
Posts: 149
Rep Power: 1
![]() |
Re: Comp Sci help!
java Syntax (Toggle Plain Text)
And it will first execute the rectangles, then the utensils and plate. If you add the delays where I said, it will look like they are being added one at a time. Try it, and see if you can figure WHY things happen the way they do. Just ask if you still don't get it, but don't expect me to right the whole program for you. ![]() PS: See how the code tags help?
__________________
A man sees a bear. He walks 100m south, 100m west and 100m north, ending up right where he began. What colour is the bear? Answer (PM me if you want an explanation) |
|
|
|
|
|
#5 |
|
Newbie
Join Date: Oct 2008
Location: Geekville
Posts: 20
Rep Power: 0
![]() |
Re: Comp Sci help!
Thanks alot!! that really helped!! Sorry, i just signed up with programming froums and i never knew there were code tags. I will tag my codes from now on,thanks for your help!
|
|
|
|
|
|
#6 |
|
Hobbyist Programmer
Join Date: Aug 2008
Location: Ontario
Posts: 149
Rep Power: 1
![]() |
Re: Comp Sci help!
No problem, glad to help.
__________________
A man sees a bear. He walks 100m south, 100m west and 100m north, ending up right where he began. What colour is the bear? Answer (PM me if you want an explanation) |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Thinking of building my first comp. | Xero | Coder's Corner Lounge | 23 | Jul 23rd, 2005 10:54 PM |
| New Comp. | Cipher | Coder's Corner Lounge | 12 | Mar 28th, 2005 10:01 AM |