-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathmain.rs
More file actions
80 lines (70 loc) · 2.13 KB
/
main.rs
File metadata and controls
80 lines (70 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#![allow(clippy::redundant_field_names)]
#![allow(clippy::too_many_arguments)]
use bevy::{prelude::*, render::camera::ScalingMode, window::PresentMode};
pub const CLEAR: Color = Color::rgb(0.1, 0.1, 0.1);
pub const RESOLUTION: f32 = 16.0 / 9.0;
pub const TILE_SIZE: f32 = 0.1;
mod ascii;
mod audio;
mod combat;
mod debug;
mod fadeout;
mod graphics;
mod npc;
mod player;
mod start_menu;
mod tilemap;
use ascii::AsciiPlugin;
use audio::GameAudioPlugin;
use combat::CombatPlugin;
use debug::DebugPlugin;
use fadeout::FadeoutPlugin;
use graphics::GraphicsPlugin;
use npc::NpcPlugin;
use player::PlayerPlugin;
use start_menu::MainMenuPlugin;
use tilemap::TileMapPlugin;
#[derive(Debug, Clone, PartialEq, Eq, Hash, Copy)]
pub enum GameState {
StartMenu,
Overworld,
Combat,
}
fn main() {
let height = 900.0;
App::new()
.add_state(GameState::StartMenu)
.insert_resource(ClearColor(CLEAR))
.insert_resource(WindowDescriptor {
width: height * RESOLUTION,
height: height,
title: "Bevy Tutorial".to_string(),
present_mode: PresentMode::Fifo,
resizable: false,
..Default::default()
})
.add_plugins(DefaultPlugins)
.add_startup_system(spawn_camera)
.add_plugin(PlayerPlugin)
.add_plugin(GameAudioPlugin)
.add_plugin(GraphicsPlugin)
.add_plugin(CombatPlugin)
.add_plugin(FadeoutPlugin)
.add_plugin(AsciiPlugin)
.add_plugin(NpcPlugin)
.add_plugin(DebugPlugin)
.add_plugin(MainMenuPlugin)
.add_plugin(TileMapPlugin)
.run();
}
fn spawn_camera(mut commands: Commands) {
let mut camera = OrthographicCameraBundle::new_2d();
//Set the camera to have normalized coordinates of y values -1 to 1
camera.orthographic_projection.top = 1.0;
camera.orthographic_projection.bottom = -1.0;
camera.orthographic_projection.right = 1.0 * RESOLUTION;
camera.orthographic_projection.left = -1.0 * RESOLUTION;
//Force the camera to use our settings
camera.orthographic_projection.scaling_mode = ScalingMode::None;
commands.spawn_bundle(camera);
}