summaryrefslogtreecommitdiff
path: root/pixel-client/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'pixel-client/src/main.rs')
-rw-r--r--pixel-client/src/main.rs34
1 files changed, 3 insertions, 31 deletions
diff --git a/pixel-client/src/main.rs b/pixel-client/src/main.rs
index db2585af..7501aba2 100644
--- a/pixel-client/src/main.rs
+++ b/pixel-client/src/main.rs
@@ -15,10 +15,9 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-use anyhow::anyhow;
use clap::{Parser, Subcommand};
use game::Game;
-use hurrycurry_protocol::glam::{UVec2, Vec2};
+use hurrycurry_protocol::glam::Vec2;
use menu::Menu;
use network::Network;
use render::SpriteRenderer;
@@ -27,10 +26,7 @@ use sdl2::{
keyboard::{KeyboardState, Keycode},
pixels::Color,
};
-use std::{
- str::FromStr,
- time::{Duration, Instant},
-};
+use std::time::{Duration, Instant};
pub mod game;
pub mod helper;
@@ -41,9 +37,6 @@ pub mod tilemap;
#[derive(Debug, Parser)]
pub struct Args {
- #[arg(short = 'r', long, default_value = "320x240")]
- logical_resolution: Resolution,
-
#[clap(subcommand)]
action: Option<Action>,
}
@@ -58,16 +51,6 @@ pub enum Action {
},
}
-#[derive(Debug, Clone)]
-struct Resolution(UVec2);
-impl FromStr for Resolution {
- type Err = anyhow::Error;
- fn from_str(s: &str) -> Result<Self, Self::Err> {
- let (x, y) = s.split_once("x").ok_or(anyhow!("sep missing"))?;
- Ok(Resolution(UVec2::new(x.parse()?, y.parse()?)))
- }
-}
-
enum State {
Ingame(Game),
Menu(Menu),
@@ -83,7 +66,6 @@ fn main() {
.unwrap();
let sdl_context = sdl2::init().unwrap();
- let ttf_context = sdl2::ttf::init().unwrap();
let video_subsystem = sdl_context.video().unwrap();
let window = video_subsystem
@@ -113,22 +95,12 @@ fn main() {
)),
};
- // let font = ttf_context
- // .load_font("/usr/share/fonts/noto/NotoSansMono-Regular.ttf", 24)
- // .unwrap();
- // let text = font.render("Hello world").blended(Color::WHITE).unwrap();
- // texture_creator.create_texture_from_surface(text).unwrap();
-
let mut events = sdl_context.event_pump().unwrap();
let mut last_tick = Instant::now();
- canvas
- .set_logical_size(args.logical_resolution.0.x, args.logical_resolution.0.y)
- .unwrap();
-
'mainloop: loop {
- let (width, height) = canvas.logical_size();
+ let (width, height) = canvas.output_size().unwrap();
renderer.size = Vec2::new(width as f32, height as f32);
let keyboard = KeyboardState::new(&events);