//#define APPLET //#define DEBUG /*------------------------------------- タイトル:勇者で行こう!Ω ver 0.06 制作:ハルーポッター HomePage: http://www.ar.wakwak.com/~harupotter/ 動作機種:imode503i,504iシリーズ、Javaアプレット [コンパイル方法] アプレットにする場合は、一番上の行を #define APPLET とする。 iアプリにする場合は、 //#define APPLET とする。 そして、PPP(Pamuow Preprocessor)を使用する。DL先・・・http://www.and.or.jp/~pamulow/ppp/ppp.html [使い方] ppp 入力フォルダ 出力フォルダ 例:ppp . src [アプレットの場合にHTMLファイルに記述するタグ] ーーーーーー---------------------------*/ //#ifdef APPLET import java.awt.*; import java.awt.event.*; import java.applet.*; //#else //import com.nttdocomo.ui.*; //#endif //セルクラス class Cell{ int gra;//グラフィックデータ int event;//イベント boolean move_flag;//通過可能フラグ Cell(int a,int b,boolean c){ gra=a;event=b;move_flag=c; } } //キャラクタークラス class Chara{ int gra;//グラフィックデータ int x,y;//マップ上の座標 int map;//登場するマップ boolean move_flag;//通過可能か String talk[];//会話 Chara(int a,int d,int b,int c,String str){ gra=a;x=b;y=c;map=d; talk=parseString(str,'\t'); } //文字列を任意の文字で分割 String[] parseString(String str,char sep) { int i,j,size; String[] result; //最後尾に分割文字 if (str.equals("")||str.charAt(str.length()-1)!=sep) str+=sep; //サイズを得る size=0; i=str.indexOf(sep); while (i>=0) { size++; i=str.indexOf(sep,i+1); } //分割する result=new String[size]; size=0; j=0; i=str.indexOf(sep); while (i>=0) { result[size++]=str.substring(j,i); j=i+1; i=str.indexOf(sep,j); } return result; } } //#ifndef APPLET // ////ポイントクラス //class Point{ // int x,y; // Point(int a,int b){x=a;y=b;} //}; // ////本体 //public class Rpg extends IApplication{ // //アプリの開始 // public void start() { // RpgCanvas r=new RpgCanvas(); // Display.setCurrent(r); // r.exe(); // } //} //#endif //#ifdef APPLET public class Rpg extends Applet implements KeyListener,Runnable{ //#else //class RpgCanvas extends Canvas{ //#endif //#ifdef APPLET Image buffer;//バッファ AudioClip se[] = new AudioClip[5];//効果音 MediaTracker tracker = new MediaTracker(this);//メディアトラッカー //#endif final int WIDTH=9; final int HEIGHT=6; final int WPIXEL=120; final int HPIXEL=130; final int MAPNUM=15;//マップパーツの数 final int CHARANUM=12;//キャラクターの数 final int CHARAIMAGENUM=5;//キャラクター画像の数 final int INIT_X=3,INIT_Y=2;//勇者の位置 final int PARTS_SIZE=16; final int UP=0,DOWN=1,LEFT=2,RIGHT=3,ENTER=4;//方向定義 int move_dir;//向いている方向(0123) int TalkPos;//会話点 boolean anime_font=true;//会話のアニメーションフラグ boolean anime_fonts[] = new boolean[3]; boolean moving_flag=false;//移動中か boolean key_flags[]=new boolean[5];//キーの状態 Image map_images[] = new Image[MAPNUM];//マップパーツ画像 Image chara_images[] = new Image[CHARAIMAGENUM];//キャラクター画像 Graphics bufferg; Image hero[]=new Image[4];//勇者画像 Point map_start = new Point(0,0);//マップ開始座標 Point limit = new Point(0,0);//限界値 Point mapfew = new Point(0,0);//アニメ中のマップずれ long FrameTime=0; Cell celldata[] = { new Cell(0,0,true), new Cell(1,0,true), new Cell(2,0,true), new Cell(3,1,true),//ハウスワープ new Cell(4,0,false), new Cell(5,0,true), new Cell(6,0,true), new Cell(7,4,true),//洞窟 new Cell(8,0,false), new Cell(10,0,false), new Cell(9,0,true), new Cell(1,2,true),//外ワープ new Cell(11,3,true),//手紙 new Cell(12,0,true),//壁 new Cell(13,0,true),//地下 new Cell(14,11,true),//宝 new Cell(1,5,true),//洞窟から外へ }; //キャラクターデータ Chara charas[]={ new Chara(0,0,8,2,"僕はるきち。 ねえ、最近思うんだ けどさ 年を取るにつれて 時間が経つのが 早く感じるんだよね"), new Chara(0,2,6,2,"冗談じゃないよ"), new Chara(1,0,5,2,"あべし お前はもうあべし"), new Chara(1,0,6,8,"勇者って職業?"), new Chara(1,1,5,2,"ひでぶ お前はもうひでぶ"), new Chara(1,0,5,6,"僕、数学博士。 早速問題! 赤・赤・黒・黒の 4枚のトランプを 裏返して置いてあ ります。 この中から2枚を 同時に開いて、そ れが同じ色(黒黒 か赤赤)である確 率は? 答えは三分の一。 2つ同時というのが 注意点。結局は、1 回目、2回目という 順番で開くのと同じ。 1回目に赤だった場 合は、2回目は「黒 ・黒・赤」の中から 赤を選ぶから。 "), new Chara(2,0,10,2,"話しかけないで ウゼエ"), new Chara(2,0,11,2,"うるせえ"), new Chara(2,2,8,8,"こんにちは ヒカル17歳女子高生"), new Chara(2,0,30,20,"彼と待ち合わせ中 なの"), new Chara(3,1,3,1,"手紙がある。 「果たし状。明日19時、 駅前にて。」"), new Chara(4,2,8,12,"宝だ。中に紙切れが。 『工事中』"), }; //マップデータ(32*24) int mapdata[][] = { {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x04,0x00,0x06,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x01,0x00,0x00,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x04,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x08,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x01,0x01,0x04,0x00,0x00,0x08,0x08,0x08,0x00,0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x08,0x08,0x08,0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x00,0x00,0x00,0x01,0x01,0x00,0x08,0x08,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x08,0x08,0x08,0x00,0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x08,0x08,0x01,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x04,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x08,0x08,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x04,0x07,0x04,0x00,0x05,0x00,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x04,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, }; //家マップデータ(7*6) int housemapdata[][] = { { 9, 9, 9, 9, 9, 9, 9}, { 9,10,10,12,10,10, 9}, { 9,10,10,10,10,10, 9}, { 9,10,10,10,10,10, 9}, { 9,10,10,10,10,10, 9}, { 9, 9,11,11,11, 9, 9}, }; int maze_mapdata[][]={ {0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x10,0x0a,0x0a,0x0a,0x0a,0x0a,0x09,0x09,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x10,0x0a,0x0a,0x0e,0x0a,0x0a,0x0a,0x09,0x09,0x0d,0x0d,0x0d,0x0d,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x09,0x0e,0x0e,0x0a,0x0a,0x0a,0x0a,0x0a,0x09,0x0d,0x0d,0x0d,0x0d,0x0d,0x0a,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x0a,0x00,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x09,0x0a,0x0e,0x0a,0x09,0x0a,0x0a,0x0a,0x09,0x0d,0x0d,0x0d,0x0d,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x09,0x0a,0x0a,0x09,0x0a,0x09,0x0a,0x0a,0x09,0x0d,0x0d,0x0d,0x0d,0x0d,0x0a,0x00,0x00,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x09,0x0a,0x0a,0x09,0x0a,0x09,0x0a,0x0a,0x09,0x0d,0x0d,0x0d,0x0d,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x09,0x09,0x0a,0x0a,0x09,0x0a,0x0a,0x0a,0x09,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x09,0x0a,0x0a,0x0a,0x0e,0x0e,0x0e,0x0e,0x0e,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x09,0x0a,0x0e,0x0e,0x0e,0x0a,0x0e,0x0a,0x0e,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x0e,0x0e,0x09,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x09,0x09,0x09,0x09,0x09,0x09,0x0a,0x0a,0x0a,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x09,0x09,0x09,0x09,0x09,0x09,0x0a,0x0a,0x0f,0x09,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x00,0x0a,0x09,0x0a,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, }; int now_map,now_string,now_chara;//現在マップ、現在文字列、現在話中キャラ int now_talk_index;//話中のキャラクター添字 Point My = new Point(1-INIT_X,1-INIT_Y);//マップ開始座標 boolean PushFlag=false;//キーを押した状態であるか long waitTime; //初期化 //#ifdef APPLET public void init(){ int i; //--------ロード----------- for(i=1;i<=4;i++){ hero[i-1]=getImage(getDocumentBase(),"hero"+i+".gif");//主人公 tracker.addImage(hero[i-1],0); } //キャラクター for(i=1;i<=CHARAIMAGENUM;i++){ chara_images[i-1]=getImage(getDocumentBase(),"chara"+i+".gif"); tracker.addImage(chara_images[i-1],0); } //マップ for(i=1;i<=MAPNUM;i++){ map_images[i-1]=getImage(getDocumentBase(),"map"+i+".gif"); tracker.addImage(map_images[i-1],0); } se[0] = getAudioClip(getDocumentBase(),"se1.au"); se[1] = getAudioClip(getDocumentBase(),"se2.au"); addKeyListener(this); requestFocus();//フォーカス取得 buffer = createImage(WPIXEL,HPIXEL); Thread t = new Thread(this);//スレッド t.start(); //#else // //コンストラクタ // RpgCanvas(){ // int i; // // setSoftLabel(SOFT_KEY_1,"勇者"); // setSoftLabel(SOFT_KEY_2,"愛"); // // //ロード // try{ // MediaImage m; // for(i=1;i<=4;i++){ //#ifdef DEBUG // m=MediaManager.getImage("resource:///hero"+i+".gif"); //#else // m=MediaManager.getImage("http://www.ar.wakwak.com/~harupotter/java/rpg/hero"+i+".gif"); //#endif // m.use(); // hero[i-1]=m.getImage(); // } // // //マップ // for(i=1;i<=MAPNUM;i++){ //#ifdef DEBUG // m=MediaManager.getImage("resource:///map"+i+".gif"); //#else // m=MediaManager.getImage("http://www.ar.wakwak.com/~harupotter/java/rpg/map"+i+".gif"); //#endif // m.use(); // map_images[i-1]=m.getImage(); // } // //キャラクター // for(i=1;i<=CHARAIMAGENUM;i++){ //#ifdef DEBUG // m=MediaManager.getImage("resource:///chara"+i+".gif"); //#else // m=MediaManager.getImage("http://www.ar.wakwak.com/~harupotter/java/rpg/chara"+i+".gif"); //#endif // m.use(); // chara_images[i-1]=m.getImage(); // } // }catch(Exception e){e.printStackTrace();} //#endif for(i=0;i<3;i++){ anime_fonts[i]=true; } for(i=0;i<5;i++){ key_flags[i]=false; } waitTime=System.currentTimeMillis(); now_map=0; now_string=1; move_dir=DOWN; } //メインループ //#ifdef APPLET public void run(){ showStatus("現在、画像をロード中..."); try{tracker.waitForAll();} catch(Exception e){return;} //#else // void exe(){ //#endif try{ while(true){ FrameTime=System.currentTimeMillis()-waitTime; if(FrameTime==0){FrameTime=1;} waitTime=System.currentTimeMillis(); myPaint(); //移動アニメ if(moving_flag){Moving(move_dir);} keyAction(); //#ifndef APPLET // checkKeyState();//キーの状態 //#endif } }catch(Exception e){} } //描画 public void myPaint(){ Graphics g=getGraphics(); int i,j; int map; String strs[] = new String[3]; //描画領域のロック //#ifdef APPLET if(bufferg==null){bufferg=buffer.getGraphics();} //#else // bufferg=g; // bufferg.lock(); //#endif //背景(マップ) int k,l; switch(now_map){ case 0:limit.x=32;limit.y=24;break; case 1:limit.x=7;limit.y=6;break; case 2:limit.x=64;limit.y=32;break; } for(i=My.x-1,k=-1;i=limit.x || j>=limit.y){map=12;} else{ switch(now_map){ case 0:map=celldata[mapdata[j][i]].gra;break; case 1:map=celldata[housemapdata[j][i]].gra;break; case 2:map=celldata[maze_mapdata[j][i]].gra;break; default:map=0;break; } } //#ifdef APPLET bufferg.drawImage(map_images[map],k*PARTS_SIZE+mapfew.x/100,l*PARTS_SIZE+mapfew.y/100,this); //#else // bufferg.drawImage(map_images[map],k*PARTS_SIZE+mapfew.x/100,l*PARTS_SIZE+mapfew.y/100); //#endif } } //主人公描画 //#ifdef APPLET bufferg.drawImage(hero[move_dir],PARTS_SIZE*INIT_X,PARTS_SIZE*INIT_Y,this); //#else // bufferg.drawImage(hero[move_dir],PARTS_SIZE*INIT_X,PARTS_SIZE*INIT_Y); //#endif //-------------------キャラクター描画----------------- for(i=0;i= My.x && charas[i].x=My.y && charas[i].y=now_talk_index+1+1){ strs[1]=charas[now_chara].talk[now_talk_index+1]; }else{strs[1]="";anime_fonts[1]=false;} //三行目 if(charas[now_chara].talk.length>=now_talk_index+2+1){ strs[2]=charas[now_chara].talk[now_talk_index+2]; }else{strs[2]="";anime_fonts[2]=false;} //続きがある場合 if(charas[now_chara].talk.length>=now_talk_index+4){ strs[2]+="▽"; } break; default:strs[0]="";strs[1]="FrameTime="+FrameTime;strs[2]=""; } //流れる文字 //一行目 if(anime_fonts[0]){ bufferg.drawString(strs[0].substring(0,TalkPos/100+1),2,130-21-14); if((TalkPos+=4*FrameTime)/100 >=strs[0].length()){anime_fonts[0]=false;TalkPos=-8*(int)FrameTime;} }else{bufferg.drawString(strs[0],2,130-21-14);} //二行目 if(!anime_fonts[0] && anime_fonts[1]){ if(TalkPos>=0)bufferg.drawString(strs[1].substring(0,TalkPos/100+1),2,130-7-14); if((TalkPos+=4*FrameTime)/100==strs[1].length()){anime_fonts[1]=false;TalkPos=-8*(int)FrameTime;} }else if(!anime_fonts[1]){bufferg.drawString(strs[1],2,130-7-14);} //三行目 if(!anime_fonts[1] && anime_fonts[2]){ if(TalkPos>=0)bufferg.drawString(strs[2].substring(0,TalkPos/100+1),2,130-7); if((TalkPos+=4*FrameTime)/100==strs[2].length()){anime_fonts[2]=false;TalkPos=0;} }else if(!anime_fonts[2]){bufferg.drawString(strs[2],2,130-7);} if(!anime_fonts[0] && !anime_fonts[1] && !anime_fonts[2]){anime_font=false;} //一気に描画 //#ifdef APPLET g.drawImage(buffer,0,0,this); //#else // bufferg.unlock(true); //#endif } //--------------------キー処理--------------------- public void keyAction(){ if(moving_flag)return;//移動中の状態は処理しない if(key_flags[UP]){ if(now_string<2){ move_dir=UP; //移動開始 if(map_ismove(My.x+INIT_X,My.y+INIT_Y-1)){moving_flag=true;} } } else if(key_flags[DOWN]){ if(now_string<2){ move_dir=DOWN; if(map_ismove(My.x+INIT_X,My.y+INIT_Y+1)){moving_flag=true;} } } else if(key_flags[LEFT]){ if(now_string<2){ move_dir=LEFT; if(map_ismove(My.x+INIT_X-1,My.y+INIT_Y)){moving_flag=true;} } } else if(key_flags[RIGHT]){ if(now_string<2){ move_dir=RIGHT; if(map_ismove(My.x+INIT_X+1,My.y+INIT_Y)){moving_flag=true;} } } } //------------------------------キー入力--------------------------- //#ifdef APPLET public void keyPressed(KeyEvent e){ //#else // public void processEvent(int type,int param){ // if(type!=Display.KEY_PRESSED_EVENT)return; //#endif int key; //#ifdef APPLET key=e.getKeyCode(); //#else // key=param; //#endif switch(key){ //上ボタン //#ifdef APPLET case KeyEvent.VK_UP: //#else // case Display.KEY_UP: //#endif key_flags[UP]=true; break; //下ボタン //#ifdef APPLET case KeyEvent.VK_DOWN: //#else // case Display.KEY_DOWN: //#endif key_flags[DOWN]=true; break; //#ifdef APPLET case KeyEvent.VK_RIGHT: //#else // case Display.KEY_RIGHT: //#endif key_flags[RIGHT]=true; break; //#ifdef APPLET case KeyEvent.VK_LEFT: //#else // case Display.KEY_LEFT: //#endif key_flags[LEFT]=true; break; //#ifdef APPLET case KeyEvent.VK_ENTER: //#else // case Display.KEY_SELECT:case Display.KEY_SOFT1: //#endif if(!key_flags[ENTER]){ map_search(My.x+INIT_X,My.y+INIT_Y);//調べる key_flags[ENTER]=true; } break; } } //通過可能か public boolean map_ismove(int x,int y){ int cell,i; //限界値 if(x == -1 || y == -1 || x == limit.x || y == limit.y)return false; switch(now_map){ case 0:cell = mapdata[y][x];break; case 1:cell = housemapdata[y][x];break; case 2:cell = maze_mapdata[y][x];break; default:cell=0;break; } if(celldata[cell].move_flag){ //キャラクターがいる場合 for(i=0;i=PARTS_SIZE){mapfew.y=0;moving_flag=false;My.y--;map_event(My.x+INIT_X,My.y+INIT_Y);} break; case DOWN: if((mapfew.y-=8*FrameTime)/100<=-PARTS_SIZE){mapfew.y=0;moving_flag=false;My.y++;map_event(My.x+INIT_X,My.y+INIT_Y);} break; case LEFT: if((mapfew.x+=8*FrameTime)/100>=PARTS_SIZE){mapfew.x=0;moving_flag=false;My.x--;map_event(My.x+INIT_X,My.y+INIT_Y);} break; case RIGHT: if((mapfew.x-=8*FrameTime)/100<=-PARTS_SIZE){mapfew.x=0;moving_flag=false;My.x++;map_event(My.x+INIT_X,My.y+INIT_Y);} break; } } //調べる public void map_search(int x,int y){ int cell,i,j; boolean move_flag=false; boolean talk_flag=false; if(anime_font){return;} //#ifdef APPLET se[1].play(); //#endif //会話スキップ switch(now_string){ case 0:case 1:break; case 2:now_string=3;return; case 3:now_string=0;return; case 11:now_string=0;return; case 32: //会話に続きがある場合 if(charas[now_chara].talk.length>=now_talk_index+4){ now_talk_index+=3; anime_font=true;TalkPos=0; for(j=0;j<3;j++){anime_fonts[j]=true;} }else{now_string=0;} return; } //#ifdef APPLET if(move_flag){se[0].play();} //#endif switch(now_map){ case 0:cell = mapdata[y][x];break; case 1:cell = housemapdata[y][x];break; case 2:cell = maze_mapdata[y][x];break; default:cell=0;break; } switch(celldata[cell].event){ case 11:now_string=11;break; default:now_string=0;break; } //向いている方向にキャラクターがいる場合 for(i=0;i