½º·¹µå¿¡ ¼Ò¸®¸¦ ³Ö°íÀÚ...


[ ´ÙÀ½ ±Ûµé ] [ À̾ ±Û¿Ã¸®±â(´äÇϱâ) ] [ ÀÚ¹Ù ¹¯°í ´äÇϱâ ]

±Û¾´ÀÌ :°íÀºÁ¤ 2000³â 6¿ù 08ÀÏ 21:59:54

°³±¸¸® 7¸¶¸®°¡ È£ÈíÇÏ´Â ÇÁ·Î±×·¥Àä..


¼Ò¸®¸¦ ³Ö°í ½ÍÀºµ¥... Àß ¾ÈµÇ³×¿ä..


°í¼ö´Ôµé ºÎŹµå¸³´Ï´ç..


±×¸²ÆÄÀÏÀÌ 5°³ ÇÊ¿äÇØ¿ä.. µ¹¸±·Á¸é.. ÀÌ°Å.. ^^
/* In this applet program, A frog bluffs only.
A frog make a sound when his belly is in limit
and changes his size.
The number of the images of frog is 5.
so a frog has his five states.
*/

import java.applet.*;
import java.io.*;
import java.awt.*;


class FrogImage extends Thread{
public int x = 0;
public int y = 0;
public int index;
public int current = 0;
private final int NUMFROG = 7;
private int capacity[];
private final int THESHOLD = 40; // from 0 to 40 ( i.e. 0, 10, 20, 30, 40 )
private final int INHALE[] = { 5, 10, 20};
private int location[][];

Frog parents;

public FrogImage(Frog parents) {
this.parents = parents;

capacity = new int[NUMFROG]; // the capacity of a frog`s breath
location = new int[NUMFROG][2]; // the location that a frog will be display
for(int i = 0 ; i < NUMFROG; i++){ // set a location randomly
location[i][0] = 80 * i;
location[i][1] = (int)(Math.random() * 400 );
}
}

public void smallfrog(){
for(int i = 0; i < NUMFROG; i++)
capacity[i] = 0;
}

public void inhale(int i){ // A frog inhale
int n = (int)(Math.random() * 3);
capacity[i] += INHALE[ n ];
}


public void position(int i) {
x = location[i][0]; // store corinates x,y
y = location[i][1];
}


public void paint(Graphics g) {

g.drawImage(parents.bounceimages[index], x, y, null);

}


public void nextimage(int i){ // an index of the group of frogs
if( capacity[i] > 40 ){
index = 4;
smallfrog();
}
else
index = ( capacity[i] / 10 );
}

}


public class Frog extends Applet implements Runnable {
FrogImage frog[]; // the number of frogs
boolean keepgoing = true;
private final int NUMFROG = 7;
public AudioClip sound;
public Image bounceimages[];

public void init() {
keepgoing = true;
bounceimages = new Image[5]; // create an object of bounceimages
for (int i = 1 ; i <= 5 ; i++)
bounceimages[i-1] = getImage(getDocumentBase(), "m" + i + ".jpg");

sound = getAudioClip( getCodeBase(), "gaegul.au");

try{
Thread.sleep( (int) Math.random() * 1000 );
}catch( InterruptedException e){}

(new Thread(this)).start();
}


public void stop() {
keepgoing = false;
}

public void run() {
makefrogs(); // yeild 7 frogs

while (keepgoing) {
for (int i = 0; i < NUMFROG; i++) {
frog[i].inhale(i); // increment the capacity of breath
frog[i].nextimage(i); // select what number of images is used
}
repaint();


try {
Thread.sleep(200);
} catch (InterruptedException e) {
return;
}
}
}


public void paint(Graphics g) {

if( frog != null ){
for (int i = 0; i < NUMFROG; i++) {
if (frog[i] != null) {
frog[i].paint(g);
}
}
}
}
void makefrogs() { // make the frogs respectively
frog = new FrogImage[NUMFROG]; // create an object of Frogimages

for (int i = 0; i < NUMFROG; i++) {
frog[i] = new FrogImage(this); // maker an object of the class FrogImage
frog[i].position(i); // settle random position
}
}



}





´ÙÀ½ ±Ûµé:



À̾ ±Û¿Ã¸®±â(´äÇϱâ)

À̸§:
E-Mail:
Á¦¸ñ:
³»¿ë:
HTML ÅÂ±× Æ÷ÇÔ ¿©ºÎ: HTML ¹®¼­ÀÏ °æ¿ì üũ
°ü·Ã URL(¼±ÅÃ):
URL Á¦¸ñ(¼±ÅÃ):
°ü·Ã À̹ÌÁö URL:


[ ´ÙÀ½ ±Ûµé ] [ À̾ ±Û¿Ã¸®±â(´äÇϱâ) ] [ ÀÚ¹Ù ¹¯°í ´äÇϱâ ]