resizable game window
This commit is contained in:
parent
489c2814e2
commit
1830aec847
@ -1,5 +1,5 @@
|
|||||||
mod audio;
|
mod audio;
|
||||||
mod render;
|
mod sdl;
|
||||||
mod ui;
|
mod ui;
|
||||||
|
|
||||||
pub use render::start_game;
|
pub use sdl::start_game;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
use crate::actions::{Action, ActionsHeld};
|
use crate::actions::{Action, ActionsHeld};
|
||||||
use crate::board::Board;
|
use crate::game::Game;
|
||||||
use crate::game::{CurrentTetromino, Game};
|
|
||||||
use sdl2::event::Event;
|
use sdl2::event::Event;
|
||||||
use sdl2::keyboard::Keycode;
|
use sdl2::keyboard::Keycode;
|
||||||
use sdl2::pixels::Color;
|
use sdl2::pixels::Color;
|
||||||
@ -10,7 +9,7 @@ use sdl2::ttf::Sdl2TtfContext;
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use super::audio::{self};
|
use super::audio::{self};
|
||||||
use super::ui::{Rgb, UiCtx};
|
use super::ui::{GameUiCtx, Rgb, UiCtx};
|
||||||
|
|
||||||
const WIDTH: i32 = 1000;
|
const WIDTH: i32 = 1000;
|
||||||
const HEIGHT: i32 = 800;
|
const HEIGHT: i32 = 800;
|
||||||
@ -128,6 +127,7 @@ pub fn start_game() -> Result<(), String> {
|
|||||||
|
|
||||||
let window = video_subsystem
|
let window = video_subsystem
|
||||||
.window("reimtris2", WIDTH as u32, HEIGHT as u32)
|
.window("reimtris2", WIDTH as u32, HEIGHT as u32)
|
||||||
|
.resizable()
|
||||||
.position_centered()
|
.position_centered()
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
@ -26,7 +26,9 @@ pub trait UiCtx<Err> {
|
|||||||
height: i32,
|
height: i32,
|
||||||
) -> Result<(), Err>;
|
) -> Result<(), Err>;
|
||||||
fn clear(&mut self, rgb: &Rgb) -> Result<(), Err>;
|
fn clear(&mut self, rgb: &Rgb) -> Result<(), Err>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait GameUiCtx<Err>: UiCtx<Err> {
|
||||||
fn draw_tetromino_from_parts(
|
fn draw_tetromino_from_parts(
|
||||||
&mut self,
|
&mut self,
|
||||||
x: i8,
|
x: i8,
|
||||||
@ -131,6 +133,8 @@ pub trait UiCtx<Err> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T, Err> GameUiCtx<Err> for T where T: UiCtx<Err> {}
|
||||||
|
|
||||||
pub struct Rgb(pub u8, pub u8, pub u8);
|
pub struct Rgb(pub u8, pub u8, pub u8);
|
||||||
|
|
||||||
impl Rgb {
|
impl Rgb {
|
||||||
|
Loading…
Reference in New Issue
Block a user