Android_(游戏)打飞机04:绘画敌机、添加子弹
(游戏)打飞机01:前言 传送门
(游戏)打飞机02:游戏背景滚动 传送门
(游戏)打飞机03:控制玩家飞机 传送门
(游戏)打飞机04:绘画敌机、添加子弹 传送门
(游戏)打飞机05:处理子弹,击中敌机,添加计分板 传送门
(游戏)打飞机06:后续 传送门
绘画敌机、添加子弹效果
package com.example.administrator.myapplication; import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.WindowManager; import java.util.ArrayList;
import java.util.List;
import java.util.Random; /**
* Created by Administrator on 2018/8/9.
*/ public class dafeijiGameView extends SurfaceView implements
SurfaceHolder.Callback,Runnable,android.view.View.OnTouchListener{ private Bitmap my;//自己
private Bitmap baozha;//爆炸
private Bitmap bg;//背景
private Bitmap diren;//敌人
private Bitmap zidan;//子弹
private Bitmap erjihuancun;//二级缓存
private WindowManager windowManager;//获得界面长宽高
private int display_w; //界面的宽
private int display_h; //界面的高
private ArrayList<GameImage> gameImage = new ArrayList();
private ArrayList<Zidan> zidans = new ArrayList<Zidan>(); public dafeijiGameView(Context context) {
super(context);
getHolder().addCallback(this);
//事件注册
this.setOnTouchListener(this);
} private void init(){
//加载照片
my= BitmapFactory.decodeResource(getResources(),R.drawable.my);
baozha= BitmapFactory.decodeResource(getResources(),R.drawable.baozha);
bg= BitmapFactory.decodeResource(getResources(),R.drawable.bg);
diren= BitmapFactory.decodeResource(getResources(),R.drawable.diren);
zidan= BitmapFactory.decodeResource(getResources(),R.drawable.zidan); erjihuancun=Bitmap.createBitmap(display_w,display_h, Bitmap.Config.ARGB_8888);
gameImage.add(new BeijingImage(bg)); //先加入背景照片
gameImage.add(new FeijiImage(my));
gameImage.add(new DijiImage(diren)); } FeijiImage selectfeiji;
@Override
public boolean onTouch(View v, MotionEvent event) {
//手接近屏幕产生的事件
if(event.getAction()==MotionEvent.ACTION_DOWN){
for(GameImage game: gameImage){
if(game instanceof FeijiImage){ FeijiImage feiji = (FeijiImage)game; //判断条件为真时选中飞机
if(feiji.getX()<event.getX()&&
feiji.getY()<event.getY()&&
feiji.getX()+feiji.getWidth()>event.getX() &&
feiji.getY()+feiji.getHeigth()>event.getY()){
selectfeiji=feiji; }else{
selectfeiji=null;
}
break;
}
}
}else if(event.getAction()==MotionEvent.ACTION_MOVE){
//移动鼠标
if( selectfeiji!=null){
selectfeiji.setX((int)event.getX()-selectfeiji.getWidth()/2);
selectfeiji.setY((int)event.getY()-selectfeiji.getHeigth()/2);
} }else if(event.getAction()==MotionEvent.ACTION_UP){
//松开鼠标
selectfeiji=null;
} return true;
} private interface GameImage{
public Bitmap getBitmap();
public int getX();
public int getY();
} private class Zidan implements GameImage{ Bitmap zidan;
private FeijiImage feiji;
private int x;
private int y; public Zidan(FeijiImage feiji,Bitmap zidan){
this.feiji=feiji;
this.zidan=zidan; x=(feiji.getX()+feiji.getWidth()/2)-25;//居中位置
y=feiji.getY()-zidan.getHeight();
} public Bitmap getBitmap() {
y-=19;
if(y<=-10){
zidans.remove(this);
}
return zidan;
} @Override
public int getX() {
return x;
} @Override
public int getY() {
return y;
}
} private class DijiImage implements GameImage{ private Bitmap diren = null; private List<Bitmap> bitmaps = new ArrayList<Bitmap>();
private int x;
private int y; public DijiImage(Bitmap diren){
this.diren=diren;
bitmaps.add(Bitmap.createBitmap(diren,0,0,diren.getWidth()/4,diren.getHeight()));
bitmaps.add(Bitmap.createBitmap(diren,(diren.getWidth()/4)*1,0,diren.getWidth()/4,diren.getHeight()));
bitmaps.add(Bitmap.createBitmap(diren,(diren.getWidth()/4)*2,0,diren.getWidth()/4,diren.getHeight()));
bitmaps.add(Bitmap.createBitmap(diren,(diren.getWidth()/4)*3,0,diren.getWidth()/4,diren.getHeight())); y=-diren.getHeight();
Random ran = new Random();
x=ran.nextInt(display_w-(diren.getWidth()/4)); } private int index=0;
private int num =0;
@Override
public Bitmap getBitmap() {
Bitmap bitmap = bitmaps.get(index);
//控制切换四个飞机的频率
if(num == 7){
index++;
if(index == bitmaps.size()){
index=0;
}
num=0;
}
y+=3;
num++; if(y>display_h){
gameImage.remove(this);
} return bitmap;
} @Override
public int getX() {
return x;
} @Override
public int getY() {
return y;
}
} private class FeijiImage implements GameImage{ private Bitmap my;
private int x;
private int y;
private int width;
private int heigth; private int getWidth(){
return width;
} private int getHeigth(){
return heigth;
} private List<Bitmap> bitmaps = new ArrayList<Bitmap>(); private FeijiImage(Bitmap my){
this.my=my;
bitmaps.add(Bitmap.createBitmap(my,0,0,my.getWidth()/4,my.getHeight()));
bitmaps.add(Bitmap.createBitmap(my,(my.getWidth()/4),0,my.getWidth()/4,my.getHeight()));
bitmaps.add(Bitmap.createBitmap(my,(my.getWidth()/4)*2,0,my.getWidth()/4,my.getHeight()));
bitmaps.add(Bitmap.createBitmap(my,(my.getWidth()/4)*3,0,my.getWidth()/4,my.getHeight()));
//得到战机的高和宽
width=my.getWidth()/4;
heigth=my.getHeight();
x=(display_w - my.getWidth()/4)/2;
y=display_h-my.getHeight()-30;
} private int index=0;
private int num =0;
@Override
public Bitmap getBitmap() {
Bitmap bitmap = bitmaps.get(index);
//控制切换四个飞机的频率
if(num == 7){
index++;
if(index == bitmaps.size()){
index=0;
}
num=0;
}
num++;
return bitmap;
} @Override
public int getX() {
return x;
} @Override
public int getY() {
return y;
} public void setY(int y){
this.y=y;
} public void setX(int x){
this.x=x;
} } //负责背景照片的处理
private class BeijingImage implements GameImage{
private Bitmap bg;
private BeijingImage(Bitmap bg){
this.bg=bg;
newBitmap = Bitmap.createBitmap(display_w,display_h, Bitmap.Config.ARGB_8888);
} private Bitmap newBitmap = null;
private int height = 0; public Bitmap getBitmap(){
Paint p = new Paint();
Canvas canvas = new Canvas(newBitmap);
canvas.drawBitmap(bg,
new Rect(0,0,bg.getWidth(),bg.getHeight()),
new Rect(0,height,display_w,display_h+height),p); canvas.drawBitmap(bg,
new Rect(0,0,bg.getWidth(),bg.getHeight()),
new Rect(0,-display_h+height,display_w,height),p); height++;
if(height==display_h){
height=0;
}
return newBitmap;
} public int getX(){
return 0;
} public int getY(){
return 0;
}
} private boolean state = false;
private SurfaceHolder holder; //绘画中心
public void run() {
Paint p1 = new Paint();
int diren_num=0;//
int zidan_num=0;
try{
while(state){
if(selectfeiji!=null){
if(zidan_num==10){
zidans.add(new Zidan(selectfeiji,zidan));
zidan_num=0;
}
zidan_num++;
} Canvas newCanvas = new Canvas(erjihuancun);
for(GameImage image:(List<GameImage>)gameImage.clone()){
newCanvas.drawBitmap(image.getBitmap(),image.getX(),image.getY(),p1);
} for(GameImage image:(List<GameImage>)zidans.clone()){
newCanvas.drawBitmap(image.getBitmap(),image.getX(),image.getY(),p1);
} if(diren_num==150){
diren_num=0;
gameImage.add(new DijiImage(diren));
}
diren_num++;
Canvas canvas = holder.lockCanvas();
canvas.drawBitmap(erjihuancun,0,0,p1);
holder.unlockCanvasAndPost(canvas);
Thread.sleep(10);
}
}catch(Exception e){
}
} @Override
public void surfaceCreated(SurfaceHolder holder) {
} @Override
public void surfaceDestroyed(SurfaceHolder holder) {
state = false;
} @Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
//得到屏幕的宽和高
display_w=width;
display_h=height;
init();
this.holder=holder;
state = true;
new Thread(this).start();
} }
dafeijiGameView.java
package com.example.administrator.myapplication; import android.support.v7.app.AppCompatActivity;
import android.os.Bundle; public class MainActivity extends AppCompatActivity{ @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//去掉标题
// requestWindowFeature(Window.FEATURE_NO_TITLE);
dafeijiGameView view = new dafeijiGameView(this); setContentView(view);
} }
MainActivity.java
实现过程
绘制敌机
private class DijiImage implements GameImage{ private Bitmap diren = null; private List<Bitmap> bitmaps = new ArrayList<Bitmap>();
private int x;
private int y; public DijiImage(Bitmap diren){
this.diren=diren;
bitmaps.add(Bitmap.createBitmap(diren,0,0,diren.getWidth()/4,diren.getHeight()));
bitmaps.add(Bitmap.createBitmap(diren,(diren.getWidth()/4)*1,0,diren.getWidth()/4,diren.getHeight()));
bitmaps.add(Bitmap.createBitmap(diren,(diren.getWidth()/4)*2,0,diren.getWidth()/4,diren.getHeight()));
bitmaps.add(Bitmap.createBitmap(diren,(diren.getWidth()/4)*3,0,diren.getWidth()/4,diren.getHeight())); y=-diren.getHeight();
Random ran = new Random();
x=ran.nextInt(display_w-(diren.getWidth()/4)); } private int index=0;
private int num =0;
@Override
public Bitmap getBitmap() {
Bitmap bitmap = bitmaps.get(index);
//控制切换四个飞机的频率
if(num == 7){
index++;
if(index == bitmaps.size()){
index=0;
}
num=0;
}
y+=3;
num++; if(y>display_h){
gameImage.remove(this);
} return bitmap;
} @Override
public int getX() {
return x;
} @Override
public int getY() {
return y;
}
}
DijiImage.java
初始化游戏时候加载敌机类
private void init(){
//加载照片
my= BitmapFactory.decodeResource(getResources(),R.drawable.my);
baozha= BitmapFactory.decodeResource(getResources(),R.drawable.baozha);
bg= BitmapFactory.decodeResource(getResources(),R.drawable.bg);
diren= BitmapFactory.decodeResource(getResources(),R.drawable.diren);
zidan= BitmapFactory.decodeResource(getResources(),R.drawable.zidan); erjihuancun=Bitmap.createBitmap(display_w,display_h, Bitmap.Config.ARGB_8888);
gameImage.add(new BeijingImage(bg)); //先加入背景照片
gameImage.add(new FeijiImage(my));
gameImage.add(new DijiImage(diren));
}
绘制敌机飞行动画
private List<Bitmap> bitmaps = new ArrayList<Bitmap>();
将四张敌机加入链表
bitmaps.add(Bitmap.createBitmap(diren,0,0,diren.getWidth()/4,diren.getHeight()));
bitmaps.add(Bitmap.createBitmap(diren,(diren.getWidth()/4)*1,0,diren.getWidth()/4,diren.getHeight()));
bitmaps.add(Bitmap.createBitmap(diren,(diren.getWidth()/4)*2,0,diren.getWidth()/4,diren.getHeight()));
bitmaps.add(Bitmap.createBitmap(diren,(diren.getWidth()/4)*3,0,diren.getWidth()/4,diren.getHeight()));
public static Bitmap createBitmap(Bitmap source, int x, int y, int width, int height, Matrix m, boolean filter)
从原始位图剪切图像,这是一种高级的方式。可以用Matrix(矩阵)来实现旋转等高级方式截图
Bitmap source:要从中截图的原始位图
int x:起始x坐标
int y:起始y坐标
int width:要截的图的宽度
int height:要截的图的宽度
Bitmap.Config config:一个枚举类型的配置,可以定义截到的新位图的质量
private int index=0;
private int num =0;
@Override
public Bitmap getBitmap() {
Bitmap bitmap = bitmaps.get(index);
//控制切换四个飞机的频率
if(num == 7){
index++;
if(index == bitmaps.size()){
index=0;
}
num=0;
} //y+=3控制敌机下降速度
y+=3;
随机位置生成敌机
y=-diren.getHeight();
Random ran = new Random();
x=ran.nextInt(display_w-(diren.getWidth()/4));
在游戏绘画中心中添加敌机出现
//绘画中心
public void run() {
Paint p1 = new Paint();
int diren_num=0;//
try{
while(true){
Canvas newCanvas = new Canvas(erjihuancun);
for(GameImage image:(List<GameImage>)gameImage.clone()){
newCanvas.drawBitmap(image.getBitmap(),image.getX(),image.getY(),p1);
}
if(diren_num==150){
diren_num=0;
gameImage.add(new DijiImage(diren));
}
diren_num++;
Canvas canvas = holder.lockCanvas();
canvas.drawBitmap(erjihuancun,0,0,p1);
holder.unlockCanvasAndPost(canvas);
Thread.sleep(10);
}
}catch(Exception e){
}
}
敌机出现频率
if(diren_num==150){
diren_num=0;
gameImage.add(new DijiImage(diren));
}
diren_num++;
package com.example.administrator.myapplication; import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.WindowManager; import java.util.ArrayList;
import java.util.List;
import java.util.Random; /**
* Created by Administrator on 2018/8/9.
*/ public class dafeijiGameView extends SurfaceView implements
SurfaceHolder.Callback,Runnable,android.view.View.OnTouchListener{ private Bitmap my;//自己
private Bitmap baozha;//爆炸
private Bitmap bg;//背景
private Bitmap diren;//敌人
private Bitmap zidan;//子弹
private Bitmap erjihuancun;//二级缓存
private WindowManager windowManager;//获得界面长宽高
private int display_w; //界面的宽
private int display_h; //界面的高
private ArrayList<GameImage> gameImage = new ArrayList(); public dafeijiGameView(Context context) {
super(context);
getHolder().addCallback(this);
//事件注册
this.setOnTouchListener(this);
} private void init(){
//加载照片
my= BitmapFactory.decodeResource(getResources(),R.drawable.my);
baozha= BitmapFactory.decodeResource(getResources(),R.drawable.baozha);
bg= BitmapFactory.decodeResource(getResources(),R.drawable.bg);
diren= BitmapFactory.decodeResource(getResources(),R.drawable.diren);
zidan= BitmapFactory.decodeResource(getResources(),R.drawable.zidan); erjihuancun=Bitmap.createBitmap(display_w,display_h, Bitmap.Config.ARGB_8888);
gameImage.add(new BeijingImage(bg)); //先加入背景照片
gameImage.add(new FeijiImage(my));
gameImage.add(new DijiImage(diren));
} FeijiImage selectfeiji;
@Override
public boolean onTouch(View v, MotionEvent event) {
//手接近屏幕产生的事件
if(event.getAction()==MotionEvent.ACTION_DOWN){
for(GameImage game: gameImage){
if(game instanceof FeijiImage){ FeijiImage feiji = (FeijiImage)game; //判断条件为真时选中飞机
if(feiji.getX()<event.getX()&&
feiji.getY()<event.getY()&&
feiji.getX()+feiji.getWidth()>event.getX() &&
feiji.getY()+feiji.getHeigth()>event.getY()){
selectfeiji=feiji; }else{
selectfeiji=null;
}
break;
}
}
}else if(event.getAction()==MotionEvent.ACTION_MOVE){
//移动鼠标
if( selectfeiji!=null){
selectfeiji.setX((int)event.getX()-selectfeiji.getWidth()/2);
selectfeiji.setY((int)event.getY()-selectfeiji.getHeigth()/2);
} }else if(event.getAction()==MotionEvent.ACTION_UP){
//松开鼠标
selectfeiji=null;
} return true;
} private interface GameImage{
public Bitmap getBitmap();
public int getX();
public int getY();
} private class DijiImage implements GameImage{ private Bitmap diren = null; private List<Bitmap> bitmaps = new ArrayList<Bitmap>();
private int x;
private int y; public DijiImage(Bitmap diren){
this.diren=diren;
bitmaps.add(Bitmap.createBitmap(diren,0,0,diren.getWidth()/4,diren.getHeight()));
bitmaps.add(Bitmap.createBitmap(diren,(diren.getWidth()/4)*1,0,diren.getWidth()/4,diren.getHeight()));
bitmaps.add(Bitmap.createBitmap(diren,(diren.getWidth()/4)*2,0,diren.getWidth()/4,diren.getHeight()));
bitmaps.add(Bitmap.createBitmap(diren,(diren.getWidth()/4)*3,0,diren.getWidth()/4,diren.getHeight())); y=-diren.getHeight();
Random ran = new Random();
x=ran.nextInt(display_w-(diren.getWidth()/4)); } private int index=0;
private int num =0;
@Override
public Bitmap getBitmap() {
Bitmap bitmap = bitmaps.get(index);
//控制切换四个飞机的频率
if(num == 7){
index++;
if(index == bitmaps.size()){
index=0;
}
num=0;
}
y+=3;
num++; if(y>display_h){
gameImage.remove(this);
} return bitmap;
} @Override
public int getX() {
return x;
} @Override
public int getY() {
return y;
}
} private class FeijiImage implements GameImage{ private Bitmap my;
private int x;
private int y;
private int width;
private int heigth; private int getWidth(){
return width;
} private int getHeigth(){
return heigth;
} private List<Bitmap> bitmaps = new ArrayList<Bitmap>(); private FeijiImage(Bitmap my){
this.my=my;
bitmaps.add(Bitmap.createBitmap(my,0,0,my.getWidth()/4,my.getHeight()));
bitmaps.add(Bitmap.createBitmap(my,(my.getWidth()/4),0,my.getWidth()/4,my.getHeight()));
bitmaps.add(Bitmap.createBitmap(my,(my.getWidth()/4)*2,0,my.getWidth()/4,my.getHeight()));
bitmaps.add(Bitmap.createBitmap(my,(my.getWidth()/4)*3,0,my.getWidth()/4,my.getHeight()));
//得到战机的高和宽
width=my.getWidth()/4;
heigth=my.getHeight();
x=(display_w - my.getWidth()/4)/2;
y=display_h-my.getHeight()-30;
} private int index=0;
private int num =0;
@Override
public Bitmap getBitmap() {
Bitmap bitmap = bitmaps.get(index);
//控制切换四个飞机的频率
if(num == 7){
index++;
if(index == bitmaps.size()){
index=0;
}
num=0;
}
num++;
return bitmap;
} @Override
public int getX() {
return x;
} @Override
public int getY() {
return y;
} public void setY(int y){
this.y=y;
} public void setX(int x){
this.x=x;
} } //负责背景照片的处理
private class BeijingImage implements GameImage{
private Bitmap bg;
private BeijingImage(Bitmap bg){
this.bg=bg;
newBitmap = Bitmap.createBitmap(display_w,display_h, Bitmap.Config.ARGB_8888);
} private Bitmap newBitmap = null;
private int height = 0; public Bitmap getBitmap(){
Paint p = new Paint();
Canvas canvas = new Canvas(newBitmap);
canvas.drawBitmap(bg,
new Rect(0,0,bg.getWidth(),bg.getHeight()),
new Rect(0,height,display_w,display_h+height),p); canvas.drawBitmap(bg,
new Rect(0,0,bg.getWidth(),bg.getHeight()),
new Rect(0,-display_h+height,display_w,height),p); height++;
if(height==display_h){
height=0;
}
return newBitmap;
} public int getX(){
return 0;
} public int getY(){
return 0;
}
} private boolean state = false;
private SurfaceHolder holder; //绘画中心
public void run() {
Paint p1 = new Paint();
int diren_num=0;//
try{
while(true){
Canvas newCanvas = new Canvas(erjihuancun);
for(GameImage image:(List<GameImage>)gameImage.clone()){
newCanvas.drawBitmap(image.getBitmap(),image.getX(),image.getY(),p1);
}
if(diren_num==150){
diren_num=0;
gameImage.add(new DijiImage(diren));
}
diren_num++;
Canvas canvas = holder.lockCanvas();
canvas.drawBitmap(erjihuancun,0,0,p1);
holder.unlockCanvasAndPost(canvas);
Thread.sleep(10);
}
}catch(Exception e){
}
} @Override
public void surfaceCreated(SurfaceHolder holder) {
} @Override
public void surfaceDestroyed(SurfaceHolder holder) {
state = false;
} @Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
//得到屏幕的宽和高
display_w=width;
display_h=height;
init();
this.holder=holder;
state = true;
new Thread(this).start();
} }
dafeijiGameView
游戏中添加子弹
private class Zidan implements GameImage{ Bitmap zidan;
private FeijiImage feiji;
private int x;
private int y; public Zidan(FeijiImage feiji,Bitmap zidan){
this.feiji=feiji;
this.zidan=zidan; x=(feiji.getX()+feiji.getWidth()/2)-25;//居中位置
y=feiji.getY()-zidan.getHeight();
} public Bitmap getBitmap() {
y-=19;
if(y<=-10){
zidans.remove(this);
}
return zidan;
} @Override
public int getX() {
return x;
} @Override
public int getY() {
return y;
}
}
zidan.class
判断子弹出现飞机位置
public Zidan(FeijiImage feiji,Bitmap zidan){
this.feiji=feiji;
this.zidan=zidan; x=(feiji.getX()+feiji.getWidth()/2)-25;//居中位置
y=feiji.getY()-zidan.getHeight();
}
(-25是自己微调)
子弹超出边界的时候释放子弹内存,减少手机开销
public Bitmap getBitmap() {
y-=19;
if(y<=-10){
zidans.remove(this);
}
return zidan;
}
不断的出现新的子弹
if(selectfeiji!=null){
if(zidan_num==10){
zidans.add(new Zidan(selectfeiji,zidan));
zidan_num=0;
}
zidan_num++;
}
便利所有的子弹
for(GameImage image:(List<GameImage>)zidans.clone()){
newCanvas.drawBitmap(image.getBitmap(),image.getX(),image.getY(),p1);
}
Android_(游戏)打飞机04:绘画敌机、添加子弹的更多相关文章
- Android_(游戏)打飞机05:处理子弹,击中敌机,添加计分板
(游戏)打飞机01:前言 传送门 (游戏)打飞机02:游戏背景滚动 传送门 (游戏)打飞机03:控制玩家飞机 传送门 (游戏)打飞机04:绘画敌机.添加子弹 传送门 (游戏)打飞机05:处理子弹, ...
- Android_(游戏)打飞机06:后续
(游戏)打飞机01:前言 传送门 (游戏)打飞机02:游戏背景滚动 传送门 (游戏)打飞机03:控制玩家飞机 传送门 (游戏)打飞机04:绘画敌机.添加子弹 传送门 (游戏)打飞机05:处理子弹, ...
- Android_(游戏)打飞机03:控制玩家飞机
(游戏)打飞机01:前言 传送门 (游戏)打飞机02:游戏背景滚动 传送门 (游戏)打飞机03:控制玩家飞机 传送门 (游戏)打飞机04:绘画敌机.添加子弹 传送门 (游戏)打飞机05:处理子弹, ...
- Android_(游戏)打飞机02:游戏背景滚动
(游戏)打飞机01:前言 传送门 (游戏)打飞机02:游戏背景滚动 传送门 (游戏)打飞机03:控制玩家飞机 传送门 (游戏)打飞机04:绘画敌机.添加子弹 传送门 (游戏)打飞机05:处理子弹, ...
- Android_(游戏)打飞机01:前言
(游戏)打飞机01:前言 传送门 (游戏)打飞机02:游戏背景滚动 传送门 (游戏)打飞机03:控制玩家飞机 传送门 (游戏)打飞机04:绘画敌机.添加子弹 传送门 (游戏)打飞机05:处理子弹, ...
- Python小游戏之 - 飞机大战美女 !
用Python写的"飞机大战美女"小游戏 源代码如下: # coding=utf-8 import os import random import pygame # 用一个常量来存 ...
- 微信小游戏 demo 飞机大战 代码分析 (二)(databus.js)
微信小游戏 demo 飞机大战 代码分析(二)(databus.js) 微信小游戏 demo 飞机大战 代码分析(一)(main.js) 微信小游戏 demo 飞机大战 代码分析(三)(spirit. ...
- 微信小游戏 demo 飞机大战 代码分析 (一)(game.js, main.js)
微信小游戏 demo 飞机大战 代码分析(一)(main.js) 微信小游戏 demo 飞机大战 代码分析(二)(databus.js) 微信小游戏 demo 飞机大战 代码分析(三)(spirit. ...
- 微信demo小游戏:飞机大战从无到有
微信demo游戏飞机大战从无到有 现在创建新项目会默认给飞机大战的demo,这里给大家从基础开始讲解游戏的从无到有是怎么实现的. 具体实现步骤: 创建背景图->背景图运动起来->创建飞机并 ...
随机推荐
- 2019牛客暑期多校训练营(第五场)G - subsequeue 1 (一题我真的不会的题)
layout: post title: 2019牛客暑期多校训练营(第五场)G - subsequeue 1 (一题我真的不会的题) author: "luowentaoaa" c ...
- C++练习 | 单链表的创建与输出(结构体格式)
#include <iostream> #include <stdio.h> using namespace std; #define OK 1 #define ERROR 0 ...
- jquery的offset().top与javascript的offsetTop区别?
offset().top是jquery的方法,需引入jquery,它获取你绑定元素上边框相对于html上边界的偏移量 offsetTop是原生js的方法,它获取你绑定元素上边框相对于离自己最近且pos ...
- ionic 提示 Error: Could not find gradle wrapper within Android SDK.
Error: Could not find gradle wrapper within Android SDK. Might need to update your Android SDK. 到And ...
- 客户端相关知识学习(一)之混合开发,为什么要在App中使用H5页面以及应用场景、注意事项
混合开发 随着移动互联网的高速发展,常规的开发速度已经渐渐不能满足市场需求.原生H5混合开发应运而生,目前,市场上许多主流应用都有用到混合开发,例如支付宝.美团等.下面,结合我本人的开发经验,简单谈一 ...
- MySQL索引详解(优缺点,何时需要/不需要创建索引,索引及sql语句的优化)
一.什么是索引? 索引是对数据库表中的一列或多列值进行排序的一种结构,使用索引可以快速访问数据库表中的特定信息. 二.索引的作用? 索引相当于图书上的目录,可以根据目录上的页码快速找到所需的内容,提 ...
- VS2017 VS2019 无法进入安装界面闪退问题(windows7SP1)
如果离线安装 Visual Studio 2017/2019出现“即将完成…一切即将准备就绪.”的画面后,等几秒安装程序没有任何错误提示就关闭了,无法继续安装. 解决方法: 将vs_enterpris ...
- 多线程编程-- part 9 信号量:Semaphore
Semaphore简介 Semaphore是一个计数信号量,它的本质是一个"共享锁". 信号量维护了一个信号量许可集.线程可以通过调用acquire()来获取信号量的许可:当信号量 ...
- 《编译原理》构造与正规式 (0|1)*01 等价的 DFA - 例题解析
<编译原理>构造与正规式 (0|1)*01 等价的 DFA - 例题解析 解题步骤: NFA 状态转换图 子集法 DFA 的状态转换矩阵 DFA 的状态转图 解: 已给正规式:(0|1)* ...
- 过滤器、拦截器、AOP的区别
过滤器 过滤器可以拦截到方法的请求和响应(ServletRequest request, SetvletResponse response),并对请求响应做出响应的过滤操作,比如设置字符编码.鉴权操作 ...