Spaces:
Running
Running
File size: 2,046 Bytes
d5c39db |
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 |
mod blood;
mod bone;
mod grain;
mod grid;
mod setup;
mod utils;
use crate::blood::shade_blood;
use crate::grain::{add_grain, update_grain};
use crate::grid::{update_grid_data, Grid};
use crate::setup::setup;
use crate::utils::constants::{TICK_RATE, WINDOW_SIZE};
use crate::utils::tick::TickCounter;
use bevy::prelude::*;
use bevy::window::PresentMode;
use bevy_pixel_camera::PixelCameraPlugin;
/*
🦀 Main function, used to:
- Add Ressources -> Resources are global data we can use later across Systems, independently of entities. Learn more: https://bevy-cheatbook.github.io/programming/res.html
- Register Systems -> Think Bevy ECS Systems like a database, Systems are a way to "query" our data to implement game logic. Learn more: https://bevy-cheatbook.github.io/programming/systems.html
- Run our app
*/
fn main() {
App::new()
.add_plugins((
DefaultPlugins
.set(ImagePlugin::default_nearest())
.set(WindowPlugin {
primary_window: Some(Window {
title: "Hell".into(),
resolution: (WINDOW_SIZE[0], WINDOW_SIZE[1]).into(),
resizable: false,
present_mode: PresentMode::AutoVsync,
// Used to run the game in my own Canvas in my Svelte web app
canvas: Some("#bevy-canvas".to_string()),
..default()
}),
..default()
})
.build(),
PixelCameraPlugin,
))
.insert_resource(ClearColor(Color::hex("221e22").unwrap()))
.insert_resource(TickCounter {
count: 0,
tick_rate: TICK_RATE,
})
.insert_resource(Grid::new())
.add_systems(Startup, setup)
.add_systems(Update, add_grain)
.add_systems(Update, update_grain)
.add_systems(Update, update_grid_data)
.add_systems(Update, shade_blood)
.run();
}
|