アットウィキロゴ

じゃヴぁ1112

import java.awt.*;
import java.awt.event.*;

class game1112 extends Frame implements Runnable ,MouseListener{

int px,py;
int mode;

public static void main(String [] args) {
        Frame f=new game1112();
        f.setTitle("game1112");
        f.setSize(700,700);
        f.setBackground(Color.yellow);
        f.setVisible(true);
    }

game1112(){

addMouseListener(this);

Thread th=new Thread(this);
th.start();
addWindowListener(new stopwin());
}


class stopwin extends WindowAdapter{
    public void windowClosing(WindowEvent we){System.exit(0);}
}  


public void run(){
int t;
mode=1;
px=200;
py=100;
t=0;
while(t<200){
if(mode==1)px=px+10;
if(mode==2)px=px-10;
if(px>500)px=500;
if(px<100)px=100;
repaint();
try{
Thread.sleep(100);
}catch(InterruptedException e){}
t=t+1;
}
repaint();
}


public void mouseEntered(MouseEvent e){
    }

public void mouseExited(MouseEvent e){
  }

  public void mousePressed(MouseEvent e){
}

  public void mouseReleased(MouseEvent e){
   }

  public void mouseClicked(MouseEvent e){
System.out.println(mode);
int mx;
mx=5;
if(mode==1)mx=2;
if(mode==2)mx=1;      
mode=mx;
}
最終更新:2011年02月11日 22:20