Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![feature(rustc_private)]
- extern crate rand;
- use rand::Rng;
- fn main() {}
- #[derive(Debug)]
- pub struct Tetris {
- shapetype:Shape,
- shape: [[u8;4];4]
- }
- pub struct ActiveTetris {
- tetris: &'static Tetris,
- }
- impl Tetris {
- pub fn create_Tetris() -> ActiveTetris {
- // 生成1到100之间的数字
- // let secret_number = rand::thread_rng().gen_range(1, 101);
- ActiveTetris{
- tetris:rand::thread_rng().choose(&TETRIS_LIST).unwrap(),
- }
- }
- }
- /// The set of available colors for use with a Windows console.
- #[derive(Clone, Copy, Debug, Eq, PartialEq)]
- pub enum Dir {
- UP,DOWN,LEFT,RIGHT,None
- }
- #[derive(Clone, Copy, Debug, Eq, PartialEq)]
- pub enum Shape {
- LONG1,LONG2,SQUARE,OBLIQUE1,OBLIQUE2,TIP1,TIP2,TIP3,TIP4,FORK1,FORK2,FORK3,FORK4
- }
- pub static TETRIS_LIST:[Tetris;13] = [
- Tetris {
- shapetype:Shape::LONG1,
- shape: [[0,0,1,0],
- [0,0,1,0],
- [0,0,1,0],
- [0,0,1,0]] // 长形
- },
- Tetris {
- shapetype:Shape::LONG2,
- shape: [[0,0,0,0],
- [0,0,0,0],
- [0,0,0,0],
- [1,1,1,1]] // 长形
- },
- Tetris {
- shapetype:Shape::SQUARE,
- shape: [[0,0,0,0],
- [0,0,0,0],
- [0,1,1,0],
- [0,1,1,0]] // 方形
- },
- Tetris {
- shapetype:Shape::OBLIQUE1,
- shape: [[0,0,0,0],
- [0,1,0,0],
- [0,1,1,0],
- [0,0,1,0]] // 斜形
- },
- Tetris {
- shapetype:Shape::OBLIQUE2,
- shape: [[0,0,0,0],
- [0,0,0,0],
- [0,0,1,1],
- [0,1,1,0]] // 斜形
- },
- Tetris {
- shapetype:Shape::TIP1,
- shape: [[0,0,0,0],
- [0,1,0,0],
- [0,1,1,0],
- [0,1,0,0]] // 尖形
- },
- Tetris {
- shapetype:Shape::TIP2,
- shape: [[0,0,0,0],
- [0,0,0,0],
- [0,1,0,0],
- [1,1,1,0]] // 尖形
- },
- Tetris {
- shapetype:Shape::TIP3,
- shape: [[0,0,0,0],
- [0,0,1,0],
- [0,1,1,0],
- [0,0,1,0]] // 尖形
- },
- Tetris {
- shapetype:Shape::TIP4,
- shape: [[0,0,0,0],
- [0,0,0,0],
- [1,1,1,0],
- [0,1,0,0]] // 尖形
- },
- Tetris {
- shapetype:Shape::FORK1,
- shape: [[0,0,0,0],
- [0,1,1,0],
- [0,0,1,0],
- [0,0,1,0]] // 叉形
- },
- Tetris {
- shapetype:Shape::FORK2,
- shape: [[0,0,0,0],
- [0,0,1,0],
- [1,1,1,0],
- [0,0,0,0]] // 叉形
- },
- Tetris {
- shapetype:Shape::FORK3,
- shape: [[0,0,0,0],
- [0,1,0,0],
- [0,1,0,0],
- [0,1,1,0]] // 叉形
- },
- Tetris {
- shapetype:Shape::FORK4,
- shape: [[0,0,0,0],
- [0,1,1,1],
- [0,1,0,0],
- [0,0,0,0]] // 叉形
- },
- ];
Add Comment
Please, Sign In to add comment