home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.awt.Component;
- import java.awt.Dimension;
- import java.awt.Event;
- import java.awt.Graphics;
- import java.awt.Image;
-
- public class OldShellGame extends Applet {
- static int time = 50;
- static int numframes = 8;
- boolean running = false;
- static int[] movesX0 = new int[]{0, 0, 0, 284, 0, 142, 284, 142, 142};
- static int[] movesY0 = new int[]{50, 50, 50, 176, 50, 176, 50, 176, 50};
- static int[] movesX1 = new int[]{142, 142, 142, 142, 284, 0, 0, 0, 284};
- static int[] movesY1 = new int[]{50, 50, 50, 176, 50, 176, 50, 176, 50};
- static int[] movesX2 = new int[]{284, 126, 284, 0, 142, 284, 142, 284, 0};
- static int[] movesY2 = new int[]{50, 176, 50, 176, 50, 176, 50, 176, 50};
- static int[] movesX3 = new int[]{142, 142, 300, 16, 158, 300, 158, 300, 16};
- static int[] movesY3 = new int[]{192, 192, 66, 192, 66, 192, 66, 192, 66};
- int[] left = new int[]{0, 142, 284, 142};
- int[] top = new int[]{50, 50, 50, 192};
- Image shell;
- Image stone;
-
- public void init() {
- this.stone = ((Applet)this).getImage(((Applet)this).getCodeBase(), "gem.gif");
- this.shell = ((Applet)this).getImage(((Applet)this).getCodeBase(), "walnut.gif");
- }
-
- public void paint(Graphics var1) {
- int var2 = 0;
- int var3 = 1;
- Dimension var4 = ((Component)this).size();
- var1.fillRect(0, 0, var4.width, var4.height);
- var1.drawImage(this.stone, this.left[3], this.top[3], this);
- var1.drawImage(this.shell, this.left[0], this.top[0], this);
- var1.drawImage(this.shell, this.left[1], this.top[1], this);
- var1.drawImage(this.shell, this.left[2], this.top[2], this);
- if (this.running) {
- for(; var2 < time * numframes; this.Delay(200L, var2)) {
- this.left[0] = movesX0[var3 - 1] + (movesX0[var3] - movesX0[var3 - 1]) * (var2 % time) / time;
- this.top[0] = movesY0[var3 - 1] + (movesY0[var3] - movesY0[var3 - 1]) * (var2 % time) / time;
- this.left[1] = movesX1[var3 - 1] + (movesX1[var3] - movesX1[var3 - 1]) * (var2 % time) / time;
- this.top[1] = movesY1[var3 - 1] + (movesY1[var3] - movesY1[var3 - 1]) * (var2 % time) / time;
- this.left[2] = movesX2[var3 - 1] + (movesX2[var3] - movesX2[var3 - 1]) * (var2 % time) / time;
- this.top[2] = movesY2[var3 - 1] + (movesY2[var3] - movesY2[var3 - 1]) * (var2 % time) / time;
- this.left[3] = movesX3[var3 - 1] + (movesX3[var3] - movesX3[var3 - 1]) * (var2 % time) / time;
- this.top[3] = movesY3[var3 - 1] + (movesY3[var3] - movesY3[var3 - 1]) * (var2 % time) / time;
- var1.fillRect(0, 0, var4.width, var4.height);
- if (var2 < time || var2 >= time * numframes) {
- var1.drawImage(this.stone, this.left[3], this.top[3], this);
- }
-
- var1.drawImage(this.shell, this.left[0], this.top[0], this);
- var1.drawImage(this.shell, this.left[1], this.top[1], this);
- var1.drawImage(this.shell, this.left[2], this.top[2], this);
- ++var2;
- if (var2 % time == 0 && var3 < numframes) {
- ++var3;
- }
- }
- }
-
- this.running = false;
- }
-
- public boolean mouseUp(Event var1, int var2, int var3) {
- this.running = true;
- this.left[3] = 142;
- this.top[3] = 192;
- ((Component)this).repaint();
- return true;
- }
-
- public void Delay(long var1, int var3) {
- long var4 = 0L;
- long var6 = 0L;
-
- for(long var8 = 0L; var8 < var1; ++var8) {
- ++var6;
- }
-
- }
- }
-