Write a program that draws 1000 random lines of length 300 pixels, each with a random color. All line angles should be equally likely.
Write a program that displays an animation of the inner Solar System, with the Sun at the center. Assume that planets' orbits are circular. Mark each planet's orbit with a gray circle.
Use the following data, which is based on these assumptions:
1 simulation second = 10 days of actual time
1 pixel = 500,000 km
planets are drawn 1000x actual size
Sun is drawn 25x actual size
body |
radius (pixels) |
color |
dist from Sun (pixels) |
orbital period (sec) |
---|---|---|---|---|
Sun |
35 |
(254, 143, 54) |
0 |
n/a |
Mercury |
5 |
(191, 144, 114) |
116 |
8.8 |
Venus |
12 |
(244, 190, 190) |
216 |
22.5 |
Earth |
13 |
(94, 192, 227) |
300 |
36.5 |
Mars |
7 |
(222, 70, 49) |
456 |
68.7 |
Write a program that lets the user draw squares by dragging the mouse. Each square should have a random color.
Extend the previous program so that the user can move a square to a new position by clicking and dragging it. A moved square should rise to the top of the Z-order.
Write a program that displays an equilateral triangle at the center of the window. The user should be able to rotate the triangle by holding down the left or right arrow keys.
Extend the previous program to display a spaceship in the form of a elongated triangle. The arrow keys should rotate the ship, and the A key should thrust it forward.
Write a program that animates a bubble sort. The application should display a row of random integers. As the bubble sort proceeds, adjacent integers should exchange positions by rotating around a point between them.
Write a program that displays the Towers of Hanoi, with 5 discs initially on the left peg. Each time the user presses the space bar, display the next step in the sequence of moves that will move all discs to the right peg.
Implement the game of Simon .
Write a program that lets two players play tic tac toe. A mouse click should place a mark (X or O) for the current player. If any player wins, highlight the winning squares.