1
0
Fork 0
roguelike-game/src/main.rs

146 lines
3.2 KiB
Rust

mod ai;
pub mod camera;
mod colors;
mod components;
mod damage_system;
mod game_log;
mod gamesystem;
mod gui;
mod hunger_system;
mod inventory_system;
mod lighting_system;
mod map;
pub mod map_builders;
mod map_indexing_system;
mod melee_combat_system;
mod movement_system;
mod particle_system;
mod player;
pub mod random_table;
pub mod raws;
mod rect;
mod rex_assets;
pub mod saveload_system;
mod spatial;
mod spawner;
mod state;
mod trigger_system;
mod visibility_system;
#[macro_use]
extern crate lazy_static;
use ::specs::prelude::*;
use ::specs::saveload::{SimpleMarker, SimpleMarkerAllocator};
use components::*;
pub use game_log::GameLog;
pub use map::*;
pub use rect::Rect;
pub use state::*;
/// Cut down on the amount of syntax to register components
macro_rules! register {
// $state is needed to get the scope at the usage point
// $Type is the Component type that is being registered
($state: ident <- $( $Type: ty ),*,) => {
$(
$state.ecs.register::<$Type>();
)*
}
}
fn main() -> ::rltk::BError {
let context = ::rltk::RltkBuilder::simple(80, 60)
.unwrap()
.with_title("Roguelike Tutorial")
.build()?;
let mut state = State::new();
register!(
state <-
ApplyMove,
ApplyTeleport,
AreaOfEffect,
Attributes,
BlocksTile,
BlocksVisibility,
Chasing,
Confusion,
Consumable,
Door,
DMSerializationHelper,
EntityMoved,
EntryTrigger,
Equippable,
Equipped,
EquipmentChanged,
Faction,
Hidden,
HungerClock,
InBackpack,
InflictsDamage,
Initiative,
Item,
LightSource,
LootTable,
MagicItem,
MagicMapper,
MeleeWeapon,
MoveMode,
MyTurn,
Name,
NaturalAttackDefense,
OtherLevelPosition,
ParticleLifetime,
Player,
Pools,
Position,
ProvidesFood,
ProvidesHealing,
Quips,
Ranged,
Renderable,
SerializationHelper,
SimpleMarker<SerializeMe>,
SingleActivation,
Skills,
SufferDamage,
TeleportTo,
TownPortal,
Vendor,
Viewshed,
WantsToApproach,
WantsToDropItem,
WantsToFlee,
WantsToMelee,
WantsToPickupItem,
WantsToRemoveItem,
WantsToUseItem,
Wearable,
);
state
.ecs
.insert(SimpleMarkerAllocator::<SerializeMe>::new());
raws::load_raws();
state.ecs.insert(MasterDungeonMap::new());
state.ecs.insert(Map::new(1, 64, 64, "New Map"));
state.ecs.insert(::rltk::Point::zero());
state.ecs.insert(::rltk::RandomNumberGenerator::new());
let player_entity = spawner::player(&mut state.ecs, 0, 0);
state.ecs.insert(player_entity);
state.ecs.insert(RunState::MapGeneration {});
state.ecs.insert(GameLog::new("Welcome to Rusty Roguelike"));
state.ecs.insert(particle_system::ParticleBuilder::new());
state.ecs.insert(rex_assets::RexAssets::new());
state.generate_world_map(1, 0);
::rltk::main_loop(context, state)
}