复制代码 1 package com.tarena.downwell; 2 3 import java.awt.image.BufferedImage; 4 /** 5 * 所有台阶的父类(包括顶部的刺) 6 * @author Misaki 7 * 8 */ 9 public class Board { 10 protected int x;//横坐标 11 protected int y;//纵坐标 12 protected BufferedImage image;//图片 13 protected int width;//图片宽度 14 protected int height;//图片高度 15 /* 16 * 下面都是用elipse生成的get/set方法 17 */ 18 public int getX() { 19 return x; 20 } 21 public void setX(int x) { 22 this.x = x; 23 } 24 public int getY() { 25 return y; 26 } 27 public void setY(int y) { 28 this.y = y; 29 } 30 public BufferedImage getImage() { 31 return image; 32 } 33 public void setImage(BufferedImage image) { 34 this.image = image; 35 } 36 public int getWidth() { 37 return width; 38 } 39 public void setWidth(int width) { 40 this.width = width; 41 } 42 public int getHeight() { 43 return height; 44 } 45 public void setHeight(int height) { 46 this.height = height; 47 } 48 49 } 复制代码 复制代码 package com.tarena.downwell; import java.util.Random; /** * 弹簧台阶 * @author Misaki * */ public class BoardFlip extends Board implements MoveObject,Function{ private int index = 0;//播放动画时用来控制图片数组下标 private boolean flag = true;//true就是没被踩过,踩过就false public boolean isFlag() { return flag; } public void setFlag(boolean flag) { this.flag = flag; } public BoardFlip(){//构造 Random rnd = new Random(); this.image = Game.board_e[0];//图片设为图片数组中第一个图 this.width = this.image.getWidth();//图片宽度 this.height = this.image.getHeight();//图片高度 this.x = rnd.nextInt(Game.WIDTH-this.width-10);//横坐标在游戏框范围类随机 this.y = Game.HEIGHT;//纵坐标为窗体的高度(正好在窗体之外) } @Override public void move() { this.y -= ySpeed; } /** * 这个方法每个功能性方块都差不多,只解释一次 */ public void flash(){ if(this.index==6){//如果图片播放到最后一个 this.image = Game.board_e[0];//重新把图片设为开始的图片 this.index = 0;//重置index this.flag = true;//台阶改为正常(没被踩过,总不能踩一次鬼畜一天吧) }else{//如果图片还没播放完 this.image = Game.board_e[++this.index];//播放下一个图片 } } /** * 执行功能 */ @Override public void function(Javaman man) { man.flipSpeed = -5;//给个向上的速度 this.flag = false;//说明这个方块被踩了,执行动画,动画完了再改回true } } 复制代码 复制代码 1 package com.tarena.downwell; 2 3 import java.util.Random; 4 /** 5 * 传送带(往左) 6 * @author Misaki 7 * 8 */ 9 public class BoardMoveL extends Board implements MoveObject,Function{ 10 private int index = 0; 11 12 public BoardMoveL(){//见BoradFlip 13 Random rnd = new Random(); 14 this.image = Game.board_b[0]; 15 this.width = this.image.getWidth(); 16 this.height = this.image.getHeight(); 17 this.x = rnd.nextInt(Game.WIDTH-this.width-10); 18 this.y = Game.HEIGHT; 19 } 20 @Override 21 public void move() {//传送带的动画是从头播放到尾的,就让它随着台阶向上移动一起动吧 22 if(this.index==3){//这个跟BoradFlip里flash结构一样 23 this.image = Game.board_b[0]; 24 this.index = 0; 25 }else{ 26 this.image = Game.board_b[++this.index]; 27 } 28 this.y -= ySpeed; 29 } 30 /** 31 * 给个往左的速度,区分与按键盘给的速度,最后叠加 32 */ 33 @Override 34 public void function(Javaman man) { 35 man.moveSpeed = -1; 36 } 37 //下面的都用不到,只是实现接口必须重写。(好吧我设计也有点问题) 38 @Override 39 public void flash() { 40 41 } 42 @Override 43 public boolean isFlag() { 44 return false; 45 } 46 @Override 47 public void setFlag(boolean flag) { 48 49 } 50 51 } 复制代码 复制代码 1 package com.tarena.downwell; 2 3 import java.util.Random; 4 /** 5 * 传送带(往右) 6 * @author Misaki 7 * 8 */ 9 public class BoardMoveR extends Board implements MoveObject,Function{ 10 private int index = 0; 11 12 public BoardMoveR(){//见BoradFlip 13 Random rnd = new Random(); 14 this.image = Game.board_c[0]; 15 this.width = this.image.getWidth(); 16 this.height = this.image.getHeight(); 17 this.x = rnd.nextInt(Game.WIDTH-this.width-10); 18 this.y = Game.HEIGHT; 19 } 20 @Override 21 public void move() {//见BoardMoveL 22 if(this.index==3){ 23 this.image = Game.board_c[0]; 24 this.index = 0; 25 }else{ 26 this.image = Game.board_c[++this.index]; 27 } 28 this.y -= ySpeed; 29 } 30 @Override 31 public void function(Javaman man) {//见BoardMoveL 32 man.moveSpeed = 1; 33 } 34 @Override 35 public void flash() { 36 // TODO Auto-generated method stub 37 38 } 39 @Override 40 public boolean isFlag() { 41 // TODO Auto-generated method stub 42 return false; 43 } 44 @Override 45 public void setFlag(boolean flag) { 46 // TODO Auto-generated method stub 47 48 } 49 } 复制代码 复制代码 1 package com.tarena.downwell; 2 3 import java.util.Random; 4 /** 5 * 钉子台阶 6 * @author Misaki 7 * 8 */ 9 public class BoardNail extends Board implements MoveObject,Function{ 10 private boolean flag = true; 11 public BoardNail(){//见BoradFlip 12 Random rnd = new Random(); 13 this.image = Game.board_f; 14 this.width = this.image.getWidth(); 15 this.height = this.image.getHeight(); 16 this.x = rnd.nextInt(Game.WIDTH-this.width-10); 17 this.y = Game.HEIGHT; 18 } 19 20 @Override 21 public void move() { 22 this.y -= ySpeed; 23 } 24 25 @Override 26 public void function(Javaman man) { 27 if(flag){//如果没被踩过 28 man.subLife();//减命 29 flag = false;//改为踩过 30 } 31 } 32 33 @Override 34 public void flash() { 35 // TODO Auto-generated method stub 36 37 } 38 39 @Override 40 public boolean isFlag() { 41 // TODO Auto-generated method stub 42 return false; 43 } 44 45 @Override 46 public void setFlag(boolean flag) { 47 // TODO Auto-generated method stub 48 49 } 50 } 复制代码 复制代码 package com.tarena.downwell; import java.util.Random; /** * 普通台阶 * @author Misaki * */ public class BoardNormal extends Board implements MoveObject{ public BoardNormal(){//见BoradFlip Random rnd = new Random(); this.image = Game.board_a; this.width = this.image.getWidth(); this.height = this.image.getHeight(); this.x = rnd.nextInt(Game.WIDTH-this.width-10); this.y = Game.HEIGHT; } /** * 随机产生一个普通方块,只是为了init() * @return */ public static BoardNormal randomOne(){ BoardNormal b = new BoardNormal(); Random rnd = new Random(); b.y -= rnd.nextInt(800);//设为800是让它一开始就在游戏框里 return b; } @Override public void move() { this.y -= ySpeed; } } 复制代码 复制代码 1 package com.tarena.downwell; 2 3 import java.util.Random; 4 import java.util.Timer; 5 import java.util.TimerTask; 6 /** 7 * 易碎台阶(踩上去过一会就掉下去) 8 * @author Misaki 9 * @version 1.1 10 */ 11 public class BoardOnce extends Board implements MoveObject,Function{ 12 private int index = 0; 13 private boolean flag = true; 14 15 16 public boolean isFlag() { 17 return flag; 18 } 19 public void setFlag(boolean flag) { 20 this.flag = flag; 21 } 22 public BoardOnce(){//见BoradFlip 23 Random rnd = new Random(); 24 this.image = Game.board_d[0]; 25 this.width = this.image.getWidth(); 26 this.height = this.image.getHeight(); 27 this.x = rnd.nextInt(Game.WIDTH-this.width-10); 28 this.y = Game.HEIGHT; 29 } 30 @Override 31 public void move() { 32 this.y -= ySpeed; 33 } 34 public void flash(){ 35 if(this.index==5){ 36 this.image = Game.board_d[0]; 37 this.index = 0; 38 this.flag = true; 39 }else{ 40 this.image = Game.board_d[++this.index]; 41 } 42 } 43 @Override 44 public void function(Javaman man) { 45 Timer timer = new Timer(); 46 timer.schedule(new TimerTask(){ 47 48 @Override 49 public void run() { 50 man.setY(y+height);//200ms后让小人穿过去 51 flag = false;//台阶改为没被踩过 52 } 53 54 }, 200);//只有两个参数的重载。200毫秒后执行run(),只执行一次哦! 55 } 56 } 复制代码 复制代码 1 package com.tarena.downwell; 2 /** 3 * 功能性台阶接口(弹起来,传送带转起来,刺死你,穿过去) 4 * @author Misaki 5 * 6 */ 7 public interface Function { 8 void function(Javaman man);//执行功能 9 void flash();//播放专属动画 10 /* 11 * 关于Flag的get/set 12 * Flag判断这个方块功能被没被执行,或者能不能执行 13 */ 14 boolean isFlag(); 15 void setFlag(boolean flag); 16 } 复制代码 复制代码 1 package com.tarena.downwell; 2 3 import java.awt.image.BufferedImage; 4 /** 5 * 小人类 6 * @author Misaki 7 * 8 */ 9 public class Javaman { 10 private int x;//横坐标 11 private int y;//纵坐标 12 private BufferedImage image;//图片 13 private int index = 0;//用于切换图片,形成动画 14 private int width;//图片宽 15 private int height;//图片高 16 private int ySpeed;//纵向速度 17 private int xSpeed;//横向速度 18 public int flipSpeed = 0;//弹簧台阶提供的向上速度 19 public int moveSpeed = 0;//传送带提供的横向速度 20 private boolean isManOnFloor;//是否在台阶上 21 private int life = 12;//生命 22 23 public Javaman(int x, int y) { 24 super(); 25 this.x = x; 26 this.y = y; 27 this.image = Game.javaman_s; 28 this.width = this.image.getWidth(); 29 this.height = this.image.getHeight(); 30 this.xSpeed = 0; 31 this.ySpeed = 2; 32 } 33 34 public void subLife(){//生命减一 35 life--; 36 } 37 38 public void die(){//死亡 39 life = 0; 40 } 41 42 public void addLife(){ 43 this.life++; 44 } 45 46 public int getLife(){ 47 return life; 48 } 49 50 public void move(){//横向移动 51 this.image = Game.javaman_s;//默认情况设为没有移动的图片 52 if(this.x>10 && this.x+this.width<Game.WIDTH-20){//如果在游戏框中间 53 if(xSpeed>0){//如果往右移 54 if(isManOnFloor){//如果在台阶上往右移 55 /* 56 * 播放台阶上右移的动画 57 */ 58 this.image = Game.javaman_r[index++]; 59 if(index>2){ 60 index = 0; 61 } 62 }else{//在空中 63 /* 64 * 播放空中右移的动画 65 */ 66 this.image = Game.javaman_rd[index++]; 67 if(index>2){ 68 index = 0; 69 } 70 } 71 }else if(xSpeed<0){//如果往左移 72 if(isManOnFloor){//如果在台阶上往左移 73 /* 74 * 播放台阶上左移的动画 75 */ 76 this.image = Game.javaman_l[index++]; 77 if(index>2){ 78 index = 0; 79 } 80 }else{//在空中 81 /* 82 * 播放空中左移的动画 83 */ 84 this.image = Game.javaman_ld[index++]; 85 if(index>2){ 86 index = 0; 87 } 88 } 89 } 90 this.x += xSpeed+moveSpeed;//键盘监听提供速度+传送带提供速度 91 }else if(this.x<=10){//在画面最左端 92 this.x++;//弹回来! 93 }else {//画面最右端 94 this.x--;//弹回来! 95 } 96 } 97 int flipFlag = 0;//控制被弹起来的情况下,向上速度减小的频率,快了弹得太低,慢了弹到顶了 98 public void drop(){ 99 if(flipSpeed!=0){//如果被弹起来 100 flipFlag++; 101 if(this.y>45){//如果没到顶 102 this.y += flipSpeed;//那就勇敢的上! 103 }else{//到顶了。。 104 flipSpeed = 0;//别上了,乖乖下去 105 // life--;//到顶了难道不减血?(注释原因为后来游戏主类写了判断减血的方法) 106 } 107 if(flipFlag%15==0){//到时间减速了,你想上天啊? 108 flipSpeed++;//负的数加加不就是减速吗? 109 } 110 }else{//没被弹起来 111 this.y += ySpeed;//正常下落吧。 112 } 113 } 114 115 public boolean isManOnFloor() { 116 return isManOnFloor; 117 } 118 119 public void setManOnFloor(boolean isManOnFloor) { 120 this.isManOnFloor = isManOnFloor; 121 } 122 123 public BufferedImage getImage() { 124 return image; 125 } 126 127 public void setImage(BufferedImage image) { 128 this.image = image; 129 } 130 131 public int getX() { 132 return x; 133 } 134 135 public void setX(int x) { 136 this.x = x; 137 } 138 139 public int getY() { 140 return y; 141 } 142 143 public void setY(int y) { 144 this.y = y; 145 } 146 147 public int getWidth() { 148 return width; 149 } 150 151 public void setWidth(int width) { 152 this.width = width; 153 } 154 155 public int getHeight() { 156 return height; 157 } 158 159 public void setHeight(int height) { 160 this.height = height; 161 } 162 163 public int getySpeed() { 164 return ySpeed; 165 } 166 167 public void setySpeed(int ySpeed) { 168 this.ySpeed = ySpeed; 169 } 170 171 public int getxSpeed() { 172 return xSpeed; 173 } 174 175 public void setxSpeed(int xSpeed) { 176 this.xSpeed = xSpeed; 177 } 178 179 180 } 复制代码 复制代码 1 package com.tarena.downwell; 2 3 import java.awt.Color; 4 import java.awt.Font; 5 import java.awt.Graphics; 6 import java.awt.event.KeyAdapter; 7 import java.awt.event.KeyEvent; 8 import java.awt.image.BufferedImage; 9 import java.io.IOException; 10 import java.util.ArrayList; 11 import java.util.Iterator; 12 import java.util.List; 13 import java.util.Random; 14 import java.util.Timer; 15 import java.util.TimerTask; 16 17 import javax.imageio.ImageIO; 18 import javax.swing.JFrame; 19 import javax.swing.JPanel; 20 21 /** 22 * 游戏的主类 23 * @author Misaki 24 * @version 3.2 25 * 1.将MoveObject里的常量改为负数。 26 * 2.火箭速度增大,且现在火箭根据当时小人的横坐标来生成 27 * 3.弹簧台阶现在不会连续弹起小人,即小人只有掉下来踩到台阶才会触发弹簧 28 * 4.加入游戏结束画面,游戏结束时会用图片显示下了多少层。 29 */ 30 public class Game extends JPanel{ 31 public static final int WIDTH = 500;//窗体宽度 32 public static final int HEIGHT = 900;//窗体高度 33 public static final int RUNNING = 0;//游戏运行 34 public static final int PAUSE = 1;//游戏暂停 35 public static final int START = 2;//游戏开始 36 public static final int GAME_OVER = 3;//游戏结束 37 38 private Timer timer;//定时器 39 private int intervel = 10;//定时器间隔 40 private Random rnd = new Random();//产生随机数 41 private int score = 0;//分数,即下了多少层,由于台阶上升速度一定,可以按时间增长 42 private int state = START;//游戏状态,默认为运行 43 private int level = 0; 44 45 private BoardTop boardtop = new BoardTop();//顶部尖刺 46 private Javaman man;//小人 47 private List<Board> boards = new ArrayList<Board>();//台阶集合 48 private List<Apple> apples = new ArrayList<Apple>();//苹果集合 49 private List<Monster> monsters = new ArrayList<Monster>();//怪物集合 50 private List<Rocket> rockets = new ArrayList<Rocket>();//火箭集合 51 /** 静态图片 */ 52 public static BufferedImage background; 53 public static BufferedImage pause; 54 public static BufferedImage start; 55 public static BufferedImage gameover; 56 57 public static BufferedImage[] num = new BufferedImage[10]; 58 59 public static BufferedImage apple; 60 public static BufferedImage monster; 61 public static BufferedImage rocket; 62 63 public static BufferedImage board_top; 64 public static BufferedImage board_a; 65 public static BufferedImage[] board_b = new BufferedImage[4]; 66 public static BufferedImage[] board_c = new BufferedImage[4]; 67 public static BufferedImage[] board_d = new BufferedImage[6]; 68 public static BufferedImage[] board_e = new BufferedImage[7]; 69 public static BufferedImage board_f; 70 71 public static BufferedImage[] javaman_c = new BufferedImage[3]; 72 public static BufferedImage[] javaman_l = new BufferedImage[3]; 73 public static BufferedImage[] javaman_ld = new BufferedImage[3]; 74 public static BufferedImage[] javaman_r = new BufferedImage[3]; 75 public static BufferedImage[] javaman_rd = new BufferedImage[3]; 76 public static BufferedImage javaman_s; 77 /** 静态块,加载所有图片 */ 78 static{ 79 try { 80 background = ImageIO.read(Game.class.getResource("background.gif")); 81 start = ImageIO.read(Game.class.getResource("start.gif")); 82 pause = ImageIO.read(Game.class.getResource("pause.png")); 83 gameover = ImageIO.read(Game.class.getResource("gameover.gif")); 84 85 board_top = ImageIO.read(Game.class.getResource("board/board_top.gif")); 86 board_a = ImageIO.read(Game.class.getResource("board/board_a.gif")); 87 apple = ImageIO.read(Game.class.getResource("apple.png")); 88 monster = ImageIO.read(Game.class.getResource("monster.png")); 89 rocket = ImageIO.read(Game.class.getResource("rocket.png")); 90 91 num[0] = ImageIO.read(Game.class.getResource("num/number_0.gif")); 92 num[1] = ImageIO.read(Game.class.getResource("num/number_1.gif")); 93 num[2] = ImageIO.read(Game.class.getResource("num/number_2.gif")); 94 num[3] = ImageIO.read(Game.class.getResource("num/number_3.gif")); 95 num[4] = ImageIO.read(Game.class.getResource("num/number_4.gif")); 96 num[5] = ImageIO.read(Game.class.getResource("num/number_5.gif")); 97 num[6] = ImageIO.read(Game.class.getResource("num/number_6.gif")); 98 num[7] = ImageIO.read(Game.class.getResource("num/number_7.gif")); 99 num[8] = ImageIO.read(Game.class.getResource("num/number_8.gif")); 100 num[9] = ImageIO.read(Game.class.getResource("num/number_9.gif")); 101 102 103 board_b[0] = ImageIO.read(Game.class.getResource("board/board_b1.gif")); 104 board_b[1] = ImageIO.read(Game.class.getResource("board/board_b2.gif")); 105 board_b[2] = ImageIO.read(Game.class.getResource("board/board_b3.gif")); 106 board_b[3] = ImageIO.read(Game.class.getResource("board/board_b4.gif")); 107 108 board_c[0] = ImageIO.read(Game.class.getResource("board/board_c1.gif")); 109 board_c[1] = ImageIO.read(Game.class.getResource("board/board_c2.gif")); 110 board_c[2] = ImageIO.read(Game.class.getResource("board/board_c3.gif")); 111 board_c[3] = ImageIO.read(Game.class.getResource("board/board_c4.gif")); 112 113 board_d[0] = ImageIO.read(Game.class.getResource("board/board_d1.gif")); 114 board_d[1] = ImageIO.read(Game.class.getResource("board/board_d2.gif")); 115 board_d[2] = ImageIO.read(Game.class.getResource("board/board_d3.gif")); 116 board_d[3] = ImageIO.read(Game.class.getResource("board/board_d4.gif")); 117 board_d[4] = ImageIO.read(Game.class.getResource("board/board_d5.gif")); 118 board_d[5] = ImageIO.read(Game.class.getResource("board/board_d6.gif")); 119 120 board_e[0] = ImageIO.read(Game.class.getResource("board/board_e1.gif")); 121 board_e[1] = ImageIO.read(Game.class.getResource("board/board_e2.gif")); 122 board_e[2] = ImageIO.read(Game.class.getResource("board/board_e3.gif")); 123 board_e[3] = ImageIO.read(Game.class.getResource("board/board_e4.gif")); 124 board_e[4] = ImageIO.read(Game.class.getResource("board/board_e5.gif")); 125 board_e[5] = ImageIO.read(Game.class.getResource("board/board_e6.gif")); 126 board_e[6] = ImageIO.read(Game.class.getResource("board/board_e7.gif")); 127 128 board_f = ImageIO.read(Game.class.getResource("board/board_f.gif")); 129 130 javaman_c[0] = ImageIO.read(Game.class.getResource("man/javaman_c1.gif")); 131 javaman_c[1] = ImageIO.read(Game.class.getResource("man/javaman_c2.gif")); 132 javaman_c[2] = ImageIO.read(Game.class.getResource("man/javaman_c3.gif")); 133 134 javaman_l[0] = ImageIO.read(Game.class.getResource("man/javaman_l1.gif")); 135 javaman_l[1] = ImageIO.read(Game.class.getResource("man/javaman_l2.gif")); 136 javaman_l[2] = ImageIO.read(Game.class.getResource("man/javaman_l3.gif")); 137 138 javaman_ld[0] = ImageIO.read(Game.class.getResource("man/javaman_ld1.gif")); 139 javaman_ld[1] = ImageIO.read(Game.class.getResource("man/javaman_ld2.gif")); 140 javaman_ld[2] = ImageIO.read(Game.class.getResource("man/javaman_ld3.gif")); 141 142 javaman_r[0] = ImageIO.read(Game.class.getResource("man/javaman_r1.gif")); 143 javaman_r[1] = ImageIO.read(Game.class.getResource("man/javaman_r2.gif")); 144 javaman_r[2] = ImageIO.read(Game.class.getResource("man/javaman_r3.gif")); 145 146 javaman_rd[0] = ImageIO.read(Game.class.getResource("man/javaman_rd1.gif")); 147 javaman_rd[1] = ImageIO.read(Game.class.getResource("man/javaman_rd2.gif")); 148 javaman_rd[2] = ImageIO.read(Game.class.getResource("man/javaman_rd3.gif")); 149 150 javaman_s = ImageIO.read(Game.class.getResource("man/javaman_s.gif")); 151 152 } catch (IOException e) { 153 e.printStackTrace(); 154 } 155 } 156 /** 157 * 游戏初始化 158 */ 159 public void init(){ 160 boards.clear();//清空所有台阶 161 apples.clear(); 162 monsters.clear(); 163 rockets.clear(); 164 enterFlag = isDieFlag = scoreFlag =0; 165 man = null;//重置小人 166 score = 0;//重置分数 167 level = 0; 168 state = START; 169 for(int i=0;i<5;i++){//随机产生5个台阶 170 boards.add(BoardNormal.randomOne((i+1)*100)); 171 } 172 Board b = boards.get(rnd.nextInt(5));//随便从这5个台阶中挑出一个 173 /* 174 * 创建一个小人,坐标为上边随机选取台阶的正上方 175 */ 176 man = new Javaman(b.getX()+b.getWidth()/2-javaman_s.getWidth()/2,b.getY()-javaman_s.getHeight()); 177 } 178 179 int enterFlag = 0;//控制台阶入场的频率 180 /** 181 * 台阶入场 182 */ 183 public void enterAction(){ 184 enterFlag++; 185 if(enterFlag%100==0){ 186 int index = rnd.nextInt(6); 187 /* 188 * 随机创建6个台阶中的一个 189 */ 190 switch(index){ 191 case 0 : 192 boards.add(new BoardFlip()); 193 break; 194 case 1: 195 boards.add(new BoardMoveL()); 196 break; 197 case 2: 198 boards.add(new BoardMoveR()); 199 break; 200 case 3: 201 boards.add(new BoardNail()); 202 break; 203 case 4: 204 boards.add(new BoardNormal()); 205 break; 206 case 5: 207 boards.add(new BoardOnce()); 208 break; 209 } 210 } 211 if(enterFlag%(3000+level*500)==0){//每半分钟出一个苹果奖励 212 apples.add(new Apple());//往数组里加一个新的苹果 213 } 214 215 if(enterFlag%(1000-level*100)==0){ 216 Board b = boards.get(rnd.nextInt(boards.size())); 217 int x = b.getX()+b.getWidth()/2-15; 218 int y = b.getY()-30; 219 int ox1 = b.getX(); 220 int ox2 = b.getX()+b.getWidth(); 221 monsters.add(new Monster(x,y,ox1,ox2)); 222 } 223 224 if(enterFlag%(1500-level*100)==0){ 225 rockets.add(new Rocket(man.getX())); 226 } 227 } 228 /** 229 * 判断小人是不是站在台阶上 230 */ 231 public void isManOnFloor(){ 232 man.setManOnFloor(false);//默认为小人不在台阶上 233 man.moveSpeed = 0;//将小人的横向速度重置为0 234 for(Iterator<Board> it = boards.iterator();it.hasNext();){//遍历集合 235 Board b = it.next();//取出集合元素 236 int manx = man.getX(); 237 int many = man.getY()+man.getHeight(); 238 int bx = b.getX(); 239 int by = b.getY(); 240 /* 241 * 判断小人坐标和当前取出的台阶坐标是否重合,重合则把小人改成”站在台阶上“ 242 */ 243 if(manx>bx-man.getWidth() && manx<bx+b.getWidth() && many>by && many<by+b.getHeight()){ 244 man.setManOnFloor(true); 245 if(b instanceof Function){//如果这个方块是功能性台阶 246 Function f = (Function)b;//强转为功能台阶 247 f.function(man);//对小人执行台阶功能 248 } 249 } 250 } 251 } 252 /** 253 * 更新画面(小人,台阶动起来) 254 */ 255 public void update(){ 256 if(man.isManOnFloor()){//如果小人在台阶上 257 man.setySpeed(-1);//小人跟着台阶一起向上 258 }else{//不在台阶上 259 man.setySpeed(2);//小人往下掉 260 } 261 for(Board b:boards){//遍历所有台阶 262 if(b instanceof MoveObject){//如果台阶是会动的(除了顶部刺的所有台阶,顶部刺为了节省代码,继承了台阶类(board)) 263 MoveObject o = (MoveObject)b;//强转一下咯 264 o.move();//给我动! 265 } 266 if(b instanceof Function){//如果这个方块正好是功能性方块(它有一些附带的动画) 267 Function f = (Function)b;//再转! 268 if(!f.isFlag()){//如果这个方块的功能被调用过 269 f.flash();//动画! 270 } 271 } 272 } 273 for(Apple a:apples){ 274 a.move(); 275 } 276 for(Monster m:monsters){ 277 m.move(); 278 } 279 for(Rocket r:rockets){ 280 r.move(); 281 } 282 man.drop();//小人纵向移动(实际速度根据上面设置的纵向速度) 283 man.move();//小人横向移动(实际速度根据键盘监听和传送带提供的横向速度) 284 } 285 /** 286 * 删除出界台阶 287 */ 288 public void outOfBoundsAction(){ 289 for(Iterator<Board> it = boards.iterator();it.hasNext();){//遍历!! 290 Board b = it.next();//取! 291 int by = b.getY(); 292 int ty = boardtop.getY(); 293 /* 294 * 如果台阶高度到了顶部刺的高度 295 */ 296 if(by<ty){ 297 it.remove();//出去了还不给我滚出集合! 298 } 299 } 300 for(Iterator<Monster> it = monsters.iterator();it.hasNext();){ 301 Monster m = it.next(); 302 int my = m.getY(); 303 int ty = boardtop.getY(); 304 if(my<ty){ 305 it.remove(); 306 } 307 } 308 for(Iterator<Rocket> it = rockets.iterator();it.hasNext();){ 309 Rocket r = it.next(); 310 int ry = r.getY(); 311 int ty = boardtop.getY(); 312 if(ry<ty){ 313 it.remove(); 314 } 315 } 316 } 317 int isDieFlag = 0;//控制下小人被顶部刺刺中时血量下降速度,总不能一秒降到-40吧? 318 /** 319 * 对小人血量的操作 320 */ 321 public void isDie(){ 322 int my = man.getY();//小人的纵坐标,横坐标又不会让小人死(呵呵) 323 if(my>HEIGHT){//如果掉下去了,当然是指掉到头了! 324 man.die();//死吧死吧! 325 }else if(my<=boardtop.getY()+boardtop.getHeight()){//如果碰到刺了 326 if(isDieFlag%50==0){//控制下血量下降频率,50*10ms降低一次 327 man.subLife();//小人生命减一。 328 } 329 isDieFlag++;//这个不懂???好吧直接问我 330 }else{ 331 isDieFlag = 0;//如果小人不在上面的地方,那么重置下,不然下次撞到刺可能就又要等500ms才掉血。 332 } 333 for(Iterator<Monster> it = monsters.iterator();it.hasNext();){ 334 Monster a = it.next(); 335 int ax1 = a.getX(); 336 int ax2 = a.getX()+a.getWidth(); 337 int ay1 = a.getY(); 338 int ay2 = a.getY()+a.getHeight(); 339 int mx1 = man.getX(); 340 int mx2 = man.getX()+man.getWidth(); 341 int my1 = man.getY(); 342 int my2 = man.getY()+man.getHeight(); 343 if(((mx1>=ax1 && mx1<=ax2)||(mx2>=ax1 && mx2<=ax2)) 344 &&((my1>=ay1 && my1<=ay2)||(my2>=ay1 && my2<=ay2)) 345 ){ 346 man.subLife(); 347 it.remove(); 348 } 349 } 350 for(Iterator<Rocket> it = rockets.iterator();it.hasNext();){ 351 Rocket r = it.next(); 352 int rx1 = r.getX(); 353 int rx2 = r.getX()+r.getWidth(); 354 int ry1 = r.getY(); 355 int ry2 = r.getY()+r.getHeight(); 356 int mx1 = man.getX(); 357 int mx2 = man.getX()+man.getWidth(); 358 int my1 = man.getY(); 359 int my2 = man.getY()+man.getHeight(); 360 if(((mx1>=rx1 && mx1<=rx2)||(mx2>=rx1 && mx2<=rx2)) 361 &&((my1>=ry1 && my1<=ry2)||(my2>=ry1 && my2<=ry2)) 362 ){ 363 man.subLife(); 364 it.remove(); 365 } 366 } 367 } 368 /** 369 * 判断游戏结束了没 370 */ 371 public void gameover(){ 372 if(man.getLife()<=0){//如果生命值为0了 373 state=GAME_OVER; 374 } 375 } 376 int scoreFlag = 0;//用于计时 377 /** 378 * 得分,2秒加一层 379 */ 380 public void getScore(){ 381 scoreFlag++; 382 if(scoreFlag%200==0){//200*10ms加一层 383 score++; 384 if(score%20==0 && level<9){ 385 level++; 386 } 387 } 388 } 389 390 public void getLife(){ 391 boolean getlife = false; 392 for(Iterator<Apple> it = apples.iterator();it.hasNext();){ 393 Apple a = it.next(); 394 /* 395 * 苹果和小人的四个界点坐标 396 */ 397 int ax1 = a.getX(); 398 int ax2 = a.getX()+a.getWidth(); 399 int ay1 = a.getY(); 400 int ay2 = a.getY()+a.getHeight(); 401 int mx1 = man.getX(); 402 int mx2 = man.getX()+man.getWidth(); 403 int my1 = man.getY(); 404 int my2 = man.getY()+man.getHeight(); 405 if(((mx1>=ax1 && mx1<=ax2)||(mx2>=ax1 && mx2<=ax2)) 406 &&((my1>=ay1 && my1<=ay2)||(my2>=ay1 && my2<=ay2))){ 407 getlife = true; 408 it.remove(); 409 } 410 } 411 412 if(getlife){ 413 man.addLife(); 414 } 415 416 } 417 418 public void action(){ 419 this.addKeyListener(new KeyAdapter(){//键盘监听 420 /** 421 * 键盘被按下时给小人速度 422 */ 423 @Override 424 public void keyPressed(KeyEvent e) { 425 int key = e.getKeyCode();//获取按下的键是个啥 426 switch(key){ 427 case KeyEvent.VK_LEFT://按的是方向左: 428 man.setxSpeed(-2);//给个往左移的速度 429 break; 430 case KeyEvent.VK_RIGHT://按的是方向右: 431 man.setxSpeed(2);//给个往右移的速度啊! 432 break; 433 case KeyEvent.VK_SPACE://按的是空格: 434 if(state==RUNNING){ 435 state=PAUSE; 436 }else if(state==PAUSE){ 437 state=RUNNING; 438 }else if(state==START){ 439 state=RUNNING; 440 }else if(state==GAME_OVER){ 441 init();//游戏初始化,所有台阶和小人重新生成 442 state=START; 443 } 444 break; 445 } 446 } 447 448 /** 449 * 键盘松开时小人你就憋动啦! 450 */ 451 @Override 452 public void keyReleased(KeyEvent e) { 453 man.setxSpeed(0);//小人横向速度重置为0 454 } 455 456 }); 457 /* 458 * 这两句坑了我半天,先开始没加键盘怎么按都没反应 459 * 直到加了这两句,也是从俄罗斯方块代码里看的。意思不是很了解,也懒得了解了 460 */ 461 this.setFocusable(true); 462 this.requestFocus(); 463 464 timer = new Timer();//把上面声明的那个定时器引用指个对象给他,不然会报空指针哦~ 465 timer.schedule(new TimerTask(){ 466 /** 467 * 重写run 468 */ 469 @Override 470 public void run() { 471 /* 472 * 想知道下面是干啥的你鼠标移上去呗 473 */ 474 if(state==RUNNING){ 475 enterAction(); 476 isManOnFloor(); 477 update(); 478 outOfBoundsAction(); 479 getLife(); 480 getScore(); 481 isDie(); 482 gameover(); 483 } 484 repaint();//重画下,不然你玩张静态图片啊? 485 } 486 487 }, 0, intervel);//intervel没忘吧,上面有写,计时器时间间隔,10ms一次哦 488 } 489 /** 490 * 主方法,程序的入口 491 * @param args 492 */ 493 public static void main(String[] args) { 494 JFrame frame = new JFrame("Downwell");//新建一个窗体,标题为Downwell <-啥意思?百度去! 495 Game game = new Game();//新建一个游戏 496 game.init();//第一次运行你不得初始化啊! 497 frame.add(game);//把游戏添加到窗体里去(游戏这个类是继承了JPanel了才可以添加的,别乱加别的对象哦) 498 frame.setSize(WIDTH, HEIGHT);//设置窗体宽高 499 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//设置默认关闭操作(关闭窗体则程序结束) 500 frame.setResizable(false);//设置窗体大小不能被改变(不懂就注释了这句然后运行下,用鼠标拖下窗体四角) 501 frame.setLocationRelativeTo(null);//窗体居中显示 502 frame.setVisible(true);//设置窗体可见,并提醒程序快点调用paint()方法 503 game.action();//游戏开始! 504 } 505 /** 506 * 重写paint方法 507 */ 508 public void paint(Graphics g){ 509 paintStatic(g);//画些静止不动的背景 510 paintBoard(g);//画台阶 511 paintMonster(g);//画怪物 512 paintRocket(g);//画火箭 513 paintApple(g);//画苹果 514 paintJavaman(g);//画小人 515 paintLife(g);//画小人的生命 516 paintScore(g);//画分数 517 paintState(g);//画状态 518 } 519 /* 520 * 介绍下drawImage()六个参数的重载,最后一个直接写null,只介绍前五个 521 * 第一个:要画的图片 522 * 第二,三个:画的图片从哪个坐标开始画 523 * 第四,五个:控制图片大小,按给定的宽高缩放后画出来 524 */ 525 526 527 public void paintRocket(Graphics g){ 528 for(Rocket r:rockets){ 529 g.drawImage(r.getImage(),r.getX(),r.getY(),r.getWidth(),r.getHeight(),null); 530 } 531 } 532 533 public void paintMonster(Graphics g){ 534 for(Monster m:monsters){ 535 g.drawImage(m.getImage(),m.getX(),m.getY(),m.getWidth(),m.getHeight(),null); 536 } 537 } 538 539 public void paintState(Graphics g){ 540 if(state==PAUSE){ 541 g.drawImage(pause,0,0,WIDTH,HEIGHT,null); 542 } 543 if(state==START){ 544 g.drawImage(start,0,0,WIDTH,HEIGHT,null); 545 } 546 if(state==GAME_OVER){ 547 int x = 350; 548 int temp = score; 549 g.drawImage(gameover, 0, 0, WIDTH,HEIGHT,null); 550 do{ 551 int n = temp%10; 552 g.drawImage(num[n],x,500,100,100,null); 553 temp /= 10; 554 x -= 120; 555 }while(temp>0); 556 } 557 } 558 559 public void paintApple(Graphics g){ 560 for(Apple a:apples){ 561 g.drawImage(a.getImage(),a.getX(),a.getY(),a.getWidth(),a.getHeight(),null); 562 } 563 } 564 565 public void paintScore(Graphics g){ 566 Font font = new Font(Font.SANS_SERIF,Font.BOLD,25);//设置字体,我不想查字体的参数了,直接照搬飞机大战 567 g.setColor(new Color(0xffffff));//白色的 568 g.setFont(font);//把画笔字体设置为上面创建的字体 569 g.drawString("SCORE:"+score, WIDTH-150, 25);//这个坐标是慢慢试出来的,想改就改。 570 } 571 572 public void paintLife(Graphics g){ 573 Font font = new Font(Font.SANS_SERIF,Font.BOLD,25);//设置字体,我不想查字体的参数了,直接照搬飞机大战 574 g.setColor(new Color(0xffffff));//白色的 575 g.setFont(font);//把画笔字体设置为上面创建的字体 576 g.drawString("LIFE:"+man.getLife(), 10, 25);//这个坐标是慢慢试出来的,想改就改。 577 } 578 /** 579 * 画台阶 580 * @param g 画笔,我只写一次,不需要太纠结画笔是什么 581 */ 582 public void paintBoard(Graphics g){ 583 for(Board b:boards){//增强for遍历集合 584 g.drawImage(b.getImage(), b.getX(), b.getY(), null);//画! 585 } 586 } 587 /** 588 * 画小人 589 * @param g 590 */ 591 public void paintJavaman(Graphics g){ 592 g.drawImage(man.getImage(), man.getX(), man.getY(), null);//画!! 593 } 594 /** 595 * 画背景 596 * @param g 597 */ 598 public void paintStatic(Graphics g){ 599 g.drawImage(background, 0, 0, WIDTH, HEIGHT, null);//画背景!!! 600 g.drawImage(boardtop.image, boardtop.x, boardtop.y, boardtop.width, boardtop.height, null);//画顶部那个刺!!!! 601 } 602 } 复制代码 复制代码 1 package com.tarena.downwell; 2 /** 3 * 可动台阶(除了顶部刺都算) 4 * @author Misaki 5 * 6 */ 7 public interface MoveObject { 8 final int ySpeed = 1;//每次往上移动一个像素 9 void move();//移动! 10 } 复制代码 复制代码 1 package com.tarena.downwell; 2 3 import java.awt.image.BufferedImage; 4 import java.util.Random; 5 6 public class Monster implements MoveObject{ 7 private int x; 8 private int y; 9 private int ox1;//移动时的左界限 10 private int ox2;//移动时的右界限 11 private BufferedImage image; 12 private int width; 13 private int height; 14 private int xSpeed; 15 16 public Monster(int x,int y,int ox1,int ox2){ 17 this.x = x; 18 this.y = y; 19 this.ox1 = ox1; 20 this.ox2 = ox2; 21 this.image = Game.monster; 22 this.width = 30; 23 this.height = 30; 24 this.xSpeed = -1 + new Random().nextInt(2)*2;//横向速度为-1或1 25 } 26 27 @Override 28 public void move() { 29 if(x<=ox1){ 30 xSpeed = 1; 31 } 32 if(x+width>=ox2){ 33 xSpeed = -1; 34 } 35 this.x += xSpeed; 36 this.y += ySpeed; 37 } 38 39 public int getX() { 40 return x; 41 } 42 43 public void setX(int x) { 44 this.x = x; 45 } 46 47 public int getY() { 48 return y; 49 } 50 51 public void setY(int y) { 52 this.y = y; 53 } 54 55 public int getOx1() { 56 return ox1; 57 } 58 59 public void setOx1(int ox1) { 60 this.ox1 = ox1; 61 } 62 63 public int getOx2() { 64 return ox2; 65 } 66 67 public void setOx2(int ox2) { 68 this.ox2 = ox2; 69 } 70 71 public BufferedImage getImage() { 72 return image; 73 } 74 75 public void setImage(BufferedImage image) { 76 this.image = image; 77 } 78 79 public int getxSpeed() { 80 return xSpeed; 81 } 82 83 public void setxSpeed(int xSpeed) { 84 this.xSpeed = xSpeed; 85 } 86 87 public int getWidth() { 88 return width; 89 } 90 91 public int getHeight() { 92 return height; 93 } 94 95 } 复制代码 复制代码 1 package com.tarena.downwell; 2 3 import java.awt.image.BufferedImage; 4 import java.util.Random; 5 6 public class Rocket { 7 private int x; 8 private int y; 9 private BufferedImage image; 10 private int width; 11 private int height; 12 private int ySpeed; 13 14 public Rocket(){ 15 Random rnd = new Random(); 16 this.x = rnd.nextInt(Game.WIDTH-this.width-25)+10; 17 this.y = Game.HEIGHT; 18 this.width = 50; 19 this.height = 90; 20 this.image = Game.rocket; 21 this.ySpeed = -5; 22 } 23 public Rocket(int x){ 24 this(); 25 this.x = x; 26 } 27 28 public void move(){ 29 this.y += ySpeed; 30 } 31 32 public int getX() { 33 return x; 34 } 35 36 public void setX(int x) { 37 this.x = x; 38 } 39 40 public int getY() { 41 return y; 42 } 43 44 public void setY(int y) { 45 this.y = y; 46 } 47 48 public BufferedImage getImage() { 49 return image; 50 } 51 52 public void setImage(BufferedImage image) { 53 this.image = image; 54 } 55 56 public int getWidth() { 57 return width; 58 } 59 60 public void setWidth(int width) { 61 this.width = width; 62 } 63 64 public int getHeight() { 65 return height; 66 } 67 68 public void setHeight(int height) { 69 this.height = height; 70 } 71 72 public int getySpeed() { 73 return ySpeed; 74 } 75 76 public void setySpeed(int ySpeed) { 77 this.ySpeed = ySpeed; 78 } 79 80 } 复制代码 复制代码 1 package com.tarena.downwell; 2 3 import java.awt.image.BufferedImage; 4 import java.util.Random; 5 6 public class Apple { 7 private int x; 8 private int y; 9 private BufferedImage image; 10 private int width; 11 private int height; 12 private int xSpeed; 13 private int ySpeed; 14 15 public Apple(){ 16 Random rnd = new Random(); 17 this.x = rnd.nextInt(Game.WIDTH-this.width-20)+10; 18 this.y = rnd.nextInt(Game.HEIGHT-65)+65; 19 this.width = 30; 20 this.height = 30; 21 this.image = Game.apple; 22 switch(rnd.nextInt(2)){ 23 case 0: 24 xSpeed = -2;break; 25 case 1: 26 xSpeed = 2;break; 27 } 28 switch(rnd.nextInt(2)){ 29 case 0: 30 ySpeed = -2;break; 31 case 1: 32 ySpeed = 2;break; 33 } 34 } 35 36 public void move(){ 37 if(this.x<=10){ 38 this.xSpeed = 2; 39 } 40 if(this.x>=Game.WIDTH-20){ 41 this.xSpeed = -2; 42 } 43 if(this.y<=65){ 44 this.ySpeed = 2; 45 } 46 if(this.y>=Game.HEIGHT-this.height){ 47 this.ySpeed = -2; 48 } 49 this.x += xSpeed; 50 this.y += ySpeed; 51 } 52 53 public int getX() { 54 return x; 55 } 56 public void setX(int x) { 57 this.x = x; 58 } 59 public int getY() { 60 return y; 61 } 62 public void setY(int y) { 63 this.y = y; 64 } 65 public BufferedImage getImage() { 66 return image; 67 } 68 public void setImage(BufferedImage image) { 69 this.image = image; 70 } 71 public int getxSpeed() { 72 return xSpeed; 73 } 74 public void setxSpeed(int xSpeed) { 75 this.xSpeed = xSpeed; 76 } 77 public int getySpeed() { 78 return ySpeed; 79 } 80 public void setySpeed(int ySpeed) { 81 this.ySpeed = ySpeed; 82 } 83 public int getWidth() { 84 return width; 85 } 86 public int getHeight() { 87 return height; 88 } 89 90 } 复制代码
相关推荐
在"Python是男人就下一百层小游戏源代码"这个项目中,我们有两个核心的程序文件:`game.py`和`是男人就下一百层.py`。这两个文件共同构成了游戏的全部逻辑。 首先,`game.py`通常会包含游戏的基本框架和一些通用的...
游戏源码分享下载 --- 100c.zipHTML5小游戏【是男人就下100层--100c优秀H5小游戏合集】游戏源码分享下载 --- 100c.zipHTML5小游戏【是男人就下100层--100c优秀H5小游戏合集】游戏源码分享下载 --- 100c.zipHTML5小...
《Cocos2d 3.0小游戏:男人就下100层》 本文将深入探讨基于Cocos2d 3.0引擎开发的一款小游戏——“男人就下100层”。Cocos2d是一款广泛使用的2D游戏开发框架,其3.0版本在性能优化和易用性上都有显著提升,为开发者...
本小游戏素材来自于原版“是男人就下一百层”小游戏,仅供学习与研究用途。适合.NET入门者练习的一个实例,本小游戏中涉及到抽象类,抽象方法,方法重载,类的继承,事件,委托,GDI+画图的综合应用。 [开发环境] ...
《C#编程:“是男人就下100层”游戏实现详解》 “是男人就下100层”是一款经典的游戏,它挑战玩家的反应速度和决策能力。在编程领域,利用C#来实现这样的游戏,不仅可以锻炼编程技能,也能提供一种有趣的交互式体验...
本项目“是男人就下100层”是一款基于Cocos2d-x的小游戏,其核心挑战是让玩家操控角色深入100层地下迷宫,考验玩家的操作技巧和策略。 1. **游戏结构**: 游戏通常由场景(Scene)、层(Layer)、精灵(Sprite)等...
经典小游戏“是男人就下100层”的C#源代码, 实现了原作的绝大部分功能,并额外添加了两种障碍物, 是本人学习XNA的练习作品,供初学者参考。 由VS2010开发,使用了.net framework 4.0及XNA 4.0。
《是男人就下100层》是一款经典的H5小游戏,源码的分享为我们提供了一个深入理解HTML5游戏开发的宝贵资源。H5小游戏源码是基于HTML5、CSS3和JavaScript技术构建的,这些技术是现代网页和游戏开发的核心组成部分。在...
《是男人就下1000层》是一款经典的JAVA(J2ME)平台游戏,它以其独特的挑战性和趣味性吸引了大量的玩家。此游戏的源码是开发者们学习和研究JAVA移动游戏开发的重要参考资料。下面我们将深入探讨这款游戏中涉及到的...
《J2ME_是男人就下100层》是一款基于Java 2 Micro Edition (J2ME) 平台开发的轻量级小游戏。J2ME 是Java技术的一个分支,主要用于移动设备、嵌入式系统和其他有限资源的计算平台。这个游戏以简单的挑战为特色,玩家...
《是男人就下100层》是一款基于JavaWeb技术和HTML5开发的在线小游戏,它融合了两者的优势,为玩家提供了丰富的交互体验和流畅的游戏运行。在这个游戏中,玩家需要操控角色不断向下探索,挑战自己的反应速度和策略...
是男人就下100层-小游戏,部署于NAS的WebStation等服务器上,分配端口即可使用,Index文件内已去除广告
《是男人就下100层》是一款经典的Flash小游戏,深受玩家喜爱。源码的公开为编程爱好者提供了学习和研究的宝贵资源。本压缩包文件包含的是这款游戏的完整源代码,对于想要了解游戏开发,尤其是Flash游戏开发的初学者...
本项目"是男人就下100层"是一款基于Cocos2d-x框架的Android小游戏,其中涉及到JNI的使用,主要是为了实现高性能的计算或者利用C++库来增强游戏性能。 1. **Cocos2d-x框架**:Cocos2d-x是一个开源的、跨平台的游戏...
《是男人就坚持100秒》是一款使用C#编程语言开发的小型游戏,它以其简单易上手的玩法和挑战性吸引了众多玩家。在这款游戏中,玩家需要操控角色完成特定任务,目标是在限定的100秒内尽可能地得分或者达到一定的目标。...
本资源提供的是一个基于HTML5技术开发的微信朋友圈小游戏源码,名为“是男人就下100层”。游戏的核心玩法挑战玩家的反应速度和策略规划,通过控制角色在楼层间跳跃,避开障碍,尽可能深入地下100层。这个游戏源码...
基于html开发的小游戏,无需配置环境,点击即可运行 基于html开发的小游戏,无需配置环境,点击即可运行 基于html开发的小游戏,无需配置环境,点击即可运行 基于html开发的小游戏,无需配置环境,点击即可运行 基于...
是男人就下100层游戏源码,经典的flash游戏《是男人就下100层》登录win8平台了,支持surface 以及 surface pro, 操作方式支持键盘左右键和触摸操作,该游戏现在android版,ios版已经上线了,但是wp版现在才开发的,...
"是男人就下100层"游戏的核心在于玩家需要操控角色不断向下移动,避开障碍物,尽可能达到更深的层次。这就涉及到游戏状态管理,如游戏开始、暂停、结束,以及分数系统、障碍物生成和运动规律等。开发者可能使用了...
写的一个小游戏程序,由于没有美工合作,所以游戏画面完全是通过程序运算绘制的,不过也还人性化啦,希望朋友们能喜欢 本程序共分3个类 主类 角色类 和挡板类 源程序里已经包含相关说明 不过,实现的代码部分,我...