summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/graphics.rs45
1 files changed, 44 insertions, 1 deletions
diff --git a/src/graphics.rs b/src/graphics.rs
index 68dfa65..18ccfec 100644
--- a/src/graphics.rs
+++ b/src/graphics.rs
@@ -1,6 +1,7 @@
use std::collections::HashMap;
use sfml::system::Vector2f;
+use sfml::window::mouse::Button;
use sfml::window::{
ContextSettings,
@@ -11,6 +12,10 @@ use sfml::window::{
use sfml::graphics::{
RenderWindow,
RenderTarget,
+ View,
+};
+
+use sfml::graphics::{
Texture,
Image,
Color,
@@ -29,7 +34,10 @@ pub struct MapAssets;
#[derive(Debug)]
pub struct Graphics {
+ // sfml elements
window: RenderWindow,
+ view: View,
+ // status
running: bool,
// loaded resources
tilesets: HashMap<u32, Image>,
@@ -46,6 +54,7 @@ impl Graphics {
..Default::default()
};
+ // create window
let mut window = RenderWindow::new(
default_window_size,
"Subconscious",
@@ -56,12 +65,29 @@ impl Graphics {
window.set_framerate_limit(default_framerate);
window.set_vertical_sync_enabled(true);
- return Graphics {
+ let mut graphics = Graphics {
+ // sfml elements
window: window,
+ view: View::new(
+ Vector2f::new(
+ default_window_size.0 as f32 / 2.0,
+ default_window_size.1 as f32 / 2.0
+ ),
+ Vector2f::new(
+ default_window_size.0 as f32,
+ default_window_size.1 as f32,
+ ),
+ ),
+ // status
running: true,
+ // resources
tilesets: HashMap::new(),
textures: HashMap::new(),
};
+
+ graphics.window.set_view(&graphics.view);
+
+ return graphics;
}
pub fn is_running(self: &mut Self) -> bool {
@@ -179,6 +205,23 @@ impl Graphics {
self.window.close();
self.running = false;
},
+ Event::MouseWheelScrolled { wheel: _, delta, x, y } => {
+
+ },
+ Event::MouseButtonPressed { button, x: _, y: _ } => {
+ match button {
+ Button::Left => {},
+ Button::Right => {}
+ _ => {},
+ }
+ },
+ Event::MouseButtonReleased { button, x: _, y: _ } => {
+ match button {
+ Button::Left => {}
+ Button::Right => {},
+ _ => {},
+ }
+ },
_ => {},
}
}