Added some constrant definitions

This commit is contained in:
Coeuvre 2014-05-19 20:40:55 +08:00
parent 74bbde0e05
commit 8650bbe9b2
3 changed files with 81 additions and 0 deletions

13
src/app.rs Normal file
View file

@ -0,0 +1,13 @@
use piston::*;
pub struct App;
impl App {
pub fn new() -> App {
App
}
}
impl Game for App {
}

33
src/main.rs Normal file
View file

@ -0,0 +1,33 @@
#![feature(globs)]
extern crate rand;
extern crate graphics;
extern crate piston;
use piston::*;
mod app;
mod settings;
type GameWindowBackEnd = GameWindowSDL2;
fn main() {
let mut game_window: GameWindowBackEnd = GameWindow::new(
GameWindowSettings::new (
"Rust-2048".to_owned(),
settings::WINDOW_SIZE,
false,
true,
settings::WINDOW_BACKGROUND_COLOR,
)
);
let mut asset_store = AssetStore::from_folder(settings::ASSET_FOLDER);
let mut app = app::App::new();
app.run(&mut game_window, &mut asset_store);
}

35
src/settings.rs Normal file
View file

@ -0,0 +1,35 @@
pub static ASSET_FOLDER: &'static str = "assets";
pub static WINDOW_SIZE: [u32, ..2] = [400, 400];
pub static WINDOW_BACKGROUND_COLOR: [f32, ..4] = [250.0 / 255.0, 248.0 / 255.0, 239.0 / 255.0, 1.0];
pub static WINDOW_PADDING: f64 = 12.0;
pub static TILE_SIZE: [f64, ..2] = [72.0, 72.0];
pub static TILE_PADDING: f64 = 12.0;
pub static TILE_BACKGROUND_COLOR: [f32, ..4] = [187.0 / 255.0, 173.0 / 255.0, 160.0 / 255.0, 1.0];
pub static TILES_COLOR: [[f32, ..4], ..12] = [
/// empty color
[204.0 / 255.0, 192.0 / 255.0, 179.0 / 255.0, 1.0],
/// 2 color
[238.0 / 255.0, 228.0 / 255.0, 218.0 / 255.0, 1.0],
/// 4 color
[237.0 / 255.0, 224.0 / 255.0, 200.0 / 255.0, 1.0],
/// 8 color
[242.0 / 255.0, 177.0 / 255.0, 121.0 / 255.0, 1.0],
/// 16 color
[245.0 / 255.0, 149.0 / 255.0, 99.0 / 255.0, 1.0],
/// 32 color
[246.0 / 255.0, 124.0 / 255.0, 95.0 / 255.0, 1.0],
/// 64 color
[246.0 / 255.0, 94.0 / 255.0, 59.0 / 255.0, 1.0],
/// 128 color
[237.0 / 255.0, 207.0 / 255.0, 114.0 / 255.0, 1.0],
/// 256 color
[237.0 / 255.0, 204.0 / 255.0, 97.0 / 255.0, 1.0],
/// 512 color
[237.0 / 255.0, 200.0 / 255.0, 80.0 / 255.0, 1.0],
]
pub static LABEL_COLOR: [f32, ..4] = [187.0 / 255.0, 173.0 / 255.0, 160.0 / 255.0, 1.0];
pub static BUTTON_COLOR: [f32, ..4] = [142.0 / 255.0, 122.0 / 255.0, 102.0 / 255.0, 1.0];