package tw.brad.apps.bombking;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.media.AudioManager;
import android.media.SoundPool;
import android.os.Environment;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MotionEvent;
import android.view.View;
public class GameView extends View {
int play_level, bombking;
boolean isSound, isLimit, isMusic, isCustom;
String CustomFile;
private Context context;
private Resources res;
private GestureDetector gDetector;
private static SharedPreferences sp;
private static SharedPreferences.Editor speditor;
private File rootPath, savePath;
private int rows = 12;
private int cols = 20;
private int[][] gamemap, prebomb;
private int[] leveldata = { R.raw.bomb000, R.raw.bomb001, R.raw.bomb002,
R.raw.bomb003, R.raw.bomb004, R.raw.bomb005, R.raw.bomb006,
R.raw.bomb007, R.raw.bomb008, R.raw.bomb009, R.raw.bomb010,
R.raw.bomb011, R.raw.bomb012, R.raw.bomb013, R.raw.bomb014,
R.raw.bomb015, R.raw.bomb016, R.raw.bomb017, R.raw.bomb018,
R.raw.bomb019, R.raw.bomb020, R.raw.bomb021, R.raw.bomb022,
R.raw.bomb023, R.raw.bomb024, R.raw.bomb025, R.raw.bomb026,
R.raw.bomb027, R.raw.bomb028, R.raw.bomb029, R.raw.bomb030,
R.raw.bomb031, R.raw.bomb032, R.raw.bomb033, R.raw.bomb034,
R.raw.bomb035, R.raw.bomb036, R.raw.bomb037, R.raw.bomb038,
R.raw.bomb039, R.raw.bomb040, R.raw.bomb041, R.raw.bomb042,
R.raw.bomb043, R.raw.bomb044, R.raw.bomb045, R.raw.bomb046,
R.raw.bomb047, R.raw.bomb048, R.raw.bomb049, R.raw.bomb050,
R.raw.bomb051, R.raw.bomb052, R.raw.bomb053, R.raw.bomb054,
R.raw.bomb055, R.raw.bomb056, R.raw.bomb057, R.raw.bomb058,
R.raw.bomb059, R.raw.bomb060, R.raw.bomb061, R.raw.bomb062,
R.raw.bomb063 };
private Bitmap android, bbbird1, bbbird2, apple, brick_dig, brick_hard,
bomb, bomb2, exit;
private Bitmap android_walk1, android_walk2;
private Bitmap bomb_f1, bomb_f2, bomb_f3, bomb_f4, danger, box, shield,
shields, shieldb;
private Bitmap sound_on, sound_off, music_on, music_off;
private Bitmap bg;
private Bitmap stop, up, down, left, right, bomb_bt;
private Bitmap plank1, plank2, plank3, plank4;
private Bitmap controller;
private boolean isInitGame, isStartGame, isStopRound, isShieldMode;
private int android_r, android_c, android_step_h, android_step_v;
private int viewW, viewH, unitW, unitH;
private Matrix matrix;
private final int STOP = 0;
private final int UP = 1;
private final int DOWN = 2;
private final int LEFT = 3;
private final int RIGHT = 4;
private static final int MAP_ROAD = 0;
private static final int MAP_BRICK = 1;
private static final int MAP_WALL = 2;
private static final int MAP_BOX = 3;
private static final int MAP_EXIT = 4;
private static final int MAP_BOMB2 = 5;
private static final int MAP_BOMB = 6;
private static final int MAP_BBBIRD = 7;
private static final int MAP_ANDROID = 8;
private static final int MAP_APPLE = 9;
private static final int MAP_SHIELD = 10;
private static final int MAP_FLASH_4 = -4;
private static final int MAP_FLASH_3 = -3;
private static final int MAP_FLASH_2 = -2;
private static final int MAP_FLASH_1 = -1;
private static final int BOMB_KING_FOX = 0;
private static final int BOMB_KING_LION = 1;
private static final int BOMB_KING_PANDA = 2;
private int freq = 70;
private int bb_freq = 180;
private int bomb_timeout, shield_timeout = 7000;
private static int bomb_freq = 200;
private List<BBBird> bbs = new ArrayList<BBBird>();
private static int Apple_Qty = 0, Apple_Total = 0;
private static int Bomb_Qty, addBombQty;
private static int Shield_Qty, addShieldQty;
Timer timer;
private Android atask;
private static Paint txtTitlePaint, txtStagePaint, txtApplePaint, bgPaint;
private LinkedList<HashMap<String, Integer>> bricks;
private int exit_r0, exit_c0, exit_r1, exit_c1, exit_r2, exit_c2, iStart;
private int box_count, box_open;
private int shield_count, shield_open;
private SoundPool soundPool;
private int Sound_Bomb, Sound_Apple, Sound_Box, Sound_Put_Bomb,
Sound_Loser, Sound_Winner, Sound_Timer;
private boolean isTouchController;
private int tc, tr;
public GameView(Context context, AttributeSet attrs) {
super(context, attrs);
this.context = context;
gDetector = new GestureDetector(this.context, new MyGesture());
sp = context.getSharedPreferences("gamedata", context.MODE_PRIVATE);
speditor = sp.edit();
rootPath = Environment.getExternalStorageDirectory();
savePath = new File(rootPath, "/Android/data/"
+ context.getPackageName() + "/levels");
if (!savePath.exists())
savePath.mkdirs();
// Load Sound Effect
soundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0);
Sound_Bomb = soundPool.load(context, R.raw.bomb2, 1);
Sound_Apple = soundPool.load(context, R.raw.eat_apple, 1);
Sound_Box = soundPool.load(context, R.raw.eat_box, 1);
Sound_Put_Bomb = soundPool.load(context, R.raw.put_bomb, 1);
Sound_Loser = soundPool.load(context, R.raw.loser, 1);
Sound_Winner = soundPool.load(context, R.raw.winner1, 1);
Sound_Timer = soundPool.load(context, R.raw.timer, 1);
bgPaint = new Paint();
bgPaint.setAlpha(192);
res = getResources();
}
void initGame() {
viewW = getWidth();
viewH = getHeight();
unitW = viewW / cols;
unitH = viewH / rows;
txtStagePaint = new Paint();
txtStagePaint.setColor(Color.WHITE);
txtStagePaint.setStrokeWidth((int) (unitH / 30));
txtStagePaint.setTextSize((int) (0.6 * unitH));
txtStagePaint.setStyle(Paint.Style.FILL_AND_STROKE);
txtApplePaint = new Paint();
txtApplePaint.setColor(Color.YELLOW);
txtApplePaint.setStrokeWidth((int) (unitH / 30));
txtApplePaint.setTextSize((int) (0.6 * unitH));
txtApplePaint.setStyle(Paint.Style.FILL_AND_STROKE);
matrix = new Matrix();
switch (bombking) {
default:
case BOMB_KING_FOX:
bg = fitBitmap(R.drawable.bg_01, 0);
android = fitBitmap(R.drawable.android_fox, 1);
android_walk1 = fitBitmap(R.drawable.fox_walk1, 1);
android_walk2 = fitBitmap(R.drawable.fox_walk2, 1);
freq = 70;
bomb_timeout = 2400;
break;
case BOMB_KING_LION:
bg = fitBitmap(R.drawable.bg_02, 0);
android = fitBitmap(R.drawable.android_lion, 1);
android_walk1 = fitBitmap(R.drawable.lion_walk1, 1);
android_walk2 = fitBitmap(R.drawable.lion_walk2, 1);
freq = 100;
bomb_timeout = 2800;
break;
case BOMB_KING_PANDA:
bg = fitBitmap(R.drawable.bg_03, 0);
android = fitBitmap(R.drawable.android_panda, 1);
android_walk1 = fitBitmap(R.drawable.panda_walk1, 1);
android_walk2 = fitBitmap(R.drawable.panda_walk2, 1);
freq = 130;
bomb_timeout = 3200;
break;
}
bbbird1 = fitBitmap(R.drawable.enemy1, 1);
bbbird2 = fitBitmap(R.drawable.enemy2, 1);
apple = fitBitmap(R.drawable.apple, 1);
brick_dig = fitBitmap(R.drawable.brick_dig, 1);
brick_hard = fitBitmap(R.drawable.bricks, 1);
bomb = fitBitmap(R.drawable.bomb, 1);
bomb2 = fitBitmap(R.drawable.bomb2, 1);
bomb_f4 = fitBitmap(R.drawable.brick_bomb1, 1);
bomb_f3 = fitBitmap(R.drawable.brick_bomb2, 1);
bomb_f2 = fitBitmap(R.drawable.brick_bomb3, 1);
bomb_f1 = fitBitmap(R.drawable.brick_bomb4, 1);
exit = fitBitmap(R.drawable.exit, 1);
danger = fitBitmap(R.drawable.danger, 1);
box = fitBitmap(R.drawable.box, 1);
sound_on = fitBitmap(R.
没有合适的资源?快使用搜索试试~ 我知道了~
《Android APP开发者必修16堂课》范例程序.rar
共2555个文件
class:691个
png:593个
xml:467个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 139 浏览量
2022-06-25
08:31:26
上传
评论
收藏 46.97MB RAR 举报
温馨提示
《Android APP开发者必修16堂课》范例程序.rar
资源推荐
资源详情
资源评论
收起资源包目录
《Android APP开发者必修16堂课》范例程序.rar (2555个子文件)
test.3gp 845KB
resources.ap_ 1.22MB
resources.ap_ 167KB
resources.ap_ 41KB
resources.ap_ 40KB
resources.ap_ 40KB
resources.ap_ 40KB
resources.ap_ 40KB
resources.ap_ 11KB
resources.ap_ 11KB
MySVTest1.apk 1.37MB
HelloLayout.apk 323KB
MySensor.apk 200KB
BradSignature.apk 196KB
MyGPSandMapv3.apk 195KB
MyDeviceInfo.apk 193KB
BradSignature.apk 193KB
LocalTest1.apk 14KB
ch401.apk 14KB
bomb000 480B
bomb001 480B
bomb002 480B
bomb003 480B
bomb004 480B
bomb005 480B
bomb006 480B
bomb007 480B
bomb008 480B
bomb009 480B
bomb010 480B
bomb011 480B
bomb012 480B
bomb013 480B
bomb014 480B
bomb015 480B
bomb016 480B
bomb017 480B
bomb018 480B
bomb019 480B
bomb020 480B
bomb021 480B
bomb022 480B
bomb023 480B
bomb024 480B
bomb025 480B
bomb026 480B
bomb027 480B
bomb028 480B
bomb029 480B
bomb030 480B
bomb031 480B
bomb032 480B
bomb033 480B
bomb034 480B
bomb035 480B
bomb036 480B
bomb037 480B
bomb038 480B
bomb039 480B
bomb040 480B
bomb041 480B
bomb042 480B
bomb043 480B
bomb044 480B
bomb045 480B
bomb046 480B
bomb047 480B
bomb048 480B
bomb049 480B
bomb050 480B
bomb051 480B
bomb052 480B
bomb053 480B
bomb054 480B
bomb055 480B
bomb056 480B
bomb057 480B
bomb058 480B
bomb059 480B
bomb060 480B
bomb061 480B
bomb062 480B
bomb063 480B
jarlist.cache 119B
jarlist.cache 119B
jarlist.cache 119B
jarlist.cache 119B
jarlist.cache 119B
jarlist.cache 119B
jarlist.cache 119B
jarlist.cache 119B
jarlist.cache 119B
jarlist.cache 119B
jarlist.cache 119B
jarlist.cache 119B
jarlist.cache 119B
jarlist.cache 119B
jarlist.cache 119B
jarlist.cache 119B
jarlist.cache 119B
共 2555 条
- 1
- 2
- 3
- 4
- 5
- 6
- 26
资源评论
qq_38220914
- 粉丝: 596
- 资源: 4315
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功