Giter VIP home page Giter VIP logo

planegame-1's Introduction

PlaneGame

Android 游戏--- 一款飞机小游戏

大二学习的android游戏编程实训作品,通过这个作品加深了对 SurfaceView 的初步认识,以及游戏状态机制认识。

游戏状态机制

  • 分为五部分

      public static final int GAME_MENU = 0;//游戏菜单
      public static final int GAMEING = 1;//游戏中
      public static final int GAME_WIN = 2;//游戏胜利
      public static final int GAME_LOST = 3;//游戏失败
      public static final int GAME_PAUSE = -1;//游戏菜单
    
  • 整个游戏画面都是由MySurfaceView(不断刷新的View)来绘制

      @Override
      	public void run() {  // 这里是MySurfaceview 线程 运行逻辑
      		while (flag) {
      			long start = System.currentTimeMillis();
      			myDraw();  // 根据状态绘制
      			logic();   // 游戏中敌机,主角,子弹逻辑
      			long end = System.currentTimeMillis();
      			try {
      				if (end - start < 50) {
      					Thread.sleep(50 - (end - start));
      				}
      			} catch (InterruptedException e) {
      				e.printStackTrace();
      			}
      		}
      	}
    

部分类说明

Boom.java 是子弹碰到敌机后的爆炸动画
Boss.java 敌人boss机的绘制以及行为逻辑等等
Bullet.java 子弹的绘制以及其移动逻辑
Enemy.java 普通敌机绘制以及逻辑(AI),不同敌机类型有不同逻辑
GameBg.java 背景移动的逻辑,分为云层,以及最底层的背景移动逻辑
GameMenu.java 菜单按钮的逻辑

//更详细就查看源码把,其实比较简单入门

部分截图

菜单

planegame-1's People

Contributors

lowly360 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.