package com.guomin.terisme;
import java.util.Random;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
public class TerisView extends View {
Context context;
MinSound mSound;
public static int SCREEN_W = 320;
public static int SCREEN_H = 455;
Paint paint;
public boolean enableSound = false;
public Random rand;
public static final int STATE_LOADING = 0;// 载入图片
public static final int STATE_MENU = 2;// 主菜单
public static final int STATE_OPTIONS = 3;// 选项
public static final int STATE_CREDITS = 4;// 开发人员
public static final int STATE_PLAY = 5;// 正在玩
public static final int STATE_GAMEOVER = 7;// 游戏结束
public static final int STATE_REMOVE = 8;// 消去
public static final int STATE_PAUSE = 9;// 暂停
public static final int STATE_ENSOUND = 10;// 是否开启声音
public static int gamestate = STATE_LOADING;
// 图片
private Bitmap bufferMap;// buffer
private Canvas canvas;
private Bitmap title;
private Bitmap menubg;
private Bitmap menuword1;
private Bitmap menuword2;
private Bitmap options1;
private Bitmap options2;
private Bitmap credits;
private Bitmap pause1;
private Bitmap pause2;
private Bitmap gauge1;
private Bitmap gauge2;
private Bitmap gameover;
private Bitmap[] mBlock = new Bitmap[8]; // 小格子图片
// 菜单变量
int menuAt = 0;
int menuSpace = 10;
int titleDown = 10;
int menuDown = titleDown * 3;
int optionsAt;
int pauseAt;
int pauseBack;
int loadFrame = 20;
// END菜单变量
// 主要游戏变量
int beginDrawX; // 开始画主体X
int beginDrawY; // 开始画主体Y
public static int caseWidth = 20; // 小格子边长
public static final int case_L = 4; // 块格子边长
public static int body_W = 11;
public static int body_H = SCREEN_H / caseWidth + 5;
public static int[][] body = new int[body_W][body_H]; // 游戏池
public static boolean[] isReCase = new boolean[body_H]; // 消去的行
public static int[][] currentCase = new int[case_L][case_L]; // 当前活动图形
public static int[][] tempCase = new int[case_L][case_L]; // 中间活动图形
public static int[][] nextCase = new int[case_L][case_L]; // 下一个活动图形
public static int currentX; // 当前块坐标
public static int currentY; // 当前块坐标
public static int currentColor; // 当前块颜色
public static int nextColor; // 下一块颜色
public static int index; // 生成块的下标
public static int nowIndex; // 当前块的下标
public static int[][][] store = new int[][][] { {// I
{ 0, 0, 0, 1 }, { 0, 0, 0, 1 }, { 0, 0, 0, 1 }, { 0, 0, 0, 1 } }, {// I
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 1, 1, 1, 1 }, { 0, 0, 0, 0 } }, {// I
{ 0, 0, 0, 1 }, { 0, 0, 0, 1 }, { 0, 0, 0, 1 }, { 0, 0, 0, 1 } }, {// I
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 1, 1, 1, 1 }, { 0, 0, 0, 0 } }, {// O
{ 0, 0, 0, 0 }, { 0, 1, 1, 0 }, { 0, 1, 1, 0 }, { 0, 0, 0, 0 } }, {// O
{ 0, 0, 0, 0 }, { 0, 1, 1, 0 }, { 0, 1, 1, 0 }, { 0, 0, 0, 0 } }, {// O
{ 0, 0, 0, 0 }, { 0, 1, 1, 0 }, { 0, 1, 1, 0 }, { 0, 0, 0, 0 } }, {// O
{ 0, 0, 0, 0 }, { 0, 1, 1, 0 }, { 0, 1, 1, 0 }, { 0, 0, 0, 0 } }, {// L
{ 0, 1, 0, 0 }, { 0, 1, 0, 0 }, { 0, 1, 1, 0 }, { 0, 0, 0, 0 } }, {// L
{ 0, 0, 0, 0 }, { 1, 1, 1, 0 }, { 1, 0, 0, 0 }, { 0, 0, 0, 0 } }, {// L
{ 0, 1, 1, 0 }, { 0, 0, 1, 0 }, { 0, 0, 1, 0 }, { 0, 0, 0, 0 } }, {// L
{ 0, 0, 0, 0 }, { 0, 0, 1, 0 }, { 1, 1, 1, 0 }, { 0, 0, 0, 0 } }, {// J
{ 0, 0, 1, 0 }, { 0, 0, 1, 0 }, { 0, 1, 1, 0 }, { 0, 0, 0, 0 } }, {// J
{ 0, 0, 0, 0 }, { 1, 0, 0, 0 }, { 1, 1, 1, 0 }, { 0, 0, 0, 0 } }, {// J
{ 0, 1, 1, 0 }, { 0, 1, 0, 0 }, { 0, 1, 0, 0 }, { 0, 0, 0, 0 } }, {// J
{ 0, 0, 0, 0 }, { 1, 1, 1, 0 }, { 0, 0, 1, 0 }, { 0, 0, 0, 0 } }, {// T
{ 0, 0, 0, 0 }, { 0, 1, 0, 0 }, { 1, 1, 1, 0 }, { 0, 0, 0, 0 } }, {// T
{ 0, 1, 0, 0 }, { 0, 1, 1, 0 }, { 0, 1, 0, 0 }, { 0, 0, 0, 0 } }, {// T
{ 0, 0, 0, 0 }, { 1, 1, 1, 0 }, { 0, 1, 0, 0 }, { 0, 0, 0, 0 } }, {// T
{ 0, 0, 1, 0 }, { 0, 1, 1, 0 }, { 0, 0, 1, 0 }, { 0, 0, 0, 0 } }, {// S
{ 0, 0, 0, 0 }, { 0, 1, 1, 0 }, { 1, 1, 0, 0 }, { 0, 0, 0, 0 } }, {// S
{ 0, 1, 0, 0 }, { 0, 1, 1, 0 }, { 0, 0, 1, 0 }, { 0, 0, 0, 0 } }, {// S
{ 0, 0, 0, 0 }, { 0, 1, 1, 0 }, { 1, 1, 0, 0 }, { 0, 0, 0, 0 } }, {// S
{ 0, 1, 0, 0 }, { 0, 1, 1, 0 }, { 0, 0, 1, 0 }, { 0, 0, 0, 0 } }, {// Z
{ 0, 0, 0, 0 }, { 1, 1, 0, 0 }, { 0, 1, 1, 0 }, { 0, 0, 0, 0 } }, {// Z
{ 0, 0, 1, 0 }, { 0, 1, 1, 0 }, { 0, 1, 0, 0 }, { 0, 0, 0, 0 } }, {// Z
{ 0, 0, 0, 0 }, { 1, 1, 0, 0 }, { 0, 1, 1, 0 }, { 0, 0, 0, 0 } }, {// Z
{ 0, 0, 1, 0 }, { 0, 1, 1, 0 }, { 0, 1, 0, 0 }, { 0, 0, 0, 0 } } };
public static int score = 0;
public static int showScore = 0;
public static int reLine = 0;
public static int iStep = body_H; // 快速落下 步数
public static int frame = 0;
public static int playFrame = 0;
public static int comboFrame = 0;
public static int addFrame = 0;
public static int frame5 = 5;
public static int frame10 = 10;
public static int frame20 = 20;
public static int removeFrame = 5;
public static int fastFrame = 1;
public static int overFrame = 10;
public static int createdFrame = 280;
public int initSpeed = 0;
public static int addSpeed;
// 开关
boolean isNewCase = false;
boolean isMoveDown = false;
boolean isCombo = false;
boolean isRemove = false;
boolean isGameOver = false;
// END 主要游戏变量
private static final int SID_ADD = 0;
private static final int SID_MOVE = 1;
// TODO 构造函数
public TerisView(Context ctx) {
super(ctx);
initTerisme(ctx);
}
public TerisView(Context ctx, AttributeSet attrs) {
super(ctx, attrs);
initTerisme(ctx);
}
public TerisView(Context ctx, AttributeSet attrs, int defStyle) {
super(ctx, attrs, defStyle);
initTerisme(ctx);
}
public void initTerisme(Context ctx) {
context = ctx;
setFocusable(true);
paint = new Paint();
rand = new Random();
mSound = new MinSound(context);
mSound.initSounds();
mSound.loadSfx(R.raw.bomb, SID_ADD);
mSound.loadSfx(R.raw.move, SID_MOVE);
paint.setTextSize(24);
beginDrawX = 0;
beginDrawY = SCREEN_H - caseWidth * body_H;
bufferMap = Bitmap.createBitmap(SCREEN_W, SCREEN_H,
Bitmap.Config.ARGB_8888);
canvas = new Canvas(bufferMap);
loadFP();
loadAllImage();
// gamestate = STATE_LOADING;
startGame();
Log.v("teris", "initialized");
}
public Bitmap createImage(Drawable tile, int w, int h) {
Bitmap bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
tile.setBounds(0, 0, w, h);
tile.draw(canvas);
return bitmap;
}
public void loadFP() {
Resources r = this.getContext().getResources();
title = createImage(r.getDrawable(R.drawable.title), 200, 71);
menubg = createImage(r.getDrawable(R.drawable.menubg), 320, 455);
gauge1 = createImage(r.getDrawable(R.drawable.gauge1), 200, 17);
gauge2 = createImage(r.getDrawable(R.drawable.gauge2), 200, 17);
}
public void freeFP() {
gauge1 = null;
gauge2 = null;
}
public void loadAllImage() {
Resources r = this.getContext().getResources();
mBlock[0] = createImage(r.getDrawable(R.drawable.block0), caseWidth,
caseWidth);
mBlock[1] = createImage(r.getDrawable(R.drawable.block1), caseWidth,
caseWidth);
mBlock[2] = createImage(r.getDrawable(R.drawable.block2), caseWidth,
caseWidth);
mBlock[3] = createImage(r.getDrawable(R.drawable.block3), caseWidth,
caseWidth);
mBlock[4] = createImage(r.getDrawable(R.drawable.block4), caseWidth,
caseWidth);
没有合适的资源?快使用搜索试试~ 我知道了~
俄罗斯游戏项目源码Android
共57个文件
png:31个
class:11个
java:5个
5星 · 超过95%的资源 需积分: 10 153 下载量 199 浏览量
2009-08-03
11:27:31
上传
评论 1
收藏 465KB RAR 举报
温馨提示
俄罗斯游戏项目源码Android,用来开发俄罗斯游戏项目源码Android
资源推荐
资源详情
资源评论
收起资源包目录
TerisMe(android).rar (57个子文件)
TerisMe
.project 843B
bin
TerisMe.apk 156KB
com
guomin
terisme
R$string.class 427B
R$layout.class 394B
RefreshHandler.class 1KB
R$drawable.class 1KB
TerisView.class 21KB
R.class 575B
R$raw.class 413B
R$attr.class 340B
MinSound.class 2KB
R$id.class 385B
TerisMe.class 1KB
resources.ap_ 142KB
classes.dex 24KB
AndroidManifest.xml 648B
src
com
guomin
terisme
TerisView.java 31KB
RefreshHandler.java 782B
MinSound.java 2KB
TerisMe.java 941B
R.java 2KB
res
values
strings.xml 164B
layout
main.xml 331B
raw
move.wav 1KB
bomb.wav 3KB
drawable
imgscore.png 843B
menuword1.png 18KB
block6.png 1KB
options1.png 12KB
gauge2.png 1KB
zcl.png 17KB
mask.png 171B
block4.png 1KB
block0.png 1KB
block5.png 1KB
num01.png 384B
bodybg.png 11KB
num02.png 430B
top.png 1KB
menubg.png 2KB
gameover.png 2KB
block1.png 1KB
block2.png 1KB
credits.png 3KB
pause2.png 10KB
block3.png 1KB
gauge1.png 1KB
icon.png 1KB
options2.png 12KB
brim.png 1KB
menuword2.png 18KB
block7.png 1KB
imgline.png 619B
imgspeed.png 833B
pause1.png 10KB
title.png 15KB
.classpath 238B
assets
共 57 条
- 1
资源评论
- 「已注销」2013-04-10不错 是我需要的
- s306786792e2012-06-19运行有点问题,搜俄罗斯游戏,有个比较全的,那个还不错,学习价值更大
- chaichai113452012-10-25运行有点问题
- chenglihuo2011-12-14不是我想要的,在1.5版本上不能用。
wjclsh
- 粉丝: 8
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功