set window resolution to phone-like

main
Elijah Voigt 2 months ago
parent 1f42537f48
commit 7aa2f344f9

@ -7,6 +7,7 @@ pub struct BaseGamePlugin {
pub title: String, pub title: String,
pub name: String, pub name: String,
pub game_type: GameType, pub game_type: GameType,
pub window: Option<Window>,
} }
pub enum GameType { pub enum GameType {
@ -20,6 +21,7 @@ impl Default for BaseGamePlugin {
title: "My Game".into(), title: "My Game".into(),
name: "mygame".into(), name: "mygame".into(),
game_type: GameType::Three, game_type: GameType::Three,
window: None,
} }
} }
} }
@ -32,7 +34,7 @@ impl Plugin for BaseGamePlugin {
primary_window: Some(Window { primary_window: Some(Window {
fit_canvas_to_parent: true, fit_canvas_to_parent: true,
canvas: Some(format!("#{}-canvas", self.name)), canvas: Some(format!("#{}-canvas", self.name)),
..default() ..self.window.clone().unwrap_or_default()
}), }),
..default() ..default()
}) })

@ -3,6 +3,7 @@
use bevy::image::{ImageLoaderSettings, ImageSampler}; use bevy::image::{ImageLoaderSettings, ImageSampler};
use bevy::render::view::ColorGrading; use bevy::render::view::ColorGrading;
use bevy::window::WindowResolution;
use games::physics2d::*; use games::physics2d::*;
use games::*; use games::*;
use std::hash::BuildHasher; use std::hash::BuildHasher;
@ -15,6 +16,7 @@ fn main() {
title: "flappy bird (with rewind)".into(), title: "flappy bird (with rewind)".into(),
name: "flappy".into(), name: "flappy".into(),
game_type: GameType::Two, game_type: GameType::Two,
window: Some(Window { resolution: WindowResolution::new(360.0, 640.0), ..default() })
}, },
Physics2dPlugin, Physics2dPlugin,
)) ))
@ -733,7 +735,7 @@ fn init_ui(mut commands: Commands, server: Res<AssetServer>) {
( (
Text::new("Rewind!\n(Hold R)"), Text::new("Rewind!\n(Hold R)"),
TextColor(BLACK.into()), TextColor(BLACK.into()),
TextFont::from_font_size(30.0), TextFont::from_font_size(20.0),
TextLayout::new_with_justify(JustifyText::Center) TextLayout::new_with_justify(JustifyText::Center)
), ),
], ],
@ -765,7 +767,7 @@ fn init_ui(mut commands: Commands, server: Res<AssetServer>) {
( (
Text::new("Flap!\n(Spacebar)"), Text::new("Flap!\n(Spacebar)"),
TextColor(BLACK.into()), TextColor(BLACK.into()),
TextFont::from_font_size(30.0), TextFont::from_font_size(20.0),
TextLayout::new_with_justify(JustifyText::Center) TextLayout::new_with_justify(JustifyText::Center)
), ),
( (

@ -1,7 +1,7 @@
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en">
<body> <body>
<canvas id="flappy-canvas"></canvas> <canvas id="flappy-canvas" ></canvas>
<script type="module"> <script type="module">
import init from './bin.js' import init from './bin.js'

Loading…
Cancel
Save