📄 gamerank.java
字号:
package GoGoGo;import java.util.Vector;import javax.microedition.rms.*;import java.io.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2003</p> * <p>Company: </p> * @author not attributable * @version 1.0.0 */public class GameRank extends GameFrameBase{ // constants final static byte RANK_TOTAL = 5; final static byte SIGNNAME_MAX = 6; final static byte MAP_X_LENGTH = 5; final static byte MAP_Y_LENGTH = 4; final static byte START_POS_X = 4; final static byte START_POS_Y = 1; final static byte FONT_SIZE = 7; final static byte SIGN_BOARD_TEXTSPACE = 10; final static byte RANK_LINESPACE = 16; final static byte RANK_HEADPOS = 44; final static byte RANK_TAP1 = 23; final static byte RANK_TAP2 = 45; final static byte RANK_TAP3 = 91; final static byte RANKS_RANK = 0; final static byte RANKS_SIGN = 1; byte m_s_RankName[][]; int m_i_RankScore[]; byte m_s_CurrName[]; byte m_i_CurrSeleIdx; byte m_i_CurrNameLength; byte m_i_GameState; int m_i_CurrScore; int iTemp; private Surface m_Surface_TitleRank = null; private Surface m_Surface_TitleSign = null; private Surface m_Surface_Font7 = null; public GameRank() { m_vect_SurfacePath = new Vector(); m_vect_SurfacePath.addElement("/title_rank.png"); m_vect_SurfacePath.addElement("/title_sign.png"); m_vect_SurfacePath.addElement("/font7.png"); m_s_RankName = new byte[RANK_TOTAL][SIGNNAME_MAX]; m_i_RankScore = new int[RANK_TOTAL]; m_s_CurrName = new byte[SIGNNAME_MAX]; ReadRankRecord(); } public void Create(GameViewBase view) { m_View = view; m_BackGraphy = m_View.m_g_BackGraphy; m_Surface_TitleRank = m_View.nextSurface(); m_Surface_TitleSign = m_View.nextSurface(); m_Surface_Font7 = m_View.nextSurface(); } public void Release() { if(m_View != null) m_View.ReleaseAllSurfaces(); } public void OnKeyDown(int iScanCode) { switch(m_i_FrameState) { case RANKS_RANK: GotoCover(); break; case RANKS_SIGN: Sign_Onkey(iScanCode); break; } } private void Sign_Onkey(int iScanCode) { switch (iScanCode) { case GameViewBase.KEY_SOFTKEY1: case GameViewBase.KEY_FIRE: if (m_i_CurrSeleIdx == 41) { if (m_i_CurrNameLength > 0) { m_s_CurrName[m_i_CurrNameLength - 1] = 0; m_i_CurrNameLength --; } break; } if (m_i_CurrSeleIdx == 42) { SaveRankAndExit(); GotoRank(); break; } m_s_CurrName[m_i_CurrNameLength] = m_i_CurrSeleIdx; m_s_CurrName[m_i_CurrNameLength]++; m_i_CurrNameLength++; if (m_i_CurrNameLength == SIGNNAME_MAX) { SaveRankAndExit(); GotoRank(); } break; case GameViewBase.KEY_UP: if (m_i_CurrSeleIdx > 40) { m_i_CurrSeleIdx -= 7; break; } if (m_i_CurrSeleIdx > 35) { m_i_CurrSeleIdx -= 10; break; } if (m_i_CurrSeleIdx > 31) { m_i_CurrSeleIdx = 25; break; } if (m_i_CurrSeleIdx > 25) { m_i_CurrSeleIdx -= 6; break; } if (m_i_CurrSeleIdx > 9) { m_i_CurrSeleIdx -= 10; break; } if (m_i_CurrSeleIdx > 7) { m_i_CurrSeleIdx += 33; break; } if (m_i_CurrSeleIdx > 4) { m_i_CurrSeleIdx = 40; break; } m_i_CurrSeleIdx += 36; break; case GameViewBase.KEY_RIGHT: m_i_CurrSeleIdx++; if (m_i_CurrSeleIdx > 42) m_i_CurrSeleIdx = 0; break; case GameViewBase.KEY_DOWN: if (m_i_CurrSeleIdx < 16) { m_i_CurrSeleIdx += 10; break; } if (m_i_CurrSeleIdx < 20) { m_i_CurrSeleIdx = 25; break; } if (m_i_CurrSeleIdx < 26) { m_i_CurrSeleIdx += 6; break; } if (m_i_CurrSeleIdx < 31) { m_i_CurrSeleIdx += 10; break; } if (m_i_CurrSeleIdx < 34) { m_i_CurrSeleIdx = 40; break; } if (m_i_CurrSeleIdx < 36) { m_i_CurrSeleIdx += 7; break; } if (m_i_CurrSeleIdx < 41) { m_i_CurrSeleIdx -= 36; break; } m_i_CurrSeleIdx -= 33; break; case GameViewBase.KEY_LEFT: if (m_i_CurrSeleIdx == 0) m_i_CurrSeleIdx = 42; else m_i_CurrSeleIdx--; break; } } public void GotoGameRank(int iScore) { m_i_CurrScore = iScore; if(m_i_CurrScore > m_i_RankScore[RANK_TOTAL - 1]) { m_i_CurrNameLength = 0; m_i_FrameTimer = 0; m_i_FrameState = RANKS_SIGN; } else { m_i_FrameTimer = 0; m_i_FrameState = RANKS_RANK; } } public void GotoRank() { m_i_FrameTimer = 0; m_i_FrameState = RANKS_RANK; } public void GotoCover() { m_View.m_pge_gamepage.GotoMenu(); m_View.m_pge_gameswitch.SwitchFrame(this, m_View.m_pge_gamepage); } public void OnKeyUp(int iScanCode) { } public void Show() { switch(m_i_FrameState) { case RANKS_RANK: DrawGameBackGround(); DrawRank(); break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -