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

📄 gamecanvas.java

📁 J2ME的游戏原代码!希望能帮助有需要帮助的师兄弟们!
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    private int m_nFirstOriginalX;

    /**
     * The Y coordinate of a point to be transformed for display.
     */
    private int m_nFirstOriginalY;

    /**
     * The X coordinate of a point to be transformed for display.
     */
    private int m_nSecondOriginalX;

    /**
     * The Y coordinate of a point to be transformed for display.
     */
    private int m_nSecondOriginalY;

    /**
     * The "intermediate" scaling factor to be applied
     * to the X coordinate of a point to be transformed for display.
     */
    private long m_lFirstIntermediateXScalingFactor;

    /**
     * The "intermediate" scaling factor to be applied to the X coordinate
     * of a point to be transformed for display.
     */
    private long m_lSecondIntermediateXScalingFactor;

    /**
     * The X coordinate of a transformed point
     */
    private int m_nFirstTransformedX;

    /**
     * The Y coordinate of a transformed point
     */
    private int m_nFirstTransformedY;

    /**
     * The X coordinate of a transformed point
     */
    private int m_nSecondTransformedX;

    /**
     * The Y coordinate of a transformed point
     */
    private int m_nSecondTransformedY;

    /**
     * An argument to the transformation method,
     * used to indicate that a character's
     * (enemy's or erix's) coordinates are to be transformed.
     */
     private final byte CHARACTER = 0;

    /**
     * An argument to the transformation method,
     * used to indicate that only one point is to be transformed,
     * and it is not the coordinate of a character.
     */
     private final byte SINGLE_POINT = 1;

    /**
     * An argument to the transformation methods,
     * used to indicate that two points
     * (the ends of a line segment) are to be transformed.
     */
     private final byte LINE_SEGMENT = 2;

    /**
     * The main off-screen buffer, on which the entire game display is painted
     * before copying it onto the screen.
     */
    private Image m_imgOffscreen;

    /**
     * Graphics context for the off-screen buffer.
     */
    private Graphics m_objOffscreenContext;

    /**
     * The current frame to be displayed for the characters
     */
    private int m_nFrameNum;

    /**
     * The coutner for the number of iterations to wait for
     * before changing the frame of a character.
     */
    private int m_nFrameChangeWaitCounter;

    /**
     * Number of frames in the images for the characters.
     */
    private final int NUM_FRAMES = 9;

    /**
     * The number of iterations to wait for
     * before changing the frame of a character.
     */
    //private final int FRAME_CHANGE_WAIT = 2;
    private final int FRAME_CHANGE_WAIT = 1;

    /**
     * Width of each frame of a character.
     */
    private final int FRAME_WIDTH = 17;

    /**
     * Horizontal distance of a character's active point
     * from the left edge of its frame.
     */
    private final int ACTIVE_POINT_X_OFFSET = 10;

    /**
     * Maximum height of each frame of a character.
     */
    private final int MAX_FRAME_HEIGHT = 13;

    /**
     * Reduction to be applied to the height of a character
     * (by displaying the appropriate sized images)
     */
    private int m_nFrameHeightReduction = 0;

    /**
     * Maximum height reduction to be applied to a character.
     */
    private final int MAX_HEIGHT_REDUCTION = 2;

    /**
     * Sequences of frames used to display Erix
     * (Multiple sequences of frames, in different sizes).
     */
    private Image m_imgErix;

    /**
     * Array of images for all enemy types.
     * (4 enemies, with image sequences in different sizes).
     */
    private Image[] m_arrimgEnemy = new Image[4];

    /**
     * Array which stores all layout images.
     */
    private Image[] m_arrimgLevel;

    /**
     * Reference to the current level image.
     */
    private Image m_imgLevel;

    /**
     * Image used for displaying the number of lives left with the user.
     */
    private Image m_imgLifeIcon;

    /**
     * For modes in which a message needs to be displayed to the user,
     * this flag tracks whether a message has already been painted once.
     * If so, the existing image buffer is re-used, saving considerably on
     * processing required in the game loop iteration.
     * This saving in processing is a must to be able to play sounds effects
     * without interruption.
     */
     //public boolean m_bMessagePaintedOnce = false;
     public boolean m_bMessagePaintedOnce;

    /**
     * For modes in which a message needs to be displayed to the user,
     * if the message has been painted once, it is not painted again
     * in that mode, to save processing required. Towards this purpose,
     * a flag is maintained. However, it may happen that the state of the game
     * changes from one message-oriented mode to another. In that case,
     * since the new mode will be one of the message-oriented ones,
     * and the flag would indicate that the message has been painted once,
     * the screen would not be updated and
     * the message for the old mode would continue to be displayed.
     * To avoid such an occurence, this counter is used to remember
     * the mode of the game during the previous call to the method
     * paintGameScreen(). If the mode in the current iteration is different
     * than the mode in the previous iteration, the display is allowed to be updated.
     */
     private int m_nPreviousEngineMode;

    /**
     * The color used to display secured regions in levels 1-8.
     * (A shade of Brown).
     */
    private final int SECURED_REGION_COLOR_1 = 0x00ADD3FF;

    /**
     * The color used to display secured regions in levels 9-16.
     * (A shade of Blue)
     */
    private final int SECURED_REGION_COLOR_2 = 0x00BBEDB2;

    /**
     * The color used to display secured regions in levels 17-24.
     * (A shade of Green).
     */
    private final int SECURED_REGION_COLOR_3 = 0x00FBB394;

    /**
     * A variable to store the value of the color to be used
     * for displaying the secured region in a particular level.
     */
     private int m_nSecuredRegionColor;

    /**
     * The color used to display the statistics in levels 1-8.
     * (A shade of brown)
     */
    //private final int STATISTICS_COLOR_1 = 0xAD6D18;
    //private final int STATISTICS_COLOR_1 = 0xFF0000;
    private final int STATISTICS_COLOR_1 = 0xFFFFFF;

    /**
     * The color used to display the statistics in levels 9-16.
     * (A shade of medium-to-dark blue).
     */
    //private final int STATISTICS_COLOR_2 = 0x31A2D6;
    private final int STATISTICS_COLOR_2 = 0xFFFFFF;

    /**
     * The color used to display the statistics in levels 17-24.
     * (A shade of dark green).
     */
    //private final int STATISTICS_COLOR_3 = 0x008200;
    private final int STATISTICS_COLOR_3 = 0xFFFFFF;

    /**
     * The color used as the background one
     * for the "score" statistic, to give it a 3-D look.
     */
    //private final int STATISTICS_BACKGROUND_COLOR = 0xFFFF00;
    private final int STATISTICS_BACKGROUND_COLOR = 0xFF0000;

    /**
     * A variable to store the value of the color
     * used to display the statistics in a particular levels.
     */
     private int m_nStatisticsColor;

    /**
     * The color used to display the completed line segments
     * of Erix's current path.
     * (A shade of Magenta).
     */
    private final int ERIX_COMPLETED_LINE_SEGMENT_COLOR = 0xDE49FF;

    /**
     * The color used to display Erix's path
     * when it is crossed by Erix or by an Enemy.
     * (Red).
     */
    private final int ERIX_CROSSED_PATH_COLOR = 0xFF0000;

    /**
     * The main color used to display in-game messages (e.g., "Game paused").
     */
    private final int GAME_MESSAGES_FOREGROUND_COLOR = 0xEE51EE;

    /**
     * The background color for the in-game messages, to give a 3D effect.
     */
    private final int GAME_MESSAGES_BACKGROUND_COLOR = 0xFFFF00;

    /**
     * X-Offset of any point on a level,
     * from the top-left corner of the device's screen.
     * This is calculated as the horizontal distance between the position
     * of the bottom-right corner of the untranslated playfield, and the
     * position of the bottom-right corner after the playfield has been
     * translated to its desired location.
     * Currently, X coord of translated position = A,
     * while X coord of translated position = B.
     * Therefore, offset desired = A-B.
     */
    private final byte DRAWING_X_OFFSET_FROM_SCREEN_ORIGIN = 34;

    /**
     * Y-Offset of any point on a level,
     * from the top-left corner of the device's screen.
     * This is calculated as the horizontal distance between the position
     * of the bottom-right corner of the untranslated playfield, and the
     * position of the bottom-right corner after the playfield has been
     * translated to its desired location.
     * Currently, Y coord of translated position = C.
.     * while Y coord of translated position = D.
     * Therefore, offset desired = C-D.
     */
    private final byte DRAWING_Y_OFFSET_FROM_SCREEN_ORIGIN = 25;

    /**
     * Object for manipulating the font of the Canvas.
     */
    private Font m_objFont;

    /**
     * The font for the highscores list screen.
     */
    private Font m_objHighscoresFont;


    private int m_objHighscoresFontHeight;

    /**
     * Horizontal distance between the various columns of data
     * on the highscores screen.
     */
    private int m_nColumnGap;

    /**
     * X coordinate for data in the rank column of the highscore screen.
     */
    private int m_nRankColumnStartX = 2;

    /**
     * X coordinate for data in the signature column of the highscore screen.
     */
    private int m_nSignatureColumnStartX;

    /**
     * X coordinate for data in the difficulty column of the highscore screen.
     */
    private int m_nDifficultyColumnStartX;

    /**
     * X coordinate for data in the level number column of the highscore screen.
     */
    private int m_nLevelColumnStartX;

    /**
     * X coordinate for data in the score column of the highscore screen.
     */
    private int m_nScoreColumnStartX;

    /**
     * The minimum vertical gap (in pixels)
     * between two successive lines of text,
     * when printed by the application through the low-level lcdui API.
     */
     private final int MIN_VERTICAL_GAP_BETWEEN_LINES = 3;


    /**
     * The previous mode of the Game Engine.
     */
    private int m_nPrevEngineMode;


	/**
	 * Stores the coordinates in "real" screen space of the lines to be drawn
	 * First indent is Y(vertical), second is X(horizontal) m_arrLinesFrame[Y][0] contains number of X coord
	 */
	private byte[][] m_arrLinesFrame;

	/**
	 * Stores for the m_arrLinesFrame which sides are to be filled
	 */
	private byte[][] m_arrLinesFrameFillDir;

	/**
	 * Maximum number of X coord in m_arrLinesFrame[Y]
	 */
	private static int MAX_NUMBER_X_COORD = 11;


	/**
	 * Directions to follow a secured contour
	 */
	static final int DIR_UP = 0;
	static final int DIR_RIGHT = 1;
	static final int DIR_DOWN = 2;
	static final int DIR_LEFT = 3;

	static final int NUMBER_DIR = 4;

	/**
	 * Keeps the current iteration for fillLinesFrame
	 */
	private int m_nIndexRow;
	private int m_nIndexCol;

	/**
	 * Size of the Image in which the scores are drawn
	 */
	static final int SCORES_WIDTH = 48;

⌨️ 快捷键说明

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