import java.awt.*; import java.applet.*; import java.io.*; import java.net.URL; import java.net.URLConnection; import java.awt.image.*; //-------------------------------------------------- // 基本管理クラス //-------------------------------------------------- class BasicManage{ //-------------------------------------------------- // クラスアクセス用 //-------------------------------------------------- // グラフィックス Graphics g; // 親アプレット MapEdit applet; //-------------------------------------------------- // 定数 //-------------------------------------------------- // 方向数 final byte DIR_NUM = 4; // 方向列挙 static final byte DIR_UP = 0; static final byte DIR_RIGHT = 1; static final byte DIR_DOWN = 2; static final byte DIR_LEFT = 3; // カメラが写せる範囲 int m_camera_width = MapManage.HALF_WIDTH; int m_camera_height = MapManage.HALF_HEIGHT; //-------------------------------------------------- // デバッグプリント //-------------------------------------------------- void DebugPrint( String str ){ System.out.println( str ); } // スクリーン座標変換 ワールド座標からスクリーン座標 int ToScreenX( int x ){ return x - ( applet.GetCamera().x - this.m_camera_width ); } int ToScreenY( int y ){ return y - ( applet.GetCamera().y - this.m_camera_height ); } // スクリーン座標からワールド座標へ int ToWorldX( int x ){ return x + applet.GetCamera().x - this.m_camera_width; } int ToWorldY( int y ){ return y + applet.GetCamera().y - this.m_camera_height; } // 絶対値 static int MyAbs( int a ){ if( a >= 0 ) return a; else return -a; } // 固定小数 final int ONE_SHIFT = 0x10; final int ONE = 1 << ONE_SHIFT; // 固定小数から通常整数に int ChangeOne( int a ){ return a >> ONE_SHIFT; } // イメージロード Image LoadImage( String file, MediaTracker mediaT ){ Image image = applet.getImage( applet.getDocumentBase(), file ); mediaT.addImage( image, 0 ); return image; } //-------------------------------------------------- // 対応する場所のピクセルイメージ作成 //-------------------------------------------------- void MakeChipImageByBigImage( ChipImage image, int big_pixles[], int width, int height, int x, int y, int big_width ){ int[] rPixels = new int[ width * height ]; GetPixelByBigImage( rPixels, x, y, width, height, big_pixles, big_width ); image.SetPix( rPixels ); } //-------------------------------------------------- // でか画像から指定のチップ採取 // 入力、開始x,y 幅、高さ、でか画像ピクセル、でか画像の横幅 //-------------------------------------------------- void GetPixelByBigImage( int pix[], int x, int y, int width, int height, int big_pixels[], int big_width ){ // でかマップから採取 int xx, yy, yyy, yyyy; for( yy = 0; yy < height; yy++ ){ yyy = yy * width; yyyy = ( y + yy ) * big_width; for( xx = 0; xx < width; xx++ ){ pix[ xx + yyy ] = big_pixels[ ( x + xx ) + yyyy ]; } } } }