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

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

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

Loading…
Cancel
Save