Commit 07ee108f authored by Enrico Ghiorzi's avatar Enrico Ghiorzi

Merge remote-tracking branch 'redox-os/master'

parents 17f0eb21 c4984dc2
Cargo.lock
target
*.swp
[root]
name = "games-for-redox"
version = "0.1.0"
dependencies = [
"extra 0.1.0 (git+https://github.com/redox-os/libextra.git)",
"libgo 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"liner 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"termion 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "extra"
version = "0.1.0"
source = "git+https://github.com/redox-os/libextra.git#461bf1b2b9ea29a6f3dd13d688fdddc02d8b5b6a"
[[package]]
name = "libc"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "libgo"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "liner"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"termion 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-width 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rand"
version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "termion"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "unicode-width"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
......@@ -46,3 +46,7 @@ path = "src/reblox/main.rs"
[[bin]]
name = "baduk"
path = "src/baduk/main.rs"
[[bin]]
name = "commie"
path = "src/commie/main.rs"
......@@ -2,7 +2,7 @@
This repository contains a bunch of minigames running on Redox OS.
[![Travis Build Status](https://travis-ci.org/redox-os/games-for-redox.svg?branch=master)](https://travis-ci.org/redox-os/games-for-redox)
[![Travis Build Status](https://travis-ci.org/redox-os/games.svg?branch=master)](https://travis-ci.org/redox-os/games)
## What we got.
......
extern crate termion;
use termion::{clear, color, cursor};
use std::{time, thread};
const COMMUNISM: &'static str = r#"
!######### #
!########! ##!
!########! ###
!########## ####
######### ##### ######
!###! !####! ######
! ##### ######!
!####! #######
##### #######
!####! #######!
####!########
## ##########
,######! !#############
,#### ########################!####!
,####' ##################!' #####
,####' ####### !####!
####' #####
~## ##~
"#;
fn main() {
let mut state = 0;
println!("\n{}{}{}{}{}{}", cursor::Hide, clear::All, cursor::Goto(1, 1), color::Fg(color::Black), color::Fg(color::Red), COMMUNISM);
loop {
println!("{}{} ☭ GAY ☭ SPACE ☭ COMMUNISM ☭ ", cursor::Goto(1, 1), color::Fg(color::AnsiValue(state)));
println!("{}{} WILL PREVAIL, COMRADES! ", cursor::Goto(1, 20), color::Fg(color::AnsiValue(state)));
state += 1;
state %= 8;
thread::sleep(time::Duration::from_millis(90));
}
}
#![feature(iter_arith)]
#[macro_use]
extern crate extra;
use extra::io::WriteExt;
use std::collections::HashMap;
use std::io::{self, BufRead, Write};
use std::io::{self, BufRead, BufReader, Write};
use std::mem;
/// The number of factors.
......@@ -240,7 +238,7 @@ impl Game {
let stdout = io::stdout();
let mut stdout = stdout.lock();
let mut lines = stdin.lock().lines().map(|x| x.unwrap());
let mut lines = BufReader::new(stdin.lock()).lines().map(|x| x.unwrap());
stdout.writeln("<< Welcome to Dem, the commandline-based Democracy clone. 'help' for help. >>".as_bytes()).unwrap();
loop {
......
......@@ -486,6 +486,7 @@ fn main() {
loop {
// Read the arguments.
// Does not use a for loop because each argument may have second parameter.
let arg = if let Some(x) = args.next() {
x
......@@ -545,6 +546,10 @@ fn main() {
// We go to raw mode to make the control over the terminal more fine-grained.
let stdout = stdout.into_raw_mode().unwrap();
let termsize = termion::terminal_size().ok();
let termwidth = termsize.map(|(w,_)| w - 2);
let termheight = termsize.map(|(_,h)| h - 2);
// Initialize the game!
init(stdout, stdin, diff, width.unwrap_or(70), height.unwrap_or(40));
init(stdout, stdin, diff, width.or(termwidth).unwrap_or(70),
height.or(termheight).unwrap_or(40));
}
#![feature(question_mark)]
extern crate termion;
extern crate extra;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment