📄 stagecanvas.java
字号:
this.stage_CenterY + 30, this.ANCHOR0_LT);
g.setColor(this.COLOR_RED);
g.drawString("返回", stage_CenterX + 40, stage_CenterY + 65, this.ANCHOR0_LT);
}
/*
游戏难度选择
*/
private void drawGradeScreen(Graphics g) { //主菜单
this.drawClearScreen(g, this.COLOR_BLACK);
g.setColor(this.COLOR_WHITE);
g.setFont(this.FONT_SMALL);
g.drawString("游戏级别", this.stage_CenterX - 20,
this.stage_CenterY - 30,
this.ANCHOR0_LT);
for (int i = 0; i < 3; i++) {
g.drawString(this.STR_GRADE[i], this.stage_CenterX - 10,
this.stage_CenterY - 10 + 20 * i,
this.ANCHOR0_LT);
if (this.gradeSelectIndex == i) {
g.drawString("==>", this.stage_CenterX - 40,
this.stage_CenterY - 10 + 20 * i,
this.ANCHOR0_LT);
}
}
g.setColor(this.COLOR_RED);
g.drawString("确定", stage_CenterX - 60, stage_CenterY + 50, this.ANCHOR0_LT);
g.drawString("返回", stage_CenterX + 40, stage_CenterY + 50, this.ANCHOR0_LT);
}
//背景边框图 frame num:0 1 2 3 (left—right)4 5(down)
private void drawCutFrame(Graphics g, int num) { //
switch (num) {
case 0:
this.setClipImage(g, 0, 2, images[4], 14 * num, 0, 10, 104,
this.ANCHOR0_LT);
this.setClipImage(g, 0, 105, images[4], 14 * num, 0, 10, 104,
this.ANCHOR0_LT);
break;
case 1:
this.setClipImage(g, this.stage_Width - 10, 0, images[4], 10 * num + 1,
0,
10, 103,
this.ANCHOR0_LT);
this.setClipImage(g, this.stage_Width - 10, 103, images[4], 10 * num + 1,
0,
10, 104,
this.ANCHOR0_LT);
break;
case 2:
this.setClipImage(g, 0, 2, images[4], 10 * num + 2, 0, 10, 104,
this.ANCHOR0_LT);
this.setClipImage(g, 0, 105, images[4], 10 * num + 2, 0, 10, 104,
this.ANCHOR0_LT);
break;
case 3:
this.setClipImage(g, this.stage_Width - 10, 0, images[4], 10 * num + 3,
0,
10, 103,
this.ANCHOR0_LT);
this.setClipImage(g, this.stage_Width - 10, 103, images[4], 10 * num + 3,
0,
10, 104,
this.ANCHOR0_LT);
break;
case 4:
this.setClipImage(g, 0, 0, images[4], 0,105, 176, 13,
this.ANCHOR0_LT);
break;
case 5:
this.setClipImage(g, 0, this.stage_Height - 13, images[4], 0, 105 + 14,
176, 14,
this.ANCHOR0_LT);
break;
}
}
/*
绘制背景
*/
private void drawBackground(Graphics g) {
// this.drawClearScreen(g, this.COLOR_WHITE);
g.drawImage(images[1], 0, 0, this.ANCHOR0_LT); //背景
g.drawImage(images[1], this.stage_CenterX - 32, 0, this.ANCHOR0_LT);
g.drawImage(images[1], this.stage_CenterX - 64, 0, this.ANCHOR0_LT);
g.drawImage(images[1], this.stage_CenterX, 0, this.ANCHOR0_LT);
g.drawImage(images[1], this.stage_CenterX + 32, 0, this.ANCHOR0_LT);
g.drawImage(images[1], this.stage_CenterX + 64, 0, this.ANCHOR0_LT);
}
/*
绘制边框
*/
private void drawFrame(Graphics g) {
// if ( (score[gradeSelectIndex % 3] / 400) % 2 == 0) {
if ( (thisMaxScore / 200) % 2 == 0) {
this.drawCutFrame(g, 0);
this.drawCutFrame(g, 1);
}
else { //200分后交替切换岸边图片
this.drawCutFrame(g, 2);
this.drawCutFrame(g, 3);
}
this.drawCutFrame(g, 4); //上下图片
this.drawCutFrame(g, 5);
this.drawLifeValue(g); //化出life筐
g.setColor(this.COLOR_WHITE); //画的得分
g.setFont(this.FONT_SMALL);
g.drawString("" + thisMaxScore, this.stage_CenterX + 63,
this.stage_CenterY + 92,
this.ANCHOR0_LT);
}
/*
绘制生命
*/
int lifeValue = 10; //生命初始
private void drawLifeValue(Graphics g) {
for (int i = 0; i < lifeValue; i++) {
g.setColor(this.COLOR_ORG);
g.fillRect(97 + i * 7, 1, 6, 2); // 4 6
g.setColor(this.COLOR_ORG);
g.fillRect(97 + i * 7, 5, 6, 3);
g.setColor(this.COLOR_YELLOW_RED);
g.fillRect(97 + i * 7, 3, 6, 3);
}
this.isRepaint = true;
}
private void drawCopyrightScreen(Graphics g) { //厂商咨询
this.drawClearScreen(g, this.COLOR_BLACK);
g.setFont(this.FONT_SMALL);
g.setColor(this.COLOR_YELLOW_RED);
g.drawString("按键信息", 70, 25 ,this.ANCHOR0_LT);
g.drawString("导航键:(左、右)", 35, 25+20 *2, this.ANCHOR0_LT);
g.drawString("移动皮划艇", 35, 25+20 *3, this.ANCHOR0_LT);
g.drawString("左软键: 确定", 35, 25+20 * 4, this.ANCHOR0_LT);
g.drawString("右软键: 菜单", 35, 25+20 * 5, this.ANCHOR0_LT);
g.drawString("#号键:暂停", 35, 25+20 * 6, this.ANCHOR0_LT);
/* g.setColor(this.COLOR_RED);
g.drawString("开发商:", this.stage_CenterX - 50, this.stage_CenterY - 56,
this.ANCHOR0_LT);
g.setColor(this.COLOR_WHITE);
g.drawString("BBMF软件", this.stage_CenterX - 40, this.stage_CenterY - 40,
this.ANCHOR0_LT);
g.drawString("www.BBMF.com", this.stage_CenterX - 40,
this.stage_CenterY - 24, this.ANCHOR0_LT);
g.setColor(this.COLOR_RED);
g.drawString("开发成员:", this.stage_CenterX - 50, this.stage_CenterY - 8,
this.ANCHOR0_LT);
g.setColor(this.COLOR_WHITE);
g.drawString("测划: Alex_Xu", this.stage_CenterX - 40,
this.stage_CenterY + 8, this.ANCHOR0_LT);
g.drawString("美工: Ann_Lee", this.stage_CenterX - 40,
this.stage_CenterY + 24, this.ANCHOR0_LT);
g.drawString("程序: Anders,Alex", this.stage_CenterX - 40,
this.stage_CenterY + 40, this.ANCHOR0_LT);*/
g.setColor(this.COLOR_RED);
g.drawString("返回", stage_CenterX + 40, stage_CenterY + 70, this.ANCHOR0_LT);
// g.drawString("Phone:025-4632463", this.stage_CenterX - 50,
// this.stage_CenterY + 50, this.ANCHOR0_LT);
}
/*
游戏主菜单
*/
private void drawMenuScreen(Graphics g) { //主菜单
//System.out.println(this.getWidth());
//System.out.println(this.getHeight());
this.drawClearScreen(g, this.COLOR_BLACK);
g.drawImage(images[6], 0, 0, this.ANCHOR0_LT);
g.setFont(this.FONT_SMALL);
for (int i = 0; i < 6; i++) {
g.setColor(this.COLOR_BLUE); //0x402704);
g.drawString(this.STR_MENU[i], this.stage_CenterX - 60, 23 + 27 * i, //开始游戏
this.ANCHOR0_LT);
g.setColor(this.COLOR_RED);
if (this.menuIndex == i) {
g.drawString(this.STR_MENU[i], this.stage_CenterX - 60, 23 + 27 * i, //开始游戏
this.ANCHOR0_LT);
}
}
g.setColor(this.COLOR_RED);
g.drawString("确定", stage_CenterX - 68, stage_CenterY + 80, this.ANCHOR0_LT);
}
//游戏中菜单
private void drawPlayMenuScreen(Graphics g) {
this.drawClearScreen(g, this.COLOR_BLACK);
g.setColor(this.COLOR_WHITE);
g.setFont(this.FONT_SMALL);
for (int i = 0; i < 7; i++) {
if (i == 0) {
g.drawString("继续游戏", this.stage_CenterX - 20, 40 + 16 * i,
this.ANCHOR0_LT);
}
else {
g.drawString(this.STR_MENU[i - 1], this.stage_CenterX - 20, 40 + 16 * i,
this.ANCHOR0_LT);
}
if (this.playMenuIndex == i) {
g.drawString("==>", this.stage_CenterX - 45, 40 + 16 * i,
this.ANCHOR0_LT);
}
}
g.setColor(this.COLOR_RED);
g.drawString("确定", stage_CenterX - 60, stage_CenterY + 50+20, this.ANCHOR0_LT);
}
//音乐菜单
private void drawMusicSelectScreen(Graphics g) {
this.drawClearScreen(g, this.COLOR_BLACK);
g.setFont(this.FONT_SMALL);
g.setColor(this.COLOR_RED);
g.drawString("音乐开关", this.stage_CenterX - 20,
this.stage_CenterY - 40, //开始游戏
this.ANCHOR0_LT);
g.drawString("确定", stage_CenterX - 60, stage_CenterY + 75, this.ANCHOR0_LT);
g.setColor(this.COLOR_WHITE);
g.drawString("打开音乐", this.stage_CenterX - 20, this.stage_CenterY - 10, //开始游戏
this.ANCHOR0_LT);
g.drawString("关闭音乐", this.stage_CenterX - 20, this.stage_CenterY + 10, //开始游戏
this.ANCHOR0_LT);
if (this.musicSelectIndex == 0) {
g.drawString("==>", this.stage_CenterX - 45,
this.stage_CenterY - 10, //开始游戏
this.ANCHOR0_LT);
}
if (this.musicSelectIndex == 1) {
g.drawString("==>", this.stage_CenterX - 45,
this.stage_CenterY + 10, //开始游戏
this.ANCHOR0_LT);
}
}
//播放声音
private void playSound() {
}
/*
清除屏幕
*/
private void drawClearScreen(Graphics g, int i) {
g.setClip(0, 0, stage_Width, stage_Height);
g.setColor(i);
g.fillRect(0, 0, stage_Width, stage_Height);
}
/*
暂停
*/
public void drawPause(Graphics g) {
g.setColor(this.COLOR_ORG);
g.setFont(this.FONT_SMALL);
g.drawString(" - 暂停 -", this.stage_CenterX - 40, this.stage_CenterY,
this.ANCHOR0_LT);
g.drawString("按#键继续游戏", this.stage_CenterX - 40, this.stage_CenterY + 30,
this.ANCHOR0_LT);
}
// GAMEOVER画面
private void drawGameoverScreen(Graphics g) {
this.drawClearScreen(g, this.COLOR_WHITE);
g.drawImage(images[5], 0, 0, ANCHOR0_LT); //背景图
/*if(isSound){
try{
psound.stop();}
catch (Exception e) {
System.out.println(e);
}
}*/
}
private void drawLoseScreen(Graphics g) {
this.drawClearScreen(g, this.COLOR_BLACK);
g.setFont(this.FONT_SMALL);
g.setColor(this.COLOR_WHITE);
g.drawString("游戏得分:" + this.thisMaxScore, this.stage_CenterX - 40,
this.stage_CenterY - 30,
this.ANCHOR0_LT);
g.drawString("继续游戏", this.stage_CenterX - 25, this.stage_CenterY,
this.ANCHOR0_LT);
g.drawString("退出游戏", this.stage_CenterX - 25, this.stage_CenterY + 30,
this.ANCHOR0_LT);
g.setColor(this.COLOR_RED);
g.drawString("确定", stage_CenterX - 60, stage_CenterY + 50, this.ANCHOR0_LT);
if (this.loseSelectIndex == 0) {
g.drawString("==>", this.stage_CenterX - 45,
this.stage_CenterY,
this.ANCHOR0_LT);
}
else {
g.drawString("==>", this.stage_CenterX - 45,
this.stage_CenterY + 30,
this.ANCHOR0_LT);
}
}
//public void
private void initPlay() { //init声音
try {
// InputStream isf = getClass().getResourceAsStream("/res/" +
// "backmusic.mid");
// System.out.println("backmusic.mid");
// player = Manager.createPlayer(isf, "audio/midi"); // nokia "audio/sp-midi"
}
catch (Exception e) {
// e.printStackTrace();
}
}
public int getMenuIndex() { //得到主菜单INDEX值
return menuIndex;
}
public int getGradeSelectIndex() { //得到难度INDEX值
return gradeSelectIndex;
}
public void setGradeSelectIndex(int selected) { //设置难度INDEX值
this.gradeSelectIndex = selected;
}
public void setMenuIndex(int selected) { //设置主菜单值
this.menuIndex = selected;
}
public int getMusicSelectIndex() { //得到 musci INDEX值
return musicSelectIndex;
}
public void setMusicSelectIndex(int selected) { //设置音乐INDEX值
this.musicSelectIndex = selected;
}
public int getPlayMenuIndex() { //得到play游戏菜INDEX值
return playMenuIndex;
}
public void setPlayMenuIndex(int selected) { //设置PLAY游戏INDEX值
this.playMenuIndex = selected;
}
public int getLoseSelectIndex() { //得到lose INDEX值
return loseSelectIndex;
}
public void setLoseSelectIndex(int loseSelectIndex) { //设置lose index值
this.loseSelectIndex = loseSelectIndex;
}
private long StopWatchStartTime = 0;
// 重置停止等待的时间
protected long resetStopWatch() {
// StopWatchStartTime = System.currentTimeMillis();
return System.currentTimeMillis();
}
// 取得停止的时间
protected long getStopWatchTime() {
return System.currentTimeMillis() - StopWatchStartTime;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -