Skip to content

Commit

Permalink
Revert "."
Browse files Browse the repository at this point in the history
This reverts commit f59193d.
  • Loading branch information
ShenMian committed Jun 8, 2024
1 parent f59193d commit b6630a4
Show file tree
Hide file tree
Showing 13 changed files with 113 additions and 549 deletions.
7 changes: 3 additions & 4 deletions mobile/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use bevy::prelude::*;
use bevy::window::WindowMode;
use bevy_game::GamePlugin; // ToDo: Replace bevy_game with your new crate name.
use bevy::{prelude::*, window::WindowMode};
use soukoban_rs::SokobanPlugin;

#[bevy_main]
fn main() {
Expand All @@ -14,7 +13,7 @@ fn main() {
}),
..default()
}),
GamePlugin,
// SokobanPlugin,
))
.run()
}
35 changes: 0 additions & 35 deletions src/actions/game_control.rs

This file was deleted.

60 changes: 0 additions & 60 deletions src/actions/mod.rs

This file was deleted.

56 changes: 0 additions & 56 deletions src/audio.rs

This file was deleted.

52 changes: 9 additions & 43 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,51 +1,17 @@
#![allow(clippy::type_complexity)]

mod actions;
mod audio;
mod loading;
mod menu;
mod player;

use crate::actions::ActionsPlugin;
use crate::audio::InternalAudioPlugin;
use crate::loading::LoadingPlugin;
use crate::menu::MenuPlugin;
use crate::player::PlayerPlugin;

use bevy::app::App;
#[cfg(debug_assertions)]
use bevy::diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin};
use bevy::prelude::*;

// This example game uses States to separate logic
// See https://bevy-cheatbook.github.io/programming/states.html
// Or https://github.com/bevyengine/bevy/blob/main/examples/ecs/state.rs
#[derive(States, Default, Clone, Eq, PartialEq, Debug, Hash)]
enum GameState {
// During the loading State the LoadingPlugin will load our assets
#[default]
Loading,
// During this State the actual game logic is executed
Playing,
// Here the menu is drawn and waiting for player interaction
Menu,
}
mod performance_matrix;
mod systems;

pub struct GamePlugin;
pub struct SokobanPlugin;

impl Plugin for GamePlugin {
impl Plugin for SokobanPlugin {
fn build(&self, app: &mut App) {
app.init_state::<GameState>().add_plugins((
LoadingPlugin,
MenuPlugin,
ActionsPlugin,
InternalAudioPlugin,
PlayerPlugin,
));
// app.add_plugins(DefaultPlugins);

// #[cfg(debug_assertions)]
// app.add_plugins(performance_matrix::PerformanceMatrixPlugin);

#[cfg(debug_assertions)]
{
app.add_plugins((FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin::default()));
}
// app.add_systems(Startup, (systems::window::setup, systems::camera::setup));
}
}
37 changes: 0 additions & 37 deletions src/loading.rs

This file was deleted.

56 changes: 11 additions & 45 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,53 +1,19 @@
// disable console on windows for release builds
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

use bevy::asset::AssetMetaCheck;
use bevy::prelude::*;
use bevy::window::PrimaryWindow;
use bevy::winit::WinitWindows;
use bevy::DefaultPlugins;
use bevy_game::GamePlugin; // ToDo: Replace bevy_game with your new crate name.
use std::io::Cursor;
use winit::window::Icon;
use soukoban_rs::SokobanPlugin;

fn main() {
App::new()
.insert_resource(Msaa::Off)
.insert_resource(AssetMetaCheck::Never)
.insert_resource(ClearColor(Color::rgb(0.4, 0.4, 0.4)))
.add_plugins(DefaultPlugins.set(WindowPlugin {
primary_window: Some(Window {
title: "Bevy game".to_string(), // ToDo
// Bind to canvas included in `index.html`
canvas: Some("#bevy".to_owned()),
// Tells wasm not to override default event handling, like F5 and Ctrl+R
prevent_default_event_handling: false,
.add_plugins((
DefaultPlugins.set(WindowPlugin {
primary_window: Some(Window {
title: "Sokoban".to_string(),
canvas: Some("#bevy".to_owned()),
prevent_default_event_handling: false,
..default()
}),
..default()
}),
..default()
}))
.add_plugins(GamePlugin)
.add_systems(Startup, set_window_icon)
// SokobanPlugin,
))
.run();
}

// Sets the icon on windows and X11
fn set_window_icon(
windows: NonSend<WinitWindows>,
primary_window: Query<Entity, With<PrimaryWindow>>,
) {
let primary_entity = primary_window.single();
let Some(primary) = windows.get_window(primary_entity) else {
return;
};
let icon_buf = Cursor::new(include_bytes!(
"../build/macos/AppIcon.iconset/icon_256x256.png"
));
if let Ok(image) = image::load(icon_buf, image::ImageFormat::Png) {
let image = image.into_rgba8();
let (width, height) = image.dimensions();
let rgba = image.into_raw();
let icon = Icon::from_rgba(rgba, width, height).unwrap();
primary.set_window_icon(Some(icon));
};
}
Loading

0 comments on commit b6630a4

Please sign in to comment.