size state changes

This commit is contained in:
Max Bradbury 2021-11-14 17:49:30 +00:00
parent 0e5b0c4566
commit 68f5306283
1 changed files with 4 additions and 8 deletions

View File

@ -20,8 +20,6 @@ struct Image {
struct State { struct State {
game: Game, game: Game,
width: usize,
height: usize,
player_position: (u8, u8), player_position: (u8, u8),
player_avatar: Image, player_avatar: Image,
palette: [[u8; 4]; 4], palette: [[u8; 4]; 4],
@ -47,13 +45,13 @@ impl State {
screen[ screen[
( (
// player vertical offset (number of lines above) // player vertical offset (number of lines above)
(player_y as usize * 8 * (8 * self.width as usize)) (player_y as usize * 8 * (8 * self.game.config.width as usize))
+ +
// player horizontal offset; number of pixels to the left // player horizontal offset; number of pixels to the left
(player_x as usize * 8) (player_x as usize * 8)
+ +
// tile vertical offset; number of lines within tile // tile vertical offset; number of lines within tile
(tile_y as usize * (8 * self.width as usize)) (tile_y as usize * (8 * self.game.config.width as usize))
+ +
(tile_x as usize) // tile horizontal offset (tile_x as usize) // tile horizontal offset
) )
@ -78,8 +76,6 @@ fn main() -> Result<(), Error> {
let mut state = State { let mut state = State {
game, game,
width: 16,
height: 9,
player_position: (8, 4), player_position: (8, 4),
player_avatar: Image { pixels: [ player_avatar: Image { pixels: [
0,0,0,2,2,0,0,0, 0,0,0,2,2,0,0,0,
@ -292,12 +288,12 @@ fn create_window(
LogicalSize::new(width * scale, height * scale); LogicalSize::new(width * scale, height * scale);
let center = LogicalPosition::new( let center = LogicalPosition::new(
(monitor_width - width * scale) / 2.0, (monitor_width - width * scale) / 2.0,
(monitor_height - height * scale) / 2.0, (monitor_height - height * scale) / 2.0,
); );
window.set_inner_size(default_size); window.set_inner_size(default_size);
window.set_min_inner_size(Some(min_size)); // window.set_min_inner_size(Some(min_size));
window.set_outer_position(center); window.set_outer_position(center);
window.set_visible(true); window.set_visible(true);