Skip to content

BWbwchen/Rustetris

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RusTetris

This is my practice project for learning Rust programming language.

Architecture of code

The game is mainly controlled by struct Tetris.

struct Tetris {
    nowPiece: Piece,        // now dropping piece
    backGround: Background,
}
#[derive(Copy, Clone, Debug)]
struct Piece {
    piece_type: i32,
    turn: i32,
    x: i32,
    y: i32,
    color: usize,
}
struct Background {
    record: [[bool; TETRIS_WIDTH]; TETRIS_HEIGHT],     // record the occupied block
    color_map: [[usize; TETRIS_WIDTH]; TETRIS_HEIGHT], // color code for each block
}