Java俄罗斯方块实现步骤

Java俄罗斯方块实现步骤

ID:36538955

大小:276.41 KB

页数:25页

时间:2019-05-09

Java俄罗斯方块实现步骤_第1页
Java俄罗斯方块实现步骤_第2页
Java俄罗斯方块实现步骤_第3页
Java俄罗斯方块实现步骤_第4页
Java俄罗斯方块实现步骤_第5页
资源描述:

《Java俄罗斯方块实现步骤》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、项目实战  --俄罗斯方块主讲:贾宗维程序演示游戏01_功能演示与说明游戏02_面向对象设计游戏03_使用API类组装游戏游戏04_编写各个类主体框架游戏05_编写Controler类实现事件监听游戏06_编写类测试代码游戏07_图形设计与创建游戏08_图形移动与显示游戏09_处理游戏边界问题游戏10_障碍物生成与显示游戏11_消除满行的障碍物游戏12_增加游戏结束游戏13_定时下落编写各个类主体框架-Shape类publicclassShape{//privateShapeListenerlistener;publicvoidmoveLeft(){System.out.prin

2、tln("shape'smoveLeft");}publicvoidmoveRight(){System.out.println("shape'smoveright");}publicvoidmoveDown(){System.out.println("shape'smoveDown");}publicvoidrotate(){System.out.println("shape'srotate");}publicvoiddrawMe(){System.out.println("shape'sdrawme");}privateclassShapeDriverimplementsRu

3、nnable{publicvoidrun(){//TODOAuto-generatedmethodstubwhile(true){moveDown();//listener.shapeMoveDown(Shape.this);try{Thread.sleep(1000);}catch(InterruptedExceptione){//TODOAuto-generatedcatchblocke.printStackTrace();编写各个类主体框架-ShapeFactory类publicclassShapeFactory{publicShapegetShape(ShapeListe

4、nerlistener){System.out.println("ShapeFactory'sgetShape");Shapeshape=newShape();returnshape;}}编写各个类主体框架-Ground类packagecn.tetris.entities;publicclassGround{publicvoidaccept(){System.out.println("Ground'saccept");}publicvoiddrawMe(){System.out.println("Ground'sdrawMe");}}编写各个类主体框架-GamePanel类pub

5、licclassGamePanelextendsJPanel{privateGroundground;privateShapeshape;publicvoiddisplay(Groundground,Shapeshape){System.out.println("GamePanel'sdisplay");this.ground=ground;this.shape=shape;this.repaint();}@OverrideprotectedvoidpaintComponent(Graphicsarg0){//TODOAuto-generatedmethodstub//重新显示i

6、f(ground!=null&&shape!=null){ground.drawMe();shape.drawMe();}}编写各个类主体框架-Controller类publicclassControllerextendsKeyAdapter{privateGroundground;privateShapeshape;privateShapeFactoryshapeFactory;privateGamePanelgamePanel;publicvoidkeyPressed(KeyEvente){switch(e.getKeyCode()){caseKeyEvent.VK_UP:s

7、hape.rotate();break;caseKeyEvent.VK_LEFT:shape.moveLeft();break;caseKeyEvent.VK_RIGHT:shape.moveRight();break;caseKeyEvent.VK_DOWN:shape.moveDown();break;}gamePanel.display(ground,shape);}编写各个类主体框架-ShapeListener接口publicinterfaceShapeListener{

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。