toyboot4e / snowrl

[WIP] Roguelike game in Rust
2 stars 0 forks source link

Two-world theory (architecture change) #2

Open toyboot4e opened 3 years ago

toyboot4e commented 3 years ago

Three-Worlds Theory: Art or Gameplay? Pick Two. - Box Dragon is my favorite article this year. I'm switching to that strategy.

The idea is duplicating the internal game state; use one for the internal game progress, and sync the other to the progressing world for visualization. So we don't need to be bothered with "stop and resume" state handling; the control is on our hands!

toyboot4e commented 3 years ago

I made yet another generational arena: toy_arena. The Arena<T, D, G> can accept distinct type parameter D, and it's perfect for duplicating the internal game Model:

pub struct Game {
    system: GameSystem,
    view: GameView,
}

/// Model + view game state that is synced to the internal `GameSystem
pub struct GameView {
    vm: Model<Self>,
}

/// Model-only game system
pub struct GameSystem {
    loop_: TurnBasedGameState,
    model: Model<Self>,
}

/// Internal game state
pub struct Model<D> {
    entities: Arena<EntityModel, D>,
    map: MapModel,
}
toyboot4e commented 3 years ago

No I have to not use the D parameter, or else I can't apply same Change to another Model