- 1、本文档共42页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
java吃豆子游戏设计课程设计
?
java吃豆子游戏设计-课程设计
java吃豆子游戏设计import java.awt.*;
/**?* 定义敌人的类?*/public class Enemy{?private int xPos;?private int yPos;?private int xVPos;?private int yVPos;?private int direction;??//敌人是否失去反抗能力?private boolean alarm;?//敌人失去防抗能力的时间?private int alarmTime;?private boolean ghostMode;?private Rectangle Enemy;?private int speed;?private int interval;?private int Colour;?private int AI_time1, AI_time2;?private int lefttime, uptime, righttime, downtime;?private int gameFlow;?private boolean ghost;?private boolean canMoveUp, canMoveDown, canMoveLeft,canMoveRight;?private boolean cantGoAnyWhere;?private int prisonTime;?private boolean stop;??/**? **根据x、y、颜色、是否已经出牢笼、剩余多长时间才可出牢笼? **构造敌人对象? */?public Enemy(int a, int b, int c, boolean cantGoAnyWhere, int prisonTime){??xPos = a;??yPos = b;??xVPos = xPos;??yVPos = yVPos;??direction = 3;??speed = 3;??interval = 63 + 21*((int)(Math.random()*10));??AI_time1 = 0;??Colour = c;??this.prisonTime = prisonTime;??this.cantGoAnyWhere = cantGoAnyWhere;??Enemy = new Rectangle(xPos -10, yPos - 10, 21, 21);?}
?/**? **方法:敌人的移动? */?public void move(int a, int b, Wall[] wall){??AI_time1++;??AI_time2++;??uptime++;??downtime++;??lefttime++;??righttime++;??gameFlow++;????//如果敌人没有反抗能力??if(alarm)???alarmTime++;??boolean changeMovement = false;
??//如果敌人不能移动,就将囚禁得时间不停增加??if(cantGoAnyWhere)???prisonTime++;
??//当敌人失去反抗能力后,速度降低??if(alarm)???speed = 1;??else???speed = 2;
??//失去反抗能力到指定时间后,恢复原态??if(alarmTime = 330){???alarmTime = 0;???alarm = false;??}
??canMoveUp = true;??canMoveDown = true;??canMoveLeft = true;??canMoveRight = true;
??Rectangle R;??Rectangle UP = new Rectangle(xVPos - 10, yVPos - 10 - speed, 21, 21);???Rectangle DOWN = new Rectangle(xVPos - 10, yVPos - 10 + speed, 21, 21);??Rectangle LEFT = new Rectangle(xVPos - 10 - speed, yVPos - 10, 21, 21);??Rectangle RIGHT = new Rectangle(xVPos - 10 + speed, yVPos - 10, 21, 21);
??for(int i = 0; i wall.length; i++){???R =
文档评论(0)