wacharoKick.GIF  wacharoStandUp.GIF  tree.GIF
  mount.GIF  river.GIF  grass.GIF
  town.GIF  castle.GIF  cave.GIF
  street.GIF  weapon.GIF  guard.GIF
  hotel.GIF  house.GIF  black.GIF
  box.GIF
上の画像を右クリックで保存して使ってください
ファミコンでいうAボタンがEnter,BボタンがSpaceです。

/*
 * 作成日: 2004/10/07
 *
 * この生成されたコメントの挿入されるテンプレートを変更するため
 * ウィンドウ > 設定 > Java > コード生成 > コードとコメント
 */

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

/**
 * @author wacharo
 *
 * この生成されたコメントの挿入されるテンプレートを変更するため
 * ウィンドウ > 設定 > Java > コード生成 > コードとコメント
 */

/**
 * 店の主人と話ができるようにする。
 */
public class WacharoQuest6 extends Applet implements Runnable, KeyListener {

    private final int wacharoWidth=30,wacharoHeight=40;
    private final int screenX=150,screenY=200;
    private final int walkDistance=5,walkStop=0;
    private final int time=20;
    private final int NORMAL=0,COMMAND=1,ITEM=2,STATUS=3,MESSAGE=4;
    private final String[] strMenu = {"話す","持ち物","ステータス","調べる"};
    
    private final String[][] strTalk0 = {{"いらっしゃい!!"},{"何にしますか?"},{"布の服","ガンダムシールド","マント"}};
    private final String[][] strTalk1 = {{"いらっしゃい!!"},{"何にしますか?"},{"こんぼう","ビームライフル","黄金のツメ"}};
    private final String[][] strTalk2 = {{"ここは宿屋だよ"},{"とまって行くかい?"},{"は〜い。","","や〜だね!!"}};
    private final String[][] strTalk3 = {{"”偽ワチャロー”を","倒してくれ〜!!"}};
    
    private int mode;
    private int walkStatus,commandStatus,talkStatus,shopStatus,walk;
    private int wacharoX=60,wacharoY=720;
    private int mapX=0,mapY=600,townX=60,townY=80,dungeonX=60,dungeonY=400;
    private int level=1,hp=50,attack=20,guard=20;
    
    private boolean mapFlag=true,townFlag,dungeonFlag,shopFlag;
    private boolean nudle;
    private boolean take_in;
    
    private Image imgMap,imgTown,imgDungeon,imgCreature,wacharoImg1,wacharoImg2;
    private Image treeImg,mountImg,riverImg,grassImg,townImg,castleImg,caveImg;
    private Image streetImg,weaponImg,guardImg,hotelImg,houseImg;
    private Image blackImg,boxImg;
    private Image man1Img,man2Img;
    
    private Graphics offGMap,offGTown,offGDungeon,offGShop;
    private Thread th;
    private Data MAP,TOWN,DUNGEON;
    private String messeage,item;
    
    private boolean[][] mapField;
    private boolean[][] townField;
    private boolean[][] dungeonField;
    
    
    
    private final int[][] map = {
                                {3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3},
                                {3,3,3,3,3,3,3,3,3,3,0,0,0,0,0,0,0,0,0,3,3,3,3},
                                {3,3,3,3,3,3,3,3,3,3,0,0,0,0,0,0,0,0,0,0,3,3,3},
                                {3,6,3,3,3,3,3,3,3,3,0,0,0,0,0,0,0,0,0,0,0,3,3},
                                {3,0,3,3,3,3,3,3,3,3,0,0,0,0,0,0,0,0,0,0,0,3,3},
                                {3,0,3,3,3,3,3,3,3,3,0,0,0,0,0,0,0,0,0,0,0,0,3},
                                {3,0,3,3,3,3,3,3,3,3,0,0,0,0,0,0,0,0,0,0,0,0,3},
                                {3,0,3,3,3,3,3,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,3},
                                {3,0,3,3,0,0,0,0,0,0,0,0,0,0,0,0,4,4,0,0,0,0,3},
                                {3,0,0,0,0,3,3,3,3,0,0,0,0,0,0,4,4,4,4,0,0,0,3},
                                {3,3,3,3,0,3,3,3,3,0,0,2,2,2,0,4,4,4,4,4,0,0,3},
                                {3,3,3,3,3,3,3,3,0,0,0,2,1,2,0,4,4,4,4,4,0,0,3},
                                {3,3,3,3,3,3,3,0,0,0,0,2,2,2,0,4,4,4,4,0,0,0,3},
                                {3,3,3,3,3,0,0,0,0,0,0,4,4,4,4,4,4,4,0,0,0,0,3},
                                {3,3,3,3,0,0,0,0,0,0,4,4,4,4,4,4,4,0,0,0,0,0,3},
                                {3,3,3,0,0,0,0,0,0,4,4,4,4,4,4,4,4,0,0,0,0,0,3},
                                {3,3,0,0,0,0,0,0,4,4,4,4,4,4,4,4,4,4,0,0,0,3,3},
                                {3,0,0,0,0,0,0,4,4,4,4,4,4,4,4,4,4,4,0,0,0,3,3},
                                {3,0,0,0,0,0,4,4,4,4,4,0,0,0,4,4,0,0,0,0,0,3,3},
                                {3,0,0,0,0,4,4,4,4,4,4,0,5,0,4,7,0,0,0,0,3,3,3},
                                {4,4,4,4,4,4,4,4,4,4,4,0,0,0,4,4,0,0,0,0,3,3,3},
                                {4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,3,3,3}
                            };
                            
    private final int[][] town = {
                                    {12,12,12,12,12,12,12,12,12},
                                    {12,10,10,10,11,10,10,10,12},
                                    {12,10,13,10,11,10,14,10,12},
                                    {12,11,11,11,11,11,11,11,12},
                                    {12,10,16,10,11,10,15,10,12},
                                    {12,10,10,10,11,10,10,10,12},
                                    {12,12,12,12,19,12,12,12,12},
                                };
                                
    private final int[][] dungeon = {
                                        {20,20,20,20,20,20,20,20,20},
                                        {20,21,21,21,20,20,20,20,20},
                                        {20,21,22,21,21,21,21,21,20},
                                        {20,21,21,21,20,20,20,21,20},
                                        {20,20,20,20,20,20,20,21,20},
                                        {20,20,20,20,20,20,20,21,20},
                                        {20,21,21,21,21,21,21,21,20},
                                        {20,21,20,20,20,20,20,20,20},
                                        {20,21,20,20,20,20,20,20,20},
                                        {20,21,21,21,21,21,21,21,20},
                                        {20,20,20,20,21,20,20,20,20},
                                        {20,20,20,20,21,20,20,20,20},
                                        {20,21,21,21,21,21,21,21,20},
                                        {20,20,20,20,21,20,20,20,20},
                                        {20,20,20,20,29,20,20,20,20},
                                    };
    
    public void init() {
        setSize(screenX,screenY);
        
        walk = walkDistance;
        
        addKeyListener(this);
    }
    
    public void start() {
        if(th == null) {
            th = new Thread(this);
            th.start();
        }
    }
    
    public void stop() {
        if(th!=null) {
            th=null;
        }
        
        take_in=false;
        
        mapField = null;
        townField = null;
        dungeonField = null;
        
        MAP = null;
        TOWN = null;
        DUNGEON = null;
        
        imgMap.flush();
        imgTown.flush();
        imgDungeon.flush();
        imgCreature.flush();
        wacharoImg1.flush();
        wacharoImg2.flush();
        treeImg.flush();
        mountImg.flush();
        riverImg.flush();
        grassImg.flush();
        townImg.flush();
        castleImg.flush();
        caveImg.flush();
        streetImg.flush();
        weaponImg.flush();
        guardImg.flush();
        hotelImg.flush();
        houseImg.flush();
        blackImg.flush();
        boxImg.flush();
        man1Img.flush();
        man2Img.flush();
        
        offGMap.dispose();
        offGTown.dispose();
        offGDungeon.dispose();
        offGShop.dispose();
    }
    
    public void update(Graphics g) {
        paint(g);
    }
    
    public void drawWacharo(Graphics offG) {
        if(System.currentTimeMillis()%2000<=1000) {
            offG.drawImage(wacharoImg1,wacharoX,wacharoY,this);
        } else {
            offG.drawImage(wacharoImg2,wacharoX,wacharoY,this);
        }
    }
    
    public void cursor(Graphics offG,int height) {
        if(System.currentTimeMillis()%1000<=500) {
            offG.drawString("▼",65,height);
        }
    }
    
    public void ready() {
        townField = new boolean[town.length][town[0].length];
        dungeonField = new boolean[dungeon.length][dungeon[0].length];
        mapField = new boolean[map.length][map[0].length];
        
        MAP = new Data(map,mapField,mapX,mapY,wacharoWidth,wacharoHeight);
        TOWN = new Data(town,townField,townX,townY,wacharoWidth,wacharoHeight);
        DUNGEON = new Data(dungeon,dungeonField,dungeonX,dungeonY,wacharoWidth,wacharoHeight);
        
        imgMap = createImage(MAP.getWidth(),MAP.getHeight());
        offGMap = imgMap.getGraphics();
        
        imgTown = createImage(TOWN.getWidth(),TOWN.getHeight());
        offGTown = imgTown.getGraphics();
        
        imgDungeon = createImage(DUNGEON.getWidth(),DUNGEON.getHeight());
        offGDungeon = imgDungeon.getGraphics();
        
        imgCreature = createImage(screenX,screenY);
        offGShop = imgCreature.getGraphics();
        
        wacharoImg1 = getImage(getDocumentBase(),"wacharoKick.GIF");
        wacharoImg2 = getImage(getDocumentBase(),"wacharoStandUp.GIF");
        treeImg = getImage(getDocumentBase(),"tree.GIF");
        mountImg = getImage(getDocumentBase(),"mount.GIF");
        riverImg = getImage(getDocumentBase(),"river.GIF");
        grassImg = getImage(getDocumentBase(),"grass.GIF");
        townImg = getImage(getDocumentBase(),"town.GIF");
        castleImg = getImage(getDocumentBase(),"castle.GIF");
        caveImg = getImage(getDocumentBase(),"cave.GIF");
        streetImg = getImage(getDocumentBase(),"street.GIF");
        weaponImg = getImage(getDocumentBase(),"weapon.GIF");
        guardImg = getImage(getDocumentBase(),"guard.GIF");
        hotelImg = getImage(getDocumentBase(),"hotel.GIF");
        houseImg = getImage(getDocumentBase(),"house.GIF");
        blackImg = getImage(getDocumentBase(),"black.GIF");
        boxImg = getImage(getDocumentBase(),"box.GIF");
        man1Img = getImage(getDocumentBase(),"man1.GIF");
        man2Img = getImage(getDocumentBase(),"man2.GIF");
        
        MediaTracker mt = new MediaTracker(this);
        mt.addImage(wacharoImg1,0);
        mt.addImage(wacharoImg2,0);
        mt.addImage(treeImg,0);
        mt.addImage(mountImg,0);
        mt.addImage(riverImg,0);
        mt.addImage(grassImg,0);
        mt.addImage(townImg,0);
        mt.addImage(castleImg,0);
        mt.addImage(caveImg,0);
        mt.addImage(streetImg,0);
        mt.addImage(weaponImg,0);
        mt.addImage(guardImg,0);
        mt.addImage(hotelImg,0);
        mt.addImage(houseImg,0);
        mt.addImage(blackImg,0);
        mt.addImage(boxImg,0);
        mt.addImage(man1Img,0);
        mt.addImage(man2Img,0);
        
        try {
            mt.waitForID(0);
        } catch(InterruptedException e) {
            e.printStackTrace();
        }
    }
    
    public void paint(Graphics Gr) {
        
        if(take_in) {
            if(mapFlag) {
                draw(MAP,imgMap,Gr,offGMap,map,mapField);
            }
            if(townFlag) {
                draw(TOWN,imgTown,Gr,offGTown,town,townField);
            }
            if(dungeonFlag) {
                draw(DUNGEON,imgDungeon,Gr,offGDungeon,dungeon,dungeonField);
            }
            if(shopFlag) {
                offGShop.clearRect(0,0,screenX,screenY);
                offGShop.setColor(Color.BLACK);
                offGShop.fillRect(0,0,screenX,screenY);
                
                if(System.currentTimeMillis()%2000<=1000) {
                    offGShop.drawImage(man1Img,0,0,this);
                } else {
                    offGShop.drawImage(man2Img,0,0,this);
                }
                
                if(shopStatus==0) {
                    command(offGShop,strTalk0,talkStatus);
                    if(talkStatus==2) {
                        offGShop.drawString("●",10,135+20*commandStatus);
                    } else {
                        cursor(offGShop,170);
                    }
                }
                if(shopStatus==1) {
                    command(offGShop,strTalk0,talkStatus);
                    if(talkStatus==2) {
                        offGShop.drawString("●",10,135+20*commandStatus);
                    } else {
                        cursor(offGShop,170);
                    }
                }

                if(shopStatus==2) {
                    command(offGShop,strTalk2,talkStatus);
                    if(talkStatus==2) {
                        offGShop.drawString("●",10,135+40*commandStatus);
                    } else {
                        cursor(offGShop,170);
                    }
                }
                if(shopStatus==3) {
                    command(offGShop,strTalk3,0);
                }
                
                Gr.drawImage(imgCreature,0,0,screenX,screenY,this);
            }
        }
            
        if(!take_in) {
            Gr.setColor(Color.WHITE);
            Gr.fillRect(0,0,150,200);
            Font font1 = new Font("Serif", Font.BOLD, 25);
            Font font2 = new Font("Serif",Font.BOLD,15);
            Font font3 = new Font("Serif",Font.PLAIN,15);
            Gr.setFont(font1);
            Gr.setColor(Color.PINK);
            Gr.drawString("チョット,",10,40);
            Gr.drawString("待っち",10,90);
            Gr.setFont(font2);
            Gr.setColor(Color.GREEN);
            Gr.drawString("クリ",95,90);
            Gr.setFont(font3);
            Gr.setColor(Color.LIGHT_GRAY);
            Gr.drawString("(数秒間だけ!!)",10,140);
        }
    }
    
    public void draw(Data data,Image img,Graphics Gr,Graphics offG,int[][] area,boolean[][] field) {
        Image gifImg = null;
        
        offG.clearRect(0,0,data.getWidth(),data.getHeight());
        
        for(int i=0;i<area.length;i++) {
            for(int j=0;j<area[0].length;j++) {
                switch(area[i][j]) {
                    case 0:
                        gifImg = grassImg;
                        break;
                    case 1:
                        gifImg = townImg;
                        break;
                    case 2:
                        gifImg = treeImg;
                        break;
                    case 3:
                        gifImg = mountImg;
                        field[i][j]=false;
                        break;
                    case 4:
                        gifImg = riverImg;
                        field[i][j]=false;
                        break;
                    case 5:
                        gifImg = castleImg;
                        break;
                    case 6:
                        gifImg = caveImg;
                        break;
                    case 7:
                        gifImg = treeImg;
                        break;
                        
                    case 10:
                        gifImg = grassImg;
                        break;
                    case 11:
                        gifImg = streetImg;
                        break;
                    case 12:
                        gifImg = treeImg;
                        field[i][j]=false;
                        break;
                    case 13:
                        gifImg = weaponImg;
                        break;
                    case 14:
                        gifImg = guardImg;
                        break;
                    case 15:
                        gifImg = hotelImg;
                        break;
                    case 16:
                        gifImg = houseImg;
                        break;
                    case 19:
                        gifImg = streetImg;
                        break;
                        
                    case 20:
                        gifImg = blackImg;
                        field[i][j]=false;
                        break;
                    case 21:
                        gifImg = streetImg;
                        break;
                    case 22:
                        gifImg = boxImg;
                        break;
                    case 29:
                        gifImg = streetImg;
                        break;
                }
                offG.drawImage(gifImg,j*wacharoWidth,i*wacharoHeight,this);
            }
        }
        
        walk(walkStatus,data);
        
        drawWacharo(offG);
        
        command(data,offG);
        
        Gr.drawImage(img,0,0,screenX,screenY,data.getX(),data.getY(),data.getX()+screenX,data.getY()+screenY,this);
        
        if(mapFlag==true && walkStatus==0 && area[wacharoY/wacharoHeight][wacharoX/wacharoWidth]==1) {
            townFlag=true;
            mapFlag=false;
            wacharoX=120;
            wacharoY=200;
        }
        
        if(mapFlag==true && walkStatus==0 && area[wacharoY/wacharoHeight][wacharoX/wacharoWidth]==6) {
            dungeonFlag=true;
            mapFlag=false;
            wacharoX=120;
            wacharoY=520;
        }
        
        if(townFlag==true && walkStatus==0 && area[wacharoY/wacharoHeight][wacharoX/wacharoWidth]==19) {
            townFlag=false;
            mapFlag=true;
            wacharoX=360;
            wacharoY=480;
        }
        
        if(townFlag==true && walkStatus==0 && (area[wacharoY/wacharoHeight][wacharoX/wacharoWidth]==13 || area[wacharoY/wacharoHeight][wacharoX/wacharoWidth]==14 || area[wacharoY/wacharoHeight][wacharoX/wacharoWidth]==15 || area[wacharoY/wacharoHeight][wacharoX/wacharoWidth]==16)) {
            switch(area[wacharoY/wacharoHeight][wacharoX/wacharoWidth]) {
                case 13:
                    shopStatus=0;
                    break;
                case 14:
                    shopStatus=1;
                    break;
                case 15:
                    shopStatus=2;
                    break;
                case 16:
                    shopStatus=3;
                    break;
            }
            shopFlag=true;
            townFlag=false;
            walk = walkStop;
        }
        
        if(dungeonFlag==true && walkStatus==0 && area[wacharoY/wacharoHeight][wacharoX/wacharoWidth]==29) {
            dungeonFlag=false;
            mapFlag=true;
            wacharoX=30;
            wacharoY=160;
        }
    }
    
    public void walk(int x,Data data) {
        int X = data.getX();
        int Y = data.getY();
        int width = data.getWidth();
        int height = data.getHeight();
        
        switch(x) {
            case 0:
                break;
                
            case 1:
                wacharoX += walk;
                if(X<width-screenX && wacharoX-X>=wacharoWidth*2) {
                    X += walk;
                }
                if(wacharoX%wacharoWidth==0) {
                    walkStatus = 0;
                }
                data.setX(X);
                break;
                
            case 2:
                wacharoX -= walk;
                if(X>0 && wacharoX-X<=wacharoWidth*2) {
                    X -= walk;
                }
                if(wacharoX%wacharoWidth==0) {
                    walkStatus = 0;
                }
                data.setX(X);
                break;
                
            case 3:
                wacharoY -= walk;
                if(Y>0 && wacharoY-Y<=wacharoHeight*2) {
                    Y -= walk;
                }
                if(wacharoY%wacharoHeight==0) {
                    walkStatus = 0;
                }
                data.setY(Y);
                break;
                
            case 4:
                wacharoY += walk;
                if(Y<height-screenY && wacharoY-Y>=wacharoHeight*2) {
                    Y += walk;
                }
                if(wacharoY%wacharoHeight==0) {
                    walkStatus = 0;
                }
                data.setY(Y);
        }
    }

    
    public void commandFrame(Graphics offG,int frameX,int frameY,int width,int height) {
        offG.setColor(Color.WHITE);
        offG.fillRoundRect(frameX,frameY,width,height,20,20);
        offG.setColor(Color.BLACK);
        offG.fillRoundRect(frameX+2,frameY+2,width-4,height-4,20,20);
    }
    
    public void commandFrame(Data data,Graphics offG,int frameX,int frameY,int width,int height) {
        offG.setColor(Color.WHITE);
        offG.fillRoundRect(data.getX()+frameX,data.getY()+frameY,width,height,20,20);
        offG.setColor(Color.BLACK);
        offG.fillRoundRect(data.getX()+frameX+2,data.getY()+frameY+2,width-4,height-4,20,20);
    }

    public void menu(Graphics offG,String[] str,int x,int y,int space) {
        offG.setColor(Color.WHITE);
        for(int i=0;i<str.length;i++) {
            offG.drawString(str[i],x,y+space*i);
        }
    }
    
    public void menu(Data data,Graphics offG,String[] str,int x,int y,int space) {
        offG.setColor(Color.WHITE);
        for(int i=0;i<str.length;i++) {
            offG.drawString(str[i],data.getX()+x,data.getY()+y+space*i);
        }
    }
    
    public void command(Graphics offG,String[][] str,int index) {
        if(shopFlag) {
            commandFrame(offGShop,5,110,140,80);
            menu(offG,str[index],25,135,20);
        }
    }
    
    public void command(Data data,Graphics offG) {
        if(mode==COMMAND) {
            commandFrame(data,offG,30,25,90,130);
            menu(data,offG,strMenu,50,50,30);
            offG.drawString("●",data.getX()+35,data.getY()+50+30*commandStatus);
        }
        if(mode==MESSAGE) {
            commandFrame(data,offG,5,120,140,40);
            offG.setColor(Color.WHITE);
            offG.drawString(messeage,data.getX()+15,data.getY()+140);
        }
        if(mode==ITEM) {
            commandFrame(data,offG,10,25,130,100);
            offG.setColor(Color.WHITE);
            offG.drawString(item,data.getX()+35,data.getY()+50);
        }
        if(mode==STATUS) {
            String[] strStatus = {"レベル:"+level,"H P:"+hp,"攻撃力:"+attack,"防御力:"+guard};    //←ローカルで宣言するのだ!!
            commandFrame(data,offG,10,25,100,100);                                                        //そうすれば、後でステータスの変化に対応できるのだ!!
            menu(data,offG,strStatus,25,50,20);
        }
    }
    
    
    public void keyEvent(KeyEvent e,int[][] area,boolean[][] field,int width,int height) {
        if(e.getKeyCode()==KeyEvent.VK_RIGHT) {
            if(!shopFlag && wacharoX<width-wacharoWidth && field[wacharoY/wacharoHeight][wacharoX/wacharoWidth+1]==true) {
                walkStatus=1;
            }
        }
        if(e.getKeyCode()==KeyEvent.VK_LEFT) {
            if(!shopFlag && wacharoX>0 &&  field[wacharoY/wacharoHeight][wacharoX/wacharoWidth-1]==true) {
                walkStatus=2;
            }
        }
        if(e.getKeyCode()==KeyEvent.VK_UP) {
            if(!shopFlag && wacharoY>0 && field[wacharoY/wacharoHeight-1][wacharoX/wacharoWidth]==true) {
                walkStatus=3;
            }
            if(commandStatus>0) {
                commandStatus--;
            }
        }
        if(e.getKeyCode()==KeyEvent.VK_DOWN) {
            if(!shopFlag && wacharoY<height-wacharoHeight && field[wacharoY/wacharoHeight+1][wacharoX/wacharoWidth]==true) {
                walkStatus=4;
            }
            if(mode==COMMAND && commandStatus<3 || (shopStatus==0 ||shopStatus==1) && commandStatus<2 || shopStatus==2 && commandStatus<1) {
                commandStatus++;
            }
        }
        if(e.getKeyCode()==KeyEvent.VK_ENTER) {
            if(mode==COMMAND) {
                switch(commandStatus) {
                    case 0:
                        messeage = "誰もいない";
                        mode=MESSAGE;
                        break;
                    case 1:
                        if(nudle) {
                            item = "ラーメン";
                        } else {
                            item = "何もない!!";
                        }
                        mode=ITEM;
                        break;
                    case 2:
                        mode=STATUS;
                        break;
                    case 3:
                        if(!nudle && area[wacharoY/wacharoHeight][wacharoX/wacharoWidth]==22) {
                            messeage = "ラーメンを見つけた。";
                            nudle = true;
                        } else {
                            messeage = "何も見つからなかった。";
                        }
                        mode=MESSAGE;
                        break;
                }
            }
            if(mode==NORMAL&&!shopFlag) {
                walk=walkStop;
                mode=COMMAND;
            }
            if(shopFlag && talkStatus<2) {
                talkStatus++;
            }
        }
        if(e.getKeyCode()==KeyEvent.VK_SPACE) {
            if(shopFlag){
                shopFlag = false;
                townFlag = true;
                talkStatus=0;
                if(town[wacharoY/wacharoHeight][wacharoX/wacharoWidth]==13 || town[wacharoY/wacharoHeight][wacharoX/wacharoWidth]==16) {
                    wacharoX = 60;
                    wacharoY = 120;
                }
                if(town[wacharoY/wacharoHeight][wacharoX/wacharoWidth]==14 || town[wacharoY/wacharoHeight][wacharoX/wacharoWidth]==15) {
                    wacharoX = 180;
                    wacharoY = 120;
                }
            }
            walk=walkDistance;
            commandStatus=0;
            talkStatus=0;
            mode=NORMAL;
        }
    }
    
    /* (非 Javadoc)
     * @see java.lang.Runnable#run()
     */
    public void run() {
        // TODO 自動生成されたメソッド・スタブ
        
        ready();
        take_in=true;
        
        while(th == Thread.currentThread()) {
            try {
                Thread.sleep(time);
            } catch(InterruptedException e) {
                th=null;
            }
            repaint();
        }
    }

    /* (非 Javadoc)
     * @see java.awt.event.KeyListener#keyPressed(java.awt.event.KeyEvent)
     */
    public void keyPressed(KeyEvent e) {
        // TODO 自動生成されたメソッド・スタブ
        int[][] area = null;
        boolean[][] field = null;
        int width=0;
        int height=0;
        
        if(walkStatus==0) {
            if(mapFlag) {
                area = map;
                field = mapField;
                width = MAP.getWidth();
                height = MAP.getHeight();
            }
            if(townFlag) {
                area = town;
                field = townField;
                width = TOWN.getWidth();
                height = TOWN.getHeight();
            }
            if(dungeonFlag) {
                area = dungeon;
                field = dungeonField;
                width = DUNGEON.getWidth();
                height = DUNGEON.getHeight();
            }
            
            keyEvent(e,area,field,width,height);
        }
    }

    /* (非 Javadoc)
     * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
     */
    public void keyReleased(KeyEvent e) {
        // TODO 自動生成されたメソッド・スタブ
    }

    /* (非 Javadoc)
     * @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent)
     */
    public void keyTyped(KeyEvent e) {
        // TODO 自動生成されたメソッド・スタブ

    }

}
		

Data.java
public class Data {
    private int X,Y;
    private int width,height;
    
    Data() {
    }
    
    Data(int[][] map,boolean[][] field,int startX,int startY,int wacharoWidth,int wacharoHeight) {
        X = startX;
        Y = startY;
        width = map[0].length*wacharoWidth;
        height = map.length*wacharoHeight;
        
        for(int i=0;i<map.length;i++) {
            for(int j=0;j<map[0].length;j++) {
                field[i][j] = true;
            }
        }
    }
    
    public void setX(int x) {
        X = x;
    }

    public int getX() {
        return X;
    }

    public void setY(int y) {
        Y = y;
    }

    public int getY() {
        return Y;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public int getWidth() {
        return width;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public int getHeight() {
        return height;
    }
}
        

top

2420