diff options
Diffstat (limited to '')
-rw-r--r-- | Cargo.lock | 69 | ||||
-rw-r--r-- | Cargo.toml | 1 | ||||
-rw-r--r-- | src/graphics.rs | 61 | ||||
-rw-r--r-- | src/main.rs | 7 |
4 files changed, 136 insertions, 2 deletions
@@ -1,4 +1,73 @@ [[package]] +name = "bitflags" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "csfml-audio-sys" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "csfml-system-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sfml-build 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "csfml-graphics-sys" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "csfml-system-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "csfml-window-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sfml-build 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "csfml-system-sys" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "sfml-build 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "csfml-window-sys" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "csfml-system-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sfml-build 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "sfml" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "csfml-audio-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "csfml-graphics-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "csfml-system-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "csfml-window-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "sfml-build" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] name = "subconscious-rs" version = "0.1.0" +dependencies = [ + "sfml 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", +] +[metadata] +"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" +"checksum csfml-audio-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c3f55bfdd00e6ded8b4bbf62acfe7e62a493584a7b0774642dac59d822061aa4" +"checksum csfml-graphics-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d508c34b7376ca0450422ee11642b5aba43bde59673c822bb436e9fc126d8487" +"checksum csfml-system-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "226869ac0651d7592d2fc0795f5e44101fbd7b22548d6cf6f0e0e74e54efa1fd" +"checksum csfml-window-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "86fd0d9840a9f92ae0960cef634c1b5781b15847dbb099a9ee6021bb5c1cb618" +"checksum sfml 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "47b06f9db4d3f8b936d232d92bfbd6335060ae51ddcf1be2e79361aeb5c8fef1" +"checksum sfml-build 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff35ae173aff95bc967d1b4f0e131a8aec384c317fd057738da4b0f71c8cf841" @@ -5,3 +5,4 @@ authors = ["Nao Pross <naopross@thearcway.org>"] edition = "2018" [dependencies] +sfml = "0.14.0"
\ No newline at end of file diff --git a/src/graphics.rs b/src/graphics.rs index c3917af..ca98946 100644 --- a/src/graphics.rs +++ b/src/graphics.rs @@ -1,5 +1,64 @@ +extern crate sfml; + + +use sfml::window::{ + ContextSettings, + Event, + Style, +}; + +use sfml::graphics::{ + RenderWindow, + RenderTarget, + Color, +}; + + +struct State { + running: bool +} pub fn start() { - + let default_window_size = (1280, 720); + let default_framerate = 80; + + let mut state = State { + running: true + }; + + let context_settings = ContextSettings { + antialiasing_level: 0, + ..Default::default() + }; + + let mut window = RenderWindow::new( + default_window_size, + "Subconscious", + Style::CLOSE, + &context_settings + ); + + window.set_framerate_limit(default_framerate); + window.set_vertical_sync_enabled(true); + + + while state.running { + render(&mut window); + update(&mut window, &mut state); + } +} + +fn render(window: &mut RenderWindow) { + window.clear(&Color::BLACK); + window.display(); +} + +fn update(window: &mut RenderWindow, state: &mut State) { + while let Some(ev) = window.poll_event() { + match ev { + Event::Closed => state.running = false, + _ => {}, + } + } }
\ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 8de52c0..2679ac4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,5 +4,10 @@ mod graphics; fn main() { game::start(); - graphics::start(); + + let graphics_thread = std::thread::spawn(move || { + graphics::start(); + }); + + graphics_thread.join().unwrap(); } |