import java.awt.*; import java.awt.image.*; import java.net.*; import java.applet.*; public class OldShellGame extends Applet { static int time=50; // Liczba taktów zegara pomiędzy klatkami static int numframes=8; // Liczba klatek w animacji boolean running=false; // Włączanie/wyłączanie animacji /** Ulokowanie obrazów */ static int movesX0[] = {0,0,0,284,0,142,284,142,142}; static int movesY0[] = {50,50,50,176,50,176,50,176,50}; static int movesX1[] = {142,142,142,142,284,0,0,0,284}; static int movesY1[] = {50,50,50,176,50,176,50,176,50}; static int movesX2[] = {284,126,284,0,142,284,142,284,0}; static int movesY2[] = {50,176,50,176,50,176,50,176,50}; static int movesX3[] = {142,142,300,16,158,300,158,300,16}; static int movesY3[] = {192,192,66,192,66,192,66,192,66}; /** Aktualne ulokowanie obrazów */ int left[] = {0,142,284,142}; int top[] = {50,50,50,192}; /** Obrazy do gry */ Image shell; Image stone; /** Inicjalizacja apletu. Dop. rozmiarów i ładowanie obrazów. */ public void init() { stone = getImage(getCodeBase(), "gem.gif"); shell = getImage(getCodeBase(), "walnut.gif"); } /** Maluj to. */ public void paint(Graphics g) { int count = 0; int curframe = 1; Dimension d = size(); g.fillRect(0,0,d.width,d.height); g.drawImage(stone, left[3], top[3], this); g.drawImage(shell, left[0], top[0], this); g.drawImage(shell, left[1], top[1], this); g.drawImage(shell, left[2], top[2], this); if(running) { while(count < time*numframes) { left[0] = movesX0[curframe-1] + ((movesX0[curframe]-movesX0[curframe-1])* (count % time)/time); top[0]=movesY0[curframe-1] + ((movesY0[curframe]-movesY0[curframe-1])* (count % time)/time); left[1]=movesX1[curframe-1] + ((movesX1[curframe]-movesX1[curframe-1])* (count % time)/time); top[1]=movesY1[curframe-1] + ((movesY1[curframe]-movesY1[curframe-1])* (count % time)/time); left[2]=movesX2[curframe-1] + ((movesX2[curframe]-movesX2[curframe-1])* (count % time)/time); top[2]=movesY2[curframe-1] + ((movesY2[curframe]-movesY2[curframe-1])* (count % time)/time); left[3]=movesX3[curframe-1] + ((movesX3[curframe]-movesX3[curframe-1])* (count % time)/time); top[3]=movesY3[curframe-1] + ((movesY3[curframe]-movesY3[curframe-1])* (count % time)/time); g.fillRect(0,0,d.width,d.height); if(count