導航:首頁 > 觀俄羅斯 > 如何製作俄羅斯方塊綠幕素材

如何製作俄羅斯方塊綠幕素材

發布時間:2022-03-07 03:23:03

㈠ photoshop怎麼製作俄羅斯方塊那種格子!!!!

前三步幼兒操作級別:

1,新建圖層

2,矩形選框工具,按住shift鍵,在圖上畫一個正方形(Shift鍵是為了保證長寬一致)

3,給正方形上色,然後取消螞蟻線


重點在第四步:

4.該圖層直接Fx做「斜面與浮雕」

在「斜面和浮雕」中主要調整大小,數值要根據你的方框大小來定(記得打開預覽看看你調整的結果,另外你要做的精細的話,可以再描邊上~)

然後確定,就完成了~

㈡ 求用flash 8 製作俄羅斯方塊游戲

我給

㈢ Java 製作俄羅斯方塊的問題

import java.awt.*;
import java.awt.event.*;
//俄羅斯方塊類
public class computer extends Frame{
public static boolean isPlay=false;
public static int level=1,score=0;
public static TextField scoreField,levelField;

public static MyTimer timer;
GameCanvas gameScr;

public static void main(String[] argus){
computer ers = new computer("俄羅斯方塊游戲 V1.0 Author:Vincent");
WindowListener win_listener = new WinListener();
ers.addWindowListener(win_listener);
}

//俄羅斯方塊類的構造方法
computer(String title){
super(title);

setSize(600,480);
setLayout(new GridLayout(1,2));

gameScr = new GameCanvas();
gameScr.addKeyListener(gameScr);

timer = new MyTimer(gameScr);
timer.setDaemon(true);
timer.start();
timer.suspend();

add(gameScr);

Panel rightScr = new Panel();
rightScr.setLayout(new GridLayout(2,1,0,30));
rightScr.setSize(120,500);
add(rightScr);

//右邊信息窗體的布局
MyPanel infoScr = new MyPanel();
infoScr.setLayout(new GridLayout(4,1,0,5));
infoScr.setSize(120,300);
rightScr.add(infoScr);

//定義標簽和初始值
Label scorep = new Label("分數:",Label.LEFT);
Label levelp = new Label("級數:",Label.LEFT);
scoreField = new TextField(8);
levelField = new TextField(8);
scoreField.setEditable(false);
levelField.setEditable(false);
infoScr.add(scorep);
infoScr.add(scoreField);
infoScr.add(levelp);
infoScr.add(levelField);
scorep.setSize(new Dimension(20,60));
scoreField.setSize(new Dimension(20,60));
levelp.setSize(new Dimension(20,60));
levelField.setSize(new Dimension(20,60));
scoreField.setText("0");
levelField.setText("1");

//右邊控制按鈕窗體的布局
MyPanel controlScr = new MyPanel();
controlScr.setLayout(new GridLayout(5,1,0,5));
rightScr.add(controlScr);

//定義按鈕play
Button play_b = new Button("開始游戲");
play_b.setSize(new Dimension(50,200));
play_b.addActionListener(new Command(Command.button_play,gameScr));

//定義按鈕Level UP
Button level_up_b = new Button("提高級數");
level_up_b.setSize(new Dimension(50,200));
level_up_b.addActionListener(new Command(Command.button_levelup,gameScr));

//定義按鈕Level Down
Button level_down_b =new Button("降低級數");
level_down_b.setSize(new Dimension(50,200));
level_down_b.addActionListener(new Command(Command.button_leveldown,gameScr));

//定義按鈕Level Pause
Button pause_b =new Button("游戲暫停");
pause_b.setSize(new Dimension(50,200));
pause_b.addActionListener(new Command(Command.button_pause,gameScr));

//定義按鈕Quit
Button quit_b = new Button("退出遊戲");
quit_b.setSize(new Dimension(50,200));
quit_b.addActionListener(new Command(Command.button_quit,gameScr));

controlScr.add(play_b);
controlScr.add(level_up_b);
controlScr.add(level_down_b);
controlScr.add(pause_b);
controlScr.add(quit_b);
setVisible(true);
gameScr.requestFocus();
}
}

//重寫MyPanel類,使Panel的四周留空間
class MyPanel extends Panel{
public Insets getInsets(){
return new Insets(30,50,30,50);
}
}

//游戲畫布類
class GameCanvas extends Canvas implements KeyListener{
final int unitSize = 30; //小方塊邊長
int rowNum; //正方格的行數
int columnNum; //正方格的列數
int maxAllowRowNum; //允許有多少行未削
int blockInitRow; //新出現塊的起始行坐標
int blockInitCol; //新出現塊的起始列坐標
int [][] scrArr; //屏幕數組
Block b; //對方快的引用

//畫布類的構造方法
GameCanvas(){
rowNum = 15;
columnNum = 10;
maxAllowRowNum = rowNum - 2;
b = new Block(this);
blockInitRow = rowNum - 1;
blockInitCol = columnNum/2 - 2;
scrArr = new int [32][32];
}

//初始化屏幕,並將屏幕數組清零的方法
void initScr(){
for(int i=0;i<rowNum;i++)
for (int j=0; j<columnNum;j++)
scrArr[i][j]=0;
b.reset();
repaint();
}

//重新刷新畫布方法
public void paint(Graphics g){
for(int i = 0; i < rowNum; i++)
for(int j = 0; j < columnNum; j++)
drawUnit(i,j,scrArr[i][j]);
}

//畫方塊的方法
public void drawUnit(int row,int col,int type){
scrArr[row][col] = type;
Graphics g = getGraphics();
switch(type){ //表示畫方快的方法
case 0: g.setColor(Color.black);break; //以背景為顏色畫
case 1: g.setColor(Color.blue);break; //畫正在下落的方塊
case 2: g.setColor(Color.magenta);break; //畫已經落下的方法
}
g.fill3DRect(col*unitSize,getSize().height-(row+1)*unitSize,unitSize,unitSize,true);
g.dispose();
}

public Block getBlock(){
return b; //返回block實例的引用
}

//返回屏幕數組中(row,col)位置的屬性值
public int getScrArrXY(int row,int col){
if (row < 0 || row >= rowNum || col < 0 || col >= columnNum)
return(-1);
else
return(scrArr[row][col]);
}

//返回新塊的初始行坐標方法
public int getInitRow(){
return(blockInitRow); //返回新塊的初始行坐標
}

//返回新塊的初始列坐標方法
public int getInitCol(){
return(blockInitCol); //返回新塊的初始列坐標
}

//滿行刪除方法
void deleteFullLine(){
int full_line_num = 0;
int k = 0;
for (int i=0;i<rowNum;i++){
boolean isfull = true;

L1:for(int j=0;j<columnNum;j++)
if(scrArr[i][j] == 0){
k++;
isfull = false;
break L1;
}
if(isfull) full_line_num++;
if(k!=0 && k-1!=i && !isfull)
for(int j = 0; j < columnNum; j++){
if (scrArr[i][j] == 0)
drawUnit(k-1,j,0);
else
drawUnit(k-1,j,2);
scrArr[k-1][j] = scrArr[i][j];
}
}
for(int i = k-1 ;i < rowNum; i++){
for(int j = 0; j < columnNum; j++){
drawUnit(i,j,0);
scrArr[i][j]=0;
}
}
computer.score += full_line_num;
computer.scoreField.setText(""+computer.score);
}

//判斷游戲是否結束方法
boolean isGameEnd(){
for (int col = 0 ; col <columnNum; col ++){
if(scrArr[maxAllowRowNum][col] !=0)
return true;
}
return false;
}

public void keyTyped(KeyEvent e){
}

public void keyReleased(KeyEvent e){
}

//處理鍵盤輸入的方法
public void keyPressed(KeyEvent e){
if(!computer.isPlay)
return;
switch(e.getKeyCode()){
case KeyEvent.VK_DOWN:b.fallDown();break;
case KeyEvent.VK_LEFT:b.leftMove();break;
case KeyEvent.VK_RIGHT:b.rightMove();break;
case KeyEvent.VK_SPACE:b.leftTurn();break;
}
}
}

//處理控制類
class Command implements ActionListener{
static final int button_play = 1; //給按鈕分配編號
static final int button_levelup = 2;
static final int button_leveldown = 3;
static final int button_quit = 4;
static final int button_pause = 5;
static boolean pause_resume = true;

int curButton; //當前按鈕
GameCanvas scr;

//控制按鈕類的構造方法
Command(int button,GameCanvas scr){
curButton = button;
this.scr=scr;
}

//按鈕執行方法
public void actionPerformed (ActionEvent e){
switch(curButton){
case button_play:if(!computer.isPlay){
scr.initScr();
computer.isPlay = true;
computer.score = 0;
computer.scoreField.setText("0");
computer.timer.resume();
}
scr.requestFocus();
break;
case button_levelup:if(computer.level < 10){
computer.level++;
computer.levelField.setText(""+computer.level);
computer.score = 0;
computer.scoreField.setText(""+computer.score);
}
scr.requestFocus();
break;
case button_leveldown:if(computer.level > 1){
computer.level--;
computer.levelField.setText(""+computer.level);
computer.score = 0;
computer.scoreField.setText(""+computer.score);
}
scr.requestFocus();
break;
case button_pause:if(pause_resume){
computer.timer.suspend();
pause_resume = false;
}else{
computer.timer.resume();
pause_resume = true;
}
scr.requestFocus();
break;
case button_quit:System.exit(0);
}
}
}

//方塊類
class Block {
static int[][] pattern = {
{0x0f00,0x4444,0x0f00,0x4444},//用十六進至表示,本行表示長條四種狀態
{0x04e0,0x0464,0x00e4,0x04c4},
{0x4620,0x6c00,0x4620,0x6c00},
{0x2640,0xc600,0x2640,0xc600},
{0x6220,0x1700,0x2230,0x0740},
{0x6440,0x0e20,0x44c0,0x8e00},
{0x0660,0x0660,0x0660,0x0660}
};
int blockType; //塊的模式號(0-6)
int turnState; //塊的翻轉狀態(0-3)
int blockState; //快的下落狀態
int row,col; //塊在畫布上的坐標
GameCanvas scr;

//塊類的構造方法
Block(GameCanvas scr){
this.scr = scr;
blockType = (int)(Math.random() * 1000)%7;
turnState = (int)(Math.random() * 1000)%4;
blockState = 1;
row = scr.getInitRow();
col = scr.getInitCol();
}

//重新初始化塊,並顯示新塊
public void reset(){
blockType = (int)(Math.random() * 1000)%7;
turnState = (int)(Math.random() * 1000)%4;
blockState = 1;
row = scr.getInitRow();
col = scr.getInitCol();
dispBlock(1);
}

//實現「塊」翻轉的方法
public void leftTurn(){
if(assertValid(blockType,(turnState + 1)%4,row,col)){
dispBlock(0);
turnState = (turnState + 1)%4;
dispBlock(1);
}
}

//實現「塊」的左移的方法
public void leftMove(){
if(assertValid(blockType,turnState,row,col-1)){
dispBlock(0);
col--;
dispBlock(1);
}
}

//實現塊的右移
public void rightMove(){
if(assertValid(blockType,turnState,row,col+1)){
dispBlock(0);
col++;
dispBlock(1);
}
}

//實現塊落下的操作的方法
public boolean fallDown(){
if(blockState == 2)
return(false);
if(assertValid(blockType,turnState,row-1,col)){
dispBlock(0);
row--;
dispBlock(1);
return(true);
}else{
blockState = 2;
dispBlock(2);
return(false);
}
}

//判斷是否正確的方法
boolean assertValid(int t,int s,int row,int col){
int k = 0x8000;
for(int i = 0; i < 4; i++){
for(int j = 0; j < 4; j++){
if((int)(pattern[t][s]&k) != 0){
int temp = scr.getScrArrXY(row-i,col+j);
if (temp<0||temp==2)
return false;
}
k = k >> 1;
}
}
return true;
}

//同步顯示的方法
public synchronized void dispBlock(int s){
int k = 0x8000;
for (int i = 0; i < 4; i++){
for(int j = 0; j < 4; j++){
if(((int)pattern[blockType][turnState]&k) != 0){
scr.drawUnit(row-i,col+j,s);
}
k=k>>1;
}
}
}
}

//定時線程
class MyTimer extends Thread{
GameCanvas scr;

public MyTimer(GameCanvas scr){
this.scr = scr;
}

public void run(){
while(true){
try{
sleep((10-computer.level + 1)*100);
}
catch(InterruptedException e){}
if(!scr.getBlock().fallDown()){
scr.deleteFullLine();
if(scr.isGameEnd()){
computer.isPlay = false;
suspend();
}else
scr.getBlock().reset();
}
}
}
}

class WinListener extends WindowAdapter{
public void windowClosing (WindowEvent l){
System.exit(0);
}
}

㈣ 在KRKR製作的游戲中加入c++編寫的俄羅斯方塊怎麼做

不用c++吧 krkr本身就有自己的編程語言tjs,可以使用tjs來編寫小游戲。
俄羅斯方塊記得kcddp有範例 你可以去看看

㈤ 用Visual C++6.0怎麼製作俄羅斯方塊啊,高人指點一下

這個問題問的很有創意:對於使用VC6.0的用戶,只要切換到classview視圖,然後右擊就好了,很強大的,你試試。對於VS2008,那就更強大了,除了裡面的代碼不能這么搞之外,什麼函數定義啊,變數定義,畫類視圖關系關系圖之類的都能給你搞了,應該根本不需要別的輔助設計軟體了

㈥ 用FLASH製作俄羅斯方塊按「新游戲」時不能清除已堆下來的方塊

你現在是怎麼處理的?把你現在的處理方法簡單說一下,再說一說症狀是什麼? 幫你想想是哪裡的問題.

如果你已經能做俄羅斯方塊的演算法了,已經不是初學者了,相信如果有問題也不是很表面的初級問題了哦

㈦ java俄羅斯方塊製作方法 全面哦

代碼多了,傳不過去 分開給你傳吧
還是發你郵箱吧
下面是一部分代碼

代碼如下:
package com.tarena.tetris;//包名倒寫
//導包
import java.awt.image.BufferedImage;
/**
* 格子類
*/
public class Cell {
//1定義屬性
private int row;//行
private int col;//列
private BufferedImage image;//圖片
//2構造器
public Cell(int row, int col, BufferedImage image) {
super();
this.row = row;
this.col = col;
this.image = image;
}
//3屬性訪問方法
public int getRow() {
return row;
}
public void setRow(int row) {
this.row = row;
}
public int getCol() {
return col;
}
public void setCol(int col) {
this.col = col;
}
public BufferedImage getImage() {
return image;
}
public void setImage(BufferedImage image) {
this.image = image;
}
//5移動方法
public void drop() {
row++;
}
public void moveLeft() {
col--;
}
public void moveRight() {
col++;
}
//4重寫toString
public String toString() {
return row + "," + col;
}
}

-----------------------------------------------------------------------
package com.tarena.tetris;//包名倒寫
//導包
import java.util.Arrays;
import java.util.Random;
/**
* 四格方塊類:包含七個子類T I J L S Z O
*/
public abstract class Tetromino {
//1創建四個格子
protected Cell[] cells = new Cell[4];
//9
protected State[] states;//旋轉狀態
protected int index = 10000;//旋轉狀態的序號 state[index%state.length]
//8旋轉 內部類
protected class State {
int row0,col0,row1,col1,row2,col2,row3,col3;//轉一圈 8個數
//構造器
public State(int row0, int col0, int row1, int col1, int row2,
int col2, int row3, int col3) {
super();
this.row0 = row0;
this.col0 = col0;
this.row1 = row1;
this.col1 = col1;
this.row2 = row2;
this.col2 = col2;
this.row3 = row3;
this.col3 = col3;
}
}
//10
/** 向右轉 */
public void rotateRight() {
//1取得變換的下個數據狀態state[n]
index++;
State s = states[index%states.length];
//2取得當前軸的row,col
Cell o = cells[0];
int row = o.getRow();
int col = o.getCol();
//3旋轉以後的數據=(row,col) + state[n]
cells[1].setRow(row + s.row1);
cells[1].setCol(col + s.col1);
cells[2].setRow(row + s.row2);
cells[2].setCol(col + s.col2);
cells[3].setRow(row + s.row3);
cells[3].setCol(col + s.col3);
}
//11
/** 向左轉 */
public void rotateLeft() {
//1取得變換的下個數據狀態state[n]
index--;
State s = states[index%states.length];
//2取得當前軸的row,col
Cell o = cells[0];
int row = o.getRow();
int col = o.getCol();
//3旋轉以後的數據=(row,col) + state[n]
cells[1].setRow(row + s.row1);
cells[1].setCol(col + s.col1);
cells[2].setRow(row + s.row2);
cells[2].setCol(col + s.col2);
cells[3].setRow(row + s.row3);
cells[3].setCol(col + s.col3);
}
//2工廠方法,隨機產生四個格子
public static Tetromino randomOne() {
//4隨機產生七種四格方塊
Random random = new Random();
int type = random.nextInt(7);
switch(type) {
case 0 : return new T();
case 1 : return new I();
case 2 : return new J();
case 3 : return new L();
case 4 : return new S();
case 5 : return new Z();
case 6 : return new O();
}
return null;
}
//5移動方法
public void softDrop() {
for(int i=0; i<cells.length; i++) {//迭代每一個方塊
cells[i].drop();//使每一個方塊下落
}
}
public void moveLeft() {
for(int i=0; i<cells.length; i++) {//迭代每一個方塊
cells[i].moveLeft();//使每一個方塊左移
}
}
public void moveRight() {
for(int i=0; i<cells.length; i++) {//迭代每一個方塊
cells[i].moveRight();//使每一個方塊右移
}
}
//6重寫toString
public String toStrig() {
return Arrays.toString(cells);
}
}
//3創建子類T繼承父類Tetromino
class T extends Tetromino {
//7
public T() {
cells[0] = new Cell(0,4,Tetris.T);
cells[1] = new Cell(0,3,Tetris.T);
cells[2] = new Cell(0,5,Tetris.T);
cells[3] = new Cell(1,4,Tetris.T);
//12
states = new State[4];
states[0] = new State(0,0, 0,-1, 0,1, 1,0);
states[1] = new State(0,0, -1,0, 1,0, 0,-1);
states[2] = new State(0,0, 0,1, 0,-1, -1,0);
states[3] = new State(0,0, 1,0, -1,0, 0,1);
}
}
//3創建子類I繼承父類Tetromino
class I extends Tetromino {
//7
public I() {
cells[0] = new Cell(0,4,Tetris.I);
cells[1] = new Cell(0,3,Tetris.I);
cells[2] = new Cell(0,5,Tetris.I);
cells[3] = new Cell(0,6,Tetris.I);
//12
states = new State[] {new State(0,0, 0,1, 0,-1, 0,-2),
new State(0,0, -1,0, 1,0, 2,0)};
}
}
//3創建子類J繼承父類Tetromino
class J extends Tetromino {
//7
public J() {
cells[0] = new Cell(0,4,Tetris.J);
cells[1] = new Cell(0,3,Tetris.J);
cells[2] = new Cell(0,5,Tetris.J);
cells[3] = new Cell(1,5,Tetris.J);
//12
states = new State[]{
new State(0,0, 0,-1, 0,1, 1,1),
new State(0,0, -1,0, 1,0, 1,-1),
new State(0,0, 0,1, 0,-1, -1,-1),
new State(0,0, 1,0, -1,0, -1,1)};
}
}
//3創建子類L繼承父類Tetromino
class L extends Tetromino {
//7
public L() {
cells[0] = new Cell(0,4,Tetris.L);
cells[1] = new Cell(0,3,Tetris.L);
cells[2] = new Cell(0,5,Tetris.L);
cells[3] = new Cell(1,3,Tetris.L);
//12
states = new State[]{
new State(0,0, 0,-1, 0,1, 1,-1),
new State(0,0, -1,0, 1,0, -1,-1),
new State(0,0, 0,1, 0,-1, -1,1),
new State(0,0, 1,0, -1,0, 1,1)};
}
}
//3創建子類S繼承父類Tetromino
class S extends Tetromino {
//7
public S() {
cells[0] = new Cell(0,4,Tetris.S);
cells[1] = new Cell(0,5,Tetris.S);
cells[2] = new Cell(1,3,Tetris.S);
cells[3] = new Cell(1,4,Tetris.S);
//12
states = new State[]{
new State(0,0, 0,1, 1,-1, 1,0),
new State(0,0, -1,0, 1,1, 0,1)};
}
}
//3創建子類Z繼承父類Tetromino
class Z extends Tetromino {
//7
public Z() {
cells[0] = new Cell(1,4,Tetris.Z);
cells[1] = new Cell(0,3,Tetris.Z);
cells[2] = new Cell(0,4,Tetris.Z);
cells[3] = new Cell(1,5,Tetris.Z);
//12
states = new State[]{
new State(0,0, -1,-1, -1,0, 0,1),
new State(0,0, -1,1, 0,1, 1,0)};
}
}
//3創建子類O繼承父類Tetromino
class O extends Tetromino {
//7
public O() {
cells[0] = new Cell(0,4,Tetris.O);
cells[1] = new Cell(0,5,Tetris.O);
cells[2] = new Cell(1,4,Tetris.O);
cells[3] = new Cell(1,5,Tetris.O);
//12
states = new State[]{
new State(0,0, 0,1, 1,0, 1,1),
new State(0,0, 0,1, 1,0, 1,1)};
}
}

㈧ 求俄羅斯方塊的製作動畫

當然可以實現了,先提供給你一個方法,即在你的視頻里插一個Flash動畫,這個動畫按照你的要求去做。
這只是其中的一個方法,還有n個方法。

㈨ 怎樣製作俄羅斯方塊

以下代碼粘貼在主場經第一禎,測試影片就看到了:
N = 20;//行數
WIDTH = 20;//方塊邊長
level = 0;//開始等級(下落速度)
ret = new Array();//當前出現的方塊
nextret = new Array();//下一個出現的方塊
bg = new Array();//背景數組
createEmptyMovieClip("panel", 1048575);//所有方塊都在此mc里
for (i = 0; i < 5; i++) {
//初始化方塊數組,2*5格式,前四行代表每個方塊的4個小塊的位置坐標,最後一行第一列是方塊形狀,第二列是方塊旋轉方向
ret.push(new Array(2));
nextret.push(new Array(2));
}
for (i = 0; i < 20; i++) {//初始化背景數組,10*20格式
bg.push(new Array(10));
}
X = Y = panel._x = panel._y = 0;//換為X、Y表示
function reach(x:Number, y:Number, ret:Object) {
//x、y為方塊位置,ret為方塊形狀,若方塊ret下落一格碰到邊界或者方塊返回1
var i:Number, j:Number, k:Number;
for (i = 0; i < N; i++) {
for (j = 0; j < 10; j++) {
if (bg[i][j] == 219) {
for (k = 0; k < 4; k++) {
if (x + ret[k][0] == j && y + ret[k][1] + 1 == i) {
return 1;
}
}
}
}
}
return 0;
}
function lrnotout(lorr:Number, a:Object) {
//lorr==-1代表a往左邊一格可行性的判斷,lorr==1代表右邊一格可行性的判斷,lorr==0代表a的位置合理性的判斷,出現不合理則返回0
var i:Number;
if (lorr == -1) {
for (i = 0; i < 4; i++) {
if (x + a[i][0] - 1 < 0 || reach(x - 1, y - 1, a)) {
return 0;
}
}
}
if (lorr == 1) {
for (i = 0; i < 4; i++) {
if (x + a[i][0] + 1 > 9 || reach(x - 1, y + 1, a)) {
return 0;
}
}
}
if (lorr == 0) {
for (i = 0; i < 4; i++) {
if (x + a[i][0] < 0 || x + a[i][0] > 9) {
return 0;
}
}
}
return 1;
}
function rv(a:Object, ret:Object) {
//方塊賦值,將a方塊賦值到ret方塊
var i:Number;
for (i = 0; i < 5; i++) {
ret[i][0] = a[i][0], ret[i][1] = a[i][1];
}
}
function rotate(ret:Object) {
//根據方塊ret最後一行(分別是形狀指示變數和旋轉方向變數)為ret的前四行賦以具體形狀值
switch (ret[4][0]) {
case 0 ://方形
a = [[1, 0], [2, 0], [1, 1], [2, 1], [0, 0]];
rv(a, ret);
return;
case 1 ://長形
switch (ret[4][1]) {
case 1 :
a = [[0, 0], [1, 0], [2, 0], [3, 0], [1, 0]];
if (lrnotout(0, a) && !reach(x, y - 1, a)) {
rv(a, ret);
}
return;
case 0 :
a = [[1, 0], [1, 1], [1, 2], [1, 3], [1, 1]];
if (lrnotout(0, a) && !reach(x, y - 1, a)) {
rv(a, ret);
}
return;
}
case 2 ://Z形
switch (ret[4][1]) {
case 1 :
a = [[0, 1], [1, 1], [1, 2], [2, 2], [2, 0]];
if (lrnotout(0, a) && !reach(x, y - 1, a)) {
rv(a, ret);
}
return;
case 0 :
a = [[2, 0], [1, 1], [2, 1], [1, 2], [2, 1]];
if (lrnotout(0, a) && !reach(x, y - 1, a)) {
rv(a, ret);
}
return;
}
case 3 ://反Z形
switch (ret[4][1]) {
case 1 :
a = [[1, 1], [2, 1], [0, 2], [1, 2], [3, 0]];
if (lrnotout(0, a) && !reach(x, y - 1, a)) {
rv(a, ret);
}
return;
case 0 :
a = [[1, 0], [1, 1], [2, 1], [2, 2], [3, 1]];
if (lrnotout(0, a) && !reach(x, y - 1, a)) {
rv(a, ret);
}
return;
}
case 4 ://T形
switch (ret[4][1]) {
case 3 :
a = [[1, 0], [0, 1], [1, 1], [2, 1], [4, 0]];
if (lrnotout(0, a) && !reach(x, y - 1, a)) {
rv(a, ret);
}
return;
case 0 :
a = [[1, 0], [0, 1], [1, 1], [1, 2], [4, 1]];
if (lrnotout(0, a) && !reach(x, y - 1, a)) {
rv(a, ret);
}
return;
case 1 :
a = [[0, 1], [1, 1], [2, 1], [1, 2], [4, 2]];
if (lrnotout(0, a) && !reach(x, y - 1, a)) {
rv(a, ret);
}
return;
case 2 :
a = [[1, 0], [1, 1], [2, 1], [1, 2], [4, 3]];
if (lrnotout(0, a) && !reach(x, y - 1, a)) {
rv(a, ret);
}
return;
}
case 5 ://倒L形
switch (ret[4][1]) {
case 3 :
a = [[1, 0], [2, 0], [1, 1], [1, 2], [5, 0]];
if (lrnotout(0, a) && !reach(x, y - 1, a)) {
rv(a, ret);
}
return;
case 0 :
a = [[0, 1], [0, 2], [1, 2], [2, 2], [5, 1]];
if (lrnotout(0, a) && !reach(x, y - 1, a)) {
rv(a, ret);
}
return;
case 1 :
a = [[2, 0], [2, 1], [1, 2], [2, 2], [5, 2]];
if (lrnotout(0, a) && !reach(x, y - 1, a)) {
rv(a, ret);
}
return;
case 2 :
a = [[0, 1], [1, 1], [2, 1], [2, 2], [5, 3]];
if (lrnotout(0, a) && !reach(x, y - 1, a)) {
rv(a, ret);
}
return;
}
case 6 ://L形
switch (ret[4][1]) {
case 3 :
a = [[1, 0], [2, 0], [2, 1], [2, 2], [5, 0]];
if (lrnotout(0, a) && !reach(x, y - 1, a)) {
rv(a, ret);
}
return;
case 0 :
a = [[0, 1], [1, 1], [2, 1], [0, 2], [5, 1]];
if (lrnotout(0, a) && !reach(x, y - 1, a)) {
rv(a, ret);
}
return;
case 1 :
a = [[1, 0], [1, 1], [1, 2], [2, 2], [5, 2]];
if (lrnotout(0, a) && !reach(x, y - 1, a)) {
rv(a, ret);
}
return;
case 2 :
a = [[2, 1], [0, 2], [1, 2], [2, 2], [5, 3]];
if (lrnotout(0, a) && !reach(x, y - 1, a)) {
rv(a, ret);
}
return;
}
}
}
function generate(ret:Object) {//隨機產生方塊函數(可進一步修正)
ret[4][0] = Math.floor(Math.random() * 7);
ret[4][1] = Math.floor(Math.random() * 4);
rotate(ret);//完成方塊ret的具體形狀的賦值
}
function init() {//初始化背景、方塊、運動函數
var i:Number, j:Number;
for (i = 0; i < N; i++) {//初始化背景,邊界為219,其餘為' '
for (j = 0; j < 10; j++) {
if (i == N - 1) {
bg[i][j] = 219;
} else {
bg[i][j] = ' ';
}
}
}
for (i = 0; i < 5; i++) {//為當前方塊賦初值0
ret[i][0] = ret[i][1] = 0;
}
generate(ret);//產生當前方塊
generate(nextret);//產生下一個方塊
y = 0, x = 3, score = lines = 0, level=0;//當前位置坐標和計分系統初始化
_tetris.removeTextField();//如果從結束過的游戲恢復,刪除結束標志
display();//顯示畫面
frameflag = 0;//標示下落時間間隔
onEnterFrame = function () {
frameflag++;
if (10 - frameflag < level) {//根據等級level確定下落時間間隔
frameflag = 0;
go();//下落及判斷
}
};
}
function drawblock(a, b, c, d) {//繪制方塊的小塊
with (panel) {
beginFill(0x000FFF, 100);
lineStyle(1, 0xFF00FF);
moveTo(panel._x + a, panel._y + b);
lineTo(panel._x + c, panel._y + b);
lineTo(panel._x + c, panel._y + d);
lineTo(panel._x + a, panel._y + d);
lineTo(panel._x + a, panel._y + b);
endFill();
}
}
function erase() {//刪除一行方塊
var n:Number = 0, i:Number, j:Number, k:Number, l:Number;
for (i = 0; i < N - 1; i++) {
for (j = 0; j < 10; j++) {
if (bg[i][j] == ' ') {//如果該行有空,則開始判斷下一行
i++, j = -1;
if (i == N - 1) {//行N-1為底線,不判斷
break;
}
} else if (j == 9) {//判斷到該行最後一列都沒有空
for (k = i; k >= 1; k--) {//上方方塊下落
for (l = 0; l < 10; l++) {
bg[k][l] = bg[k - 1][l];
}
}
for (l = 0; l < 10; l++) {//刪除該行
bg[0][l] = ' ';
}
n++;//此次刪除行數變數增一
if ((lines + n) % 30 == 0) {//刪除行數總數到30的倍數則等級上升
level = (level + 1) % 10;
}
}
}
}
lines += n, score += (n * n + n) * 50;//總行數增n,計算得分
}
function display() {
//顯示函數,採用全部清除再重繪制的方法(因為這個程序本來是在Turbo C 2.0的文本環境下完成的)
var i:Number, j:Number;
panel.clear();
with (panel) {//畫邊界
lineStyle(1, 0x0000FF);
moveTo(panel._x, panel._y);
lineTo(panel._x + WIDTH * 10, panel._y);
lineTo(panel._x + WIDTH * 10, panel._y + WIDTH * (N - 1));
lineTo(panel._x, panel._y + WIDTH * (N - 1));
lineTo(panel._x, panel._y);
}
for (i = 0; i < 4; i++) {//當前方塊占據的地方賦值為邊界類型219
bg[y + ret[i][1]][x + ret[i][0]] = 219;
}
for (i = 0; i < N - 1; i++) {//繪制背景方塊
for (j = 0; j < 10; j++) {
if (bg[i][j] == 219) {
drawblock(j * WIDTH + X, i * WIDTH + Y, j * WIDTH + WIDTH + X, i * WIDTH + WIDTH + Y);
}
}
}
for (i = 0; i < 4; i++) {//繪制當前方塊
drawblock(nextret[i][0] * WIDTH + 14 * WIDTH + X, nextret[i][1] * WIDTH + 12 * WIDTH + Y, nextret[i][0] * WIDTH + WIDTH + 14 * WIDTH + X, nextret[i][1] * WIDTH + WIDTH + 12 * WIDTH + Y);
}
for (i = 0; i < 4; i++) {//當前方塊繪制完畢,重新將當前位置改為' '
bg[y + ret[i][1]][x + ret[i][0]] = ' ';
}
createTextField("_lvltxt", 1, 270, 100, 100, 20);//繪制計分系統
createTextField("_scrtxt", 2, 270, 130, 100, 20);
createTextField("_lnstxt", 3, 270, 160, 100, 20);
_lvltxt.text = "Level: " + level;
_scrtxt.text = "Score: " + score;
_lnstxt.text = "Lines: " + lines;
}
function go() {//下落函數
var sss:Number = reach(x, y, ret);//當前方塊下落一格是否碰到邊界或方塊
var ii:Number;
if (!sss) {
y++;//如果當前方塊下落一格沒有碰到邊界或方塊則下落一格
}
display();//重新繪制
if (sss) {//碰到邊界或方塊
score += 10;//得10分
display();//重新繪制
for (ii = 0; ii < 4; ii++) {//修改背景數組,將當前方塊的位置改為邊界類型
bg[y + ret[ii][1]][x + ret[ii][0]] = 219;
}
erase();//刪除行判斷及執行
rv(nextret, ret);//將下一個方塊賦值為當前方塊
y = 0, x = 3;//重置方塊位置
generate(nextret);//生成下一個方塊
display();//重新繪制
if (reach(x, y, ret)) {//如果下一格碰到方塊則游戲結束
createTextField("_tetris", 100000, WIDTH * 3.3, WIDTH * N / 3, 70, 20);
_tetris._x += 200;
_tetris._y += 50;
_tetris._xscale = 300;
_tetris._yscale = 300;
_tetris.background = true;
_tetris.text = "Game Over!";
onEnterFrame = function () {//停止下落
};
}
}
}
function key() {
if (Key.isDown(Key.UP)) {
rotate(ret);
display();
}
if (Key.isDown(Key.LEFT)) {
if (lrnotout(-1, ret)) {//左移可行性判斷
x--;
display();
}
}
if (Key.isDown(Key.RIGHT)) {
if (lrnotout(1, ret)) {//右移可行性判斷
x++;
display();
}
}
if (Key.isDown(Key.DOWN)) {//鍵盤控制下落
go();
}
if (Key.isDown(Key.SPACE)) {//一鍵下落到底
while (!reach(x, y, ret)) {
y++;
}
go();
}
if (Key.isDown(82)) { //重新開始游戲
init();
}
}
init();//初始化
setInterval(key, 80);//每個80毫秒執行一次鍵盤事件函數
createTextField("hinttxt",33324,200,20,300,50);
hinttxt.text="鍵盤鍵:上,下,左,右,R(reset),空格";

閱讀全文

與如何製作俄羅斯方塊綠幕素材相關的資料

熱點內容
金華義烏國際商貿城雨傘在哪個區 瀏覽:591
俄羅斯如何打通飛地立陶宛 瀏覽:927
韓國如何應對流感 瀏覽:756
在德國愛他美白金版賣多少錢 瀏覽:783
澳大利亞養羊業為什麼發達 瀏覽:1175
如何進入法國高等學府 瀏覽:1278
巴西龜喂火腿吃什麼 瀏覽:1209
巴西土地面積多少萬平方千米 瀏覽:1062
巴西龜中耳炎初期要用什麼葯 瀏覽:1034
國際為什麼鋅片如此短缺 瀏覽:1464
巴西是用什麼規格的電源 瀏覽:1256
在中國賣的法國名牌有什麼 瀏覽:1180
在菲律賓投資可用什麼樣的居留條件 瀏覽:1069
德國被分裂為哪些國家 瀏覽:683
澳大利亞跟團簽證要什麼材料 瀏覽:1004
德國大鵝節多少錢 瀏覽:706
去菲律賓過關時會盤問什麼 瀏覽:1021
澳大利亞女王為什麼是元首 瀏覽:831
有什麼免費的韓國小說軟體 瀏覽:584
申請德國學校如何找中介 瀏覽:481