roguelike-game/src/main.rs

149 lines
3.2 KiB
Rust
Raw Normal View History

#[macro_use]
extern crate lazy_static;
2022-01-11 09:24:20 -05:00
mod ai;
pub mod camera;
mod colors;
2021-10-22 10:05:06 -04:00
mod components;
mod damage_system;
mod effects;
2021-11-04 10:44:52 -04:00
mod game_log;
2022-01-03 15:21:12 -05:00
mod gamesystem;
mod gui;
2021-11-18 10:28:49 -05:00
mod hunger_system;
mod inventory_system;
2022-01-10 10:21:19 -05:00
mod lighting_system;
2021-10-22 10:05:06 -04:00
mod map;
pub mod map_builders;
mod map_indexing_system;
mod melee_combat_system;
mod movement_system;
2021-11-16 11:33:58 -05:00
mod particle_system;
2021-10-22 10:05:06 -04:00
mod player;
mod random_table;
mod raws;
2021-10-22 10:05:06 -04:00
mod rect;
2021-11-29 14:59:46 -05:00
mod rex_assets;
mod saveload_system;
mod spatial;
mod spawner;
2022-01-18 11:40:31 -05:00
mod state;
2021-11-29 16:00:07 -05:00
mod trigger_system;
2021-10-25 15:26:39 -04:00
mod visibility_system;
use ::specs::prelude::*;
use ::specs::saveload::{SimpleMarker, SimpleMarkerAllocator};
2021-11-05 14:32:14 -04:00
use components::*;
2021-11-04 10:44:52 -04:00
pub use game_log::GameLog;
pub use map::*;
pub use rect::Rect;
2022-01-18 11:40:31 -05:00
pub use state::*;
2021-10-25 15:26:39 -04:00
/// Cut down on the amount of syntax to register components
macro_rules! register {
2022-01-19 09:38:41 -05:00
// $state is needed to get the scope at the usage point
// $Type is the Component type that is being registered
2022-01-19 09:38:41 -05:00
($state: ident <- $( $Type: ty ),*,) => {
$(
2022-01-19 09:38:41 -05:00
$state.ecs.register::<$Type>();
)*
}
}
2021-12-24 10:38:44 -05:00
fn main() -> ::rltk::BError {
2022-01-04 12:12:08 -05:00
let context = ::rltk::RltkBuilder::simple(80, 60)
.unwrap()
2021-10-20 12:01:15 -04:00
.with_title("Roguelike Tutorial")
.build()?;
2022-01-19 09:38:41 -05:00
let mut state = State::new();
2021-10-21 12:54:39 -04:00
register!(
2022-01-19 09:38:41 -05:00
state <-
ApplyMove,
ApplyTeleport,
2021-11-05 13:12:22 -04:00
AreaOfEffect,
Attributes,
BlocksTile,
BlocksVisibility,
Chasing,
2021-11-05 14:32:14 -04:00
Confusion,
Consumable,
Door,
DMSerializationHelper,
EntityMoved,
EntryTrigger,
2021-11-15 09:19:22 -05:00
Equippable,
Equipped,
2022-01-13 10:14:13 -05:00
EquipmentChanged,
2022-01-11 14:16:23 -05:00
Faction,
Hidden,
HungerClock,
IdentifiedItem,
InBackpack,
InflictsDamage,
2022-01-11 09:28:45 -05:00
Initiative,
Item,
2022-01-10 10:21:19 -05:00
LightSource,
LootTable,
2022-01-19 09:38:41 -05:00
MagicItem,
MagicMapper,
MeleeWeapon,
2022-01-11 14:16:23 -05:00
MoveMode,
2022-01-11 09:33:21 -05:00
MyTurn,
Name,
NaturalAttackDefense,
ObfuscatedName,
OtherLevelPosition,
2021-11-16 11:33:58 -05:00
ParticleLifetime,
Player,
Pools,
Position,
ProvidesFood,
ProvidesHealing,
2022-01-03 10:49:12 -05:00
Quips,
Ranged,
Renderable,
SerializationHelper,
SimpleMarker<SerializeMe>,
SingleActivation,
2022-01-03 15:24:38 -05:00
Skills,
SufferDamage,
TeleportTo,
TownPortal,
2022-01-13 11:29:20 -05:00
Vendor,
Viewshed,
2022-01-11 14:16:23 -05:00
WantsToApproach,
WantsToDropItem,
2022-01-11 14:16:23 -05:00
WantsToFlee,
WantsToMelee,
WantsToPickupItem,
WantsToRemoveItem,
WantsToUseItem,
Wearable,
);
2021-10-21 12:54:39 -04:00
2022-01-19 09:38:41 -05:00
state
.ecs
.insert(SimpleMarkerAllocator::<SerializeMe>::new());
2021-11-08 13:58:40 -05:00
raws::load_raws();
2022-01-19 09:38:41 -05:00
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());
2021-12-02 14:59:35 -05:00
2022-01-19 09:38:41 -05:00
let player_entity = spawner::player(&mut state.ecs, 0, 0);
state.ecs.insert(player_entity);
2021-12-02 14:59:35 -05:00
2022-01-19 09:38:41 -05:00
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());
2021-10-26 14:38:30 -04:00
2022-01-19 09:38:41 -05:00
state.generate_world_map(1, 0);
2022-01-19 09:38:41 -05:00
::rltk::main_loop(context, state)
2021-10-21 12:54:39 -04:00
}