📄 sprite.java
字号:
/* End Modified 18-03-2003 */
}
static private void renderSam(Graphics g, int animationCycle, CharacterSprite ch) {
int x = ch.charX();
int y = ch.charY();
int img_num = 0;
if (ch.charDir() == Globals.DOWNRIGHT) {
img_num = 1;
}
/* Start Modified 18-03-2003 transparency */
drawClipped(g, IMG_ALL, x+1, y+1, g_arr3ClipInfo_Sam, img_num,1);
/* End Modified 18-03-2003 */
}
static void drawCurse(Graphics g, CharacterSprite ch) {
/* Start Modified 18-03-2003 transparency */
drawClipped(g, IMG_ALL, ch.charX() + 8, ch.charY() - 18, g_arr2ClipInfo_Curse, 0, g_arr2ClipInfo_Curse.length);
/* End Modified 18-03-2003 */
}
static void drawPausedScreen(Graphics g, int selected) {
// Draw box
g.setColor(0, 0, 255);
g.drawRect(Globals.GAMEMENU_BOX_X - 2, Globals.GAMEMENU_BOX_Y - 2, Globals.GAMEMENU_BOX_WIDTH + 3, Globals.GAMEMENU_BOX_HEIGHT + 3);
g.setColor(255, 0, 0);
g.drawRect(Globals.GAMEMENU_BOX_X - 1, Globals.GAMEMENU_BOX_Y - 1, Globals.GAMEMENU_BOX_WIDTH + 1, Globals.GAMEMENU_BOX_HEIGHT + 1);
g.setColor(BG_COLOR);
g.fillRect(Globals.GAMEMENU_BOX_X, Globals.GAMEMENU_BOX_Y, Globals.GAMEMENU_BOX_WIDTH, Globals.GAMEMENU_BOX_HEIGHT);
/* Start Modified 25-04-2003 for chineese support */
g.setColor(250,250,4);
g.setFont(Globals.font);
g.drawString(Globals.chineseString[Globals.MISC_TXT_OFFSET+3],Globals.GAMEMENU_PAUSE_X,Globals.GAMEMENU_PAUSE_Y,g.TOP | g.LEFT);
g.drawString(Globals.chineseString[Globals.MENU_TXT_OFFSET+3],Globals.GAMEMENU_QUIT_X,Globals.GAMEMENU_QUIT_Y,g.TOP | g.LEFT);
g.drawString(Globals.chineseString[Globals.MISC_TXT_OFFSET+4],Globals.GAMEMENU_SAVE_X,Globals.GAMEMENU_SAVE_Y,g.TOP | g.LEFT);
//drawWord(g, Globals.GAMEMENU_PAUSE_X, Globals.GAMEMENU_PAUSE_Y, "resume");
//drawWord(g, Globals.GAMEMENU_QUIT_X, Globals.GAMEMENU_QUIT_Y, "help");
//drawWord(g, Globals.GAMEMENU_SAVE_X, Globals.GAMEMENU_SAVE_Y, "save & quit");
int y = Globals.GAMEMENU_PAUSE_Y + 5 + (selected * Globals.GAMEMENU_ELEMENT_HEIGHT) - 1;
/* End Modified 25-04-2003 */
/* Start Modified 18-03-2003 transparency */
drawClipped(g, IMG_ALL, Globals.GAMEMENU_PAUSE_X - 12, y, g_arr2ClipInfoStuff, 9, 1);
//g.drawImage(selector, Globals.GAMEMENU_PAUSE_X - 12, y, Globals.GFX_TOPLEFT);
/* End Modified 18-03-2003 */
}
static void drawTimeStop(Graphics g, int tick) {
drawClipped(g, IMG_ALL, Globals.TIMESTOP_X, Globals.TIMESTOP_Y,
m_gArr2ClipInfo_TimeStop, tick);
}
static void drawGameOver(Graphics g, boolean draw) {
int x = (Globals.GAME_WIDTH / 2) - 28;
int y = (Globals.GAME_HEIGHT / 2) - 20;
g.setColor(BG_COLOR);
/* Start Modified 25-04-2003 for chinese support */
g.fillRect(x - 1, y - 1, 55, 15);
/* End Modified 25-04-2003 */
if (draw) {
/* Start Modified 25-04-2003 for chinese support */
g.setColor(250,250,4);
g.setFont(Globals.font);
g.drawString(Globals.chineseString[Globals.MISC_TXT_OFFSET+5],x,y,g.TOP|g.LEFT);
//drawWord(g, x, y, "game over");
/* End Modified 25-04-2003 */
}
}
static private int getIndexOfCharacter(char c) {
if (c >= 'A' && c <= 'Z') {
return c - 'A';
} else if (c >= 'a' && c <= 'z') {
return c - 'a';
} else if (c == '&') {
return 27;
} else if (c == '.') {
return 28;
} else return 26;
}
static void drawWord(Graphics g, int x, int y, String word) {
for (int i = 0; i < word.length(); i++) {
char c = word.charAt(i);
if (c >= '0' && c <= '9') {
/* Start Modified 18-03-2003 transparency */
renderScore(g, c - '0', x + m_gArr2ClipInfo_Numbers[c - '0'][2] + 1, y);
x = x + m_gArr2ClipInfo_Numbers[c - '0'][2] + 1;
/* End Modified 18-03-2003 */
}
/* Start Addition for / 14-05-2003 */
else if(c == '/'){
g.setFont(Globals.engF);
g.setColor(250,250,4);
g.drawString("/", x, y,g.TOP|g.LEFT);
x += 6;
}
/* End Addition 14-05-2003 */
else {
/* Start Modified 18-03-2003 transparency */
drawClipped(g, IMG_ALL, x, y, m_gArr2ClipInfo_Alphabet, getIndexOfCharacter(c), 1);
x += (int) m_gArr2ClipInfo_Alphabet[getIndexOfCharacter(c)][2];
/* End Modified 18-03-2003 */
}
}
}
static void renderLives(Graphics g, int lives) {
int y = BackGroundSprite.LIVES_Y;
for (int i = 0; i < lives; i++) {
drawClipped(g, IMG_ALL, BackGroundSprite.LIVES_X, y, g_arr2ClipInfoStuff, 8, 1);
y += 8;
}
}
static void drawClipped(Graphics g, Image pImage,
int x, int y,
short[][][] arr2ClipInfo,
int img_set) {
drawClipped(g, pImage, x, y, arr2ClipInfo[img_set], 0, arr2ClipInfo[img_set].length);
}
static void drawClipped(Graphics g, Image pImage,
int x, int y,
short[][] arr2ClipInfo,
int clipStart, int clipCount) {
int oldClipX = g.getClipX();
int oldClipY = g.getClipY();
int oldClipWidth = g.getClipWidth();
int oldClipHeight = g.getClipHeight();
for (int i = clipStart; i < clipStart + clipCount; i++) {
int drawX = arr2ClipInfo[i][0];
int drawY = arr2ClipInfo[i][1];
/* Start Commented 18-03-2003 transparency */
//int clipX = arr2ClipInfo[i][2];
//int clipY = arr2ClipInfo[i][3];
/* End Commented 18-03-2003 */
/* Start Modified 18-03-2003 transparency */
int clipW = arr2ClipInfo[i][2];
int clipH = arr2ClipInfo[i][3];
g.setClip(x , y , clipW, clipH);
//g.setClip(x + clipX, y + clipY, clipW, clipH);
// draw to location, but offset image by designated amount
// so that the right portion is moved over the clip area
g.drawImage(pImage, x - drawX, y - drawY, Globals.GFX_TOPLEFT);
//g.drawImage(pImage, x + clipX - drawX, y + clipY - drawY, Globals.GFX_TOPLEFT);
/* End Modified 18-03-2003 */
}
g.setClip(oldClipX, oldClipY, oldClipWidth, oldClipHeight);
}
static void drawClipped(Graphics g, Image pImage,
int x, int y,
short[][] arr2ClipInfo,
int clipCount) {
drawClipped(g, pImage, x, y, arr2ClipInfo, 0, clipCount);
}
/* Start Modified 18-03-2003 removed offset for transparency */
static final short[][] g_arr2ClipInfoStuff = {
// 0: large qbert left
{ 50, 68, 10, 11 },
// 1: circle
{ 118, 25,15, 15 },
// 2: Level word image
/* Start Modified for chinese support 12-05-2003 */
{ 82, 80, 42, 19},
/* End Modified 12-05-2003*/
// 3: header
{ 0, 1, 40, 12 },
// 4: header + TM
{ 0, 1, 48, 12 },
// 5: large qbert right
{ 60, 68, 10, 11 },
// 6: change to
/* Start Modified to one pixel down 43 -> 44*/
/* Start Modified 07-05-2003 for chinese support*/
{ 137, 30, 39, 13 },
/*{ 97, 44, 45, 5 },*/
/* End Modified 07-05-2003 */
// 7: level, round)
/* Start Modified 07-05-2003 for chinese support*/
{ 147,0, 25, 27},
//{ 97, 49, 18, 13},
/* End Modified 07-05-2003 */
// 8: small qbert left
{ 77, 25, 7, 7 },
/* Start Modified 18-03-2003 transparency */
// 9: small qbert right
{ 79, 35, 7, 7 }
/* End Modified 18-03-2003 */
};
static private final short[][] m_gArr2ClipInfo_Alphabet = { {
// Alphabet a-e
3, 25, 6, 5 }, {
13, 25, 7, 5 }, {
22, 25, 7, 5 }, {
31, 25, 7, 5 }, {
41, 25, 6, 5 }, {
// f - l
49, 25, 7, 5 }, {
58, 25, 6, 5 }, {
67, 25, 6, 5 }, {
4, 31, 6, 5 }, {
12, 31, 7, 5 }, {
21, 31, 7, 5 }, {
30, 31, 6, 5 }, {
// m - q
4, 37, 7, 5 }, {
16, 37, 7, 5 }, {
25, 37, 7, 5 }, {
33, 37, 7, 5 }, {
42, 37, 7, 5 }, {
// r - u
51, 37, 7, 5 }, {
62, 37, 6, 5 }, {
71, 37, 6, 5 }, {
4, 43, 6, 5 }, {
// u +
12, 43, 7, 5 }, {
21, 43, 7, 5 }, {
31, 43, 7, 5 }, {
4, 49, 6, 5 }, {
12, 49, 6, 5 }, {
// Blank space
44, 31, 7, 5 }, {
// and
38, 31, 6, 5 }, {
// .
51, 31, 3, 5 }
};
static private final short[][] m_gArr2ClipInfo_Numbers = { {
// Numbers starting at 0 - 4
22, 49, 5, 5 }, {
31, 49, 3, 5 }, {
37, 49, 5, 5 }, {
44, 49, 4, 5 }, {
52, 49, 5, 5 }, {
// 5 - 9
61, 49, 4, 5 }, {
70, 49, 5, 5 }, {
77, 49, 4, 5 }, {
6, 55, 5, 5 }, {
14, 55, 4, 5 }
};
static private final short[][] m_gArr2ClipInfo_TimeStop = { {
2, 82, 14, 17 }, {
17, 82,14, 17 }, {
33, 82,14, 17 }, {
49, 82,14, 17 }, {
65, 82,14, 17 }
};
/* End Modified 18-03-2003 transparency */
/* Start Modified 18-03-2003 transparency */
static private final short[][] g_arr3ClipInfo_Ugg = {
// ur - empty
{118,0,12,13},
/*
{ 119, 3, 1, 3, 3, 2 },
{ 119, 5, 1, 5, 4, 8 },
{ 123, 5, 5, 5, 5, 3 },
{ 118, 8, 0, 8, 1, 3 },
{ 123, 8, 5, 8, 7, 4 },
{ 123, 0, 5, 0, 1, 1 },
{ 124, 1, 6, 1, 1, 1 },
{ 124, 2, 6, 2, 5, 4 },
{ 127, 12, 9, 12, 1, 1 },
},
*/
{ // ul - face up (empty)
},
// dr - empty
{118,13,13,12},
/*
{ 119, 13, 1, 0, 4, 7 },
{ 123, 15, 5, 2, 3, 5 },
{ 118, 20, 0, 7, 8, 4 },
{ 126, 21, 8, 8, 2, 3 },
{ 120, 24, 2, 11, 3, 1 },
{ 125, 14, 7, 1, 4, 5 },
{ 118, 15, 0, 2, 1, 1 },
{ 129, 18, 11, 5, 1, 1 },
{ 130, 19, 12, 6, 1, 1 },
},
*/
{ // dl - face down (empty)
}
};
static private final short[][] g_arr2ClipInfo_Curse = {
// Curse parts
{ 88,27,30,17
/*
{ 91, 28, 3, 1, 24, 1 },
{ 88, 31, 0, 4, 30, 6 },
{ 89, 37, 1, 10, 28, 1 },
{ 91, 39, 3, 12, 24, 1 },
{ 92, 41, 4, 14, 3, 2 },
{ 94, 27, 6, 0, 18, 1 },
{ 89, 29, 1, 2, 28, 2 },
{ 90, 38, 2, 11, 26, 1 },
{ 92, 40, 4, 13, 21, 1 },
{ 90, 43, 2, 16, 2, 1 },
*/
}
};
static private final short[][] g_arr3ClipInfo_Slick =
{
// left slick 80 68
{80,68,9,11},
/*
{85,68,5,0,3,1},
{83,69,3,1,6,2},
{82,71,2,3,6,1},
{80,72,0,4,8,4},
{81,76,1,8,7,1},
{82,77,2,9,5,1},
{81,78,1,10,5,1}
},
*/
// right slick 89 68
{89,68,9,11}
/*
{90,68,1,0,3,1},
{89,69,0,1,6,2},
{90,71,1,3,6,1},
{90,72,1,4,8,4},
{90,76,1,8,7,1},
{91,77,2,9,5,1},
{92,78,3,10,5,1}
},
*/
};
static private final short[][] g_arr3ClipInfo_Sam = {
// left slick 98 68
{98,68,9,11},
/*
{85+18,68,5,0,3,1},
{83+18,69,3,1,6,2},
{82+18,71,2,3,6,1},
{80+18,72,0,4,8,4},
{81+18,76,1,8,7,1},
{82+18,77,2,9,5,1},
{81+18,78,1,10,5,1}
},
*/
// right slick 107 68
{107,68,9,11}
/*
{90+18,68,1,0,3,1},
{89+18,69,0,1,6,2},
{90+18,71,1,3,6,1},
{90+18,72,1,4,8,4},
{90+18,76,1,8,7,1},
{91+18,77,2,9,5,1},
{92+18,78,3,10,5,1}
},
*/
};
static private final short[][] g_arr3ClipInfo_GreenBall = {
// Green Ball - flat
{ 27,62,8,5},
/*
{ 28, 62, 1, 0, 6, 5 }, {
27, 63, 0, 1, 8, 3 }
},
*/
// Green Ball - round
{ 41,62,8,6}
/*
{ 42, 62, 1, 0, 6, 6 }, {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -