⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gameshell.java

📁 CreatLog luke 俄罗斯方块
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
	case Canvas.KEY_NUM9: keyArray[keyPos] = KeyNine; break;	case Canvas.KEY_STAR: keyArray[keyPos] = KeyStar; break;	case Canvas.KEY_POUND: keyArray[keyPos] = KeyHash; break;	default:	    int gameAction = getGameAction(keyCode);	    if(gameAction==Canvas.UP)		keyArray[keyPos] = KeyUp;	    else if(gameAction==Canvas.DOWN)		keyArray[keyPos] = KeyDown;	    else if(gameAction==Canvas.LEFT)		keyArray[keyPos] = KeyLeft;	    else if(gameAction==Canvas.RIGHT)		keyArray[keyPos] = KeyRight;	    else if(gameAction==Canvas.FIRE)		keyArray[keyPos] = KeyYes;	    else		keyArray[keyPos] = Byte.MIN_VALUE;	}	timerThread.keysUpdated++;    }    protected void handleBackCommand() {	//System.out.println("gs.handleBackCommand reporting for duty");	keyPos++;	if(keyPos == 8) keyPos = 0;	keyPressedArray[keyPos] = true;		keyArray[keyPos] = KeyNo;	timerThread.keysUpdated++;	//Generate No Up event?	/*keyPos++;	  if(keyPos == 8) keyPos = 0;	  keyPressedArray[keyPos] = false;		  keyArray[keyPos] = KeyNo;	  timerThread.keysUpdated++;*/    }    /** The main event handler. Since GameShell is only an empty shell, and not      * an actual game, this is abstract and must be implemented in a subclass of      * GameShell. Some events (key press events) are created by the GameShell,      * and some, like timer and menu events, are generated by the GameMIDlet object.      * <p>      * This could be made protected if it turns out that all events can be generated      * from within this class. Probably they cannot - game start, end couldn't      * be generated from here.      * <p>      * This means the converted game's main method, whatever it might      * have been called in the C code, must be renamed gameMain.      */    public abstract boolean gameMain(GAEvent event);    /** Loads the images for this game. This is abstract, since GameShell does not know      * the names of the images in the resource file, nor the variables to store them in.      * Whoever creates an instance of a subclass of GameShell is responsible for calling      * loadImages on it before sending the first GAEvent.      *      * @returns true if all images were read successfully, false otherwise.      */    public abstract boolean loadImages();    public void startThread() {	timerThread.setMIDlet(midlet);	timerThread.start();    };    public abstract String getGameName();    /*      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                                        GAPI Emulation      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%    */    /*      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                                         game_info.h      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%    */    //enum GAMenuDataType_e    static final byte GAMenuDataBirthdate = 0;    static final byte GAMenuDataBackgroundPic = 1;    static final byte GAMenuDataForegroundPic = 2;    static final byte GAMenuDataPhoneNumber = 3;    static final byte GAMenuDataLast = 4;    /**      * This method sets the menu data number 1, this is special data retrieved       * during the menus and can be fetched by the games.      *      * @param Type Which data is to consider      * @param d The data      * @param l The length of the data      *      * @returns TRUE if everything went OK      *      */    boolean Game_SetMenuData(byte type, StringBuffer d, short l) {	mso.birthDate.delete(0,mso.birthDate.length());	mso.birthDate.append(d);	return true;    }    /**      * This method get the menu data number 1, this is special data retrieved       * during the menus.      *      * @param Type Which data is to consider      * @param l l[0] is set to the length of the data.      *      * @returns A pointer to the menu data      *      */    String Game_GetMenuData(byte Type, short[] l) {	l[0]=10;	return mso.birthDate.toString();    }    /*      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                                         Gapigraphic      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%    */    /** Creates a color in 0x00RRGGBB format from the three supplied ints.      *      * @param r Red component. Must be in the interval 0x00 ... 0xFF.      * @param g Green component. Must be in the interval 0x00 ... 0xFF.      * @param b Blue component. Must be in the interval 0x00 ... 0xFF.      *       * @returns A color in 0x00RRGGBB format. If the input      *          ints are not in the specified range, the return value is not specified.      */    protected static int RGB(int r, int g, int b){	return ( r<<16 | g<<8 | b );    }    /** Sets the color used for outlined drawing operations, lines and pixels.      * <p>      *      * @param c a color in 0x00RRGGBB format. In C, this was a uint32.      * <i>Dummy method. This means it does nothing yet, or is at best partially implemented.</i>      */    protected void GASetCurrColour(int c) {	lineColor = c;    }    protected int GAGetCurrColour() {	return lineColor;    }    /** Sets the color to be used for filled drawing operations      * <p>      * <i>Dummy method. This means it does nothing yet, or is at best partially implemented.</i>      *      * @param c a color in 0x00RRGGBB format. In C, this was a uint32.      */    protected void GASetFillColour(int c) {	fillColor = c;    }    /** Returns the color used for filled drawing operations      * <p>      * <i>Dummy method. This means it does nothing yet, or is at best partially implemented.</i>      */    protected int GAGetFillColour() {	return fillColor;    }    /** Sets the color to be used when clearing the display.      * <p>      * <i>Dummy method. This means it does nothing yet, or is at best partially implemented.</i>      * @param c a color in 0x00RRGGBB format. In C, this was a uint32.      */    protected void GASetBackgroundColour(int c) {	clearColor = c;    }    /** Sets the bitmap background mode. This method will likely be obsolete      * since the only way to get transparency in MIDP 1.0 is if the implementation      * implements the <i>optional</i> PNG alpha channel. That means      * transparency is set on a per-image basis if it is at all available.      * <p>      * If the implementation supports PNG alpha channel, images will have to be      * converted.      * <p>      * <i>Obsolete. Used only with b/w screens.</i>      *      * @param transparent If true the background will be transparent.      *                    If false it will be opaque.      */    /*protected byte GASetBitmapBackgroundMode(boolean transparent) {	return 0;	}*/    /*enum BackgroundMode_t    public static final byte BK_TRANSPARENT = 1;    public static final byte BK_OPAQUE = 2;    public static final byte BK_OUTLINE = 3;    public static final byte BK_SHADOW_LOWERRIGHT = 4;    public static final byte BK_SHADOW_LOWERLEFT = 5;    public static final byte BK_SHADOW_UPPERRIGHT = 6;    public static final byte BK_SHADOW_UPPERLEFT = 7;*/    /** Returns current font width. This method will likely be obsolete      * since MIDP 1.0 supports variable width fonts and returns width only on a per      * character basis. For now, it assumes the current font is fixed width and      * returns the width of the space character.      * <p>      * <i>Dummy method. This means it does nothing yet, or is at best partially implemented.</i>      *      * @returns Font width. In the C implementation, it returned a sint16.      */    protected int GAGetCurrfontWidth(){	return g.getFont().charWidth(' ');    }    /** Returns current font height.      *      * @returns Font width. In the C implementation, it returned a sint16.      */    protected int GAGetCurrfontHeight() {	return g.getFont().getHeight();    }    /**      * Selects font. In C, this was used to select the game's "font file"       * which actually contained the images for the game. This is obsolete and should be,       * but has not yet been removed from      * the games by C2Java.      * <p>      * <i>Obsolete. Must, but has not yet been, removed from source by C2Java.</i>      *      * @param font The font to be selected. In C, this was const Font_t* (typedef struct{} Font_t).      *      * @returns The old font. In C, this was Font_t*.      */    /*Font_t GASelectFont(Font_t font)      {        return font;      } */    /**      * Returns the width of an image specified by an id.      *      * @param id An identifier for the image. In C, this was WCHAR_t (typedef uint16 WCHAR_t).      *      * @returns The width. in C, this was sint16.      *      * @see GACharOut      */    abstract int GAGetCharWidth(int id);    /**      * Returns the height of an image specified by an id.      *      * @param id An identifier for the image. In C, this was WCHAR_t (typedef uint16 WCHAR_t).      *      * @returns The width. in C, this was sint16.      *      * @see GACharOut      */    abstract int GAGetCharHeight(int id);    /** There are two ways to write an image to the screen. This is one of them - it is       * an artifact from the original C Game API. The other way is of course g.drawImage().      * The image is specified by an id. This id was the entry in the font      * table in the old C implementation. Since GameShell knows nothing about those id:s this      * is abstract. The implementation must translate the ID number into an actual image      * and draw that image to the screen.      * <p>      * In the original C Game API this was used to      * write a character from the current selected font. However it      * was more often used to draw the images in the game. Those      * images were stored in a font file. They must now be converted      * to PNG format.      * <p>      * Comparison with original C function. This routine no longer returns the actual image      * width, nor does it take the image width and height as arguments.      *      * @param id     The number that was formerly the id in the font table. In C this was WCHAR_t (uint16).      * @param x      The x cordinate to place the image. In C this was sint16.      * @param y      The y cordinate to place the image. In C this was sint16.      */    abstract void GACharOut(int id, short x, short y);    /**      * Stetch a character from the current selected font      * <p>      * <i>Dummy method. This means it does nothing yet, or is at best partially implemented.</i>      *      * @param id     The id in the font table. In C, this was WCHAR_t (uint16).      * @param x      The x cordinate to place the image. In C, this was sint 16.      * @param y      The y cordinate to place the image. Was sint16.      * @param width  The width to which the image should be stretched. Was sint16.      * @param height The height to which the image should be stretched. Was sint16.      *      * @returns TRUE if it all went OK, otherwise it returns FALSE. In C this was sint16 ?!.      */    /*boolean GAStretchChar(int id, int x, int y, int width, int height) {      return true;      }*/    /**      * Function used to specify which zone must be refreshed ( manual refresh )      * This function is used at the same time that the other manual refresh functions      * <p>      * <i>Dummy method. This means it does nothing yet, or is at best partially implemented.</i>      *      * @param xo The x cordinate of the lower left corner of the rectangel to be refreshed. Was sint16.      * @param yo The y cordinate of the lower left corner of the rectangel to be refreshed. Was sint16.      * @param xf The x cordinate of the upper right corner of the rectangel to be refreshed. Was sint16.      * @param yf The y cordinate of the upper right corner of the rectangel to be refreshed. Was sint16.      *      *      */    /*void GARefreshManualZone(int xo, int yo, int xf, int yf) {}*/    /**      * Does a repaint()      *      */    void GACheckForRefresh() {	timerThread.paintNotScheduled = false;	repaint();    }    /**      * Show a information box, it is a window containing of several textlabels       * and strings, its kind of window      * Every text id's and strings except for the Title will can be scrolled       * with the upp/down arrow keys      *      * If a TextId is set to TEXTID_NONE, the textlabel will not be included      * If a String is set to NULL it will not be used      *      * @param Title The title of the box, this title is placed at top of the       *     box and will not be scolled.      *      *      *      * @param RowId1 The first line consist of this text id line      *      * @param RowId2 The second line consist of this text id line      * @param RowId3 The third line consist of this string      *      * @param RowId4 The fourth line consist of this text id line      * @param RowId5 The fifth line consist of this string      *      * @param RowId6 The sext line consist of this text id line      * @param RowId7 The sevent line consist of this string      *      * @param RowId8 The eight line consist of this text id line      *      * @returns None      *      */    void GAInfoBox(int Title,		   int RowId1,		   int RowId2,		   String RowId3,		   int RowId4,		   String RowId5,		   int RowId6,		   String RowId7,		   int RowId8)    {	int w = g.getFont().stringWidth(RowId3)+10;	int w5 = g.getFont().stringWidth(RowId5)+10;	if(w5>w) w = w5;	int w7 = g.getFont().stringWidth(RowId7)+10;	if(w7>w) w = w7;	int h = g.getFont().getHeight()+10;	int x = (DISPLAY_WIDTH-w)/2;	int y = (DISPLAY_HEIGHT-h)/2;	g.setColor(GACOLOR_BLACK);	g.fillRect(x+2,y+2,w,h*3);	g.setColor(GACOLOR_WHITE);	g.fillRect(x,y,w,h*3);	g.setColor(GACOLOR_BLACK);	g.drawRect(x,y,w,h*3);	g.drawString(RowId3,x+5,y+5,ALIGN_TOP_LEFT);	g.drawString(RowId5,x+5,y+5+h,ALIGN_TOP_LEFT);	g.drawString(RowId7,x+5,y+5+2*h,ALIGN_TOP_LEFT);	timerThread.paintNotScheduled = false;	repaint();    } // GAInfoBox    /**      * Show a message box, like a splash box      * This message box shows any internal textlabel in a message box.      * <p>      * <i>This is only partially implemented. Does not print the</i>      * <i>text label specified by msg, but instead prints "Message"</i>      *      * @param Msg The text id to be shown. C: was typedef uint32 TextId.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -