Jump to content

April 2017 »

232425 26 272829

Recent Comments

- - - - -

Rogue restart

roguelike 2d rpg sfml c++ adventure
4: Adsense

I'm looking towards a redesign, big re factor. I've moved onto keeping aspects of the game into their own systems. It's made the way I handle actions/events quite a mess. I'll have to butcher it to handle the abilities I have planned.

The current system, events, specifically key presses are checked to call the action that's assigned to them. Any time an action succeeds I set a flag to simulate a turn. Then simulate the turn, applying ai, remove dead things, gain levels...etc

    case : key = p
        bool simulateTurn = pickupItem(...)
    simulateTurn if true
This is further complicated by an actionState that I used for multiple state actions. Using item in the inventory used to take two steps; choose to 'u'se an item, and choose the item to use. The system that morph out of that right now uses a always on cursor to the item in the inventory you want to use. Now pressing 'u' automatically tries to use that item.

    if (actionState == idle)
        check player moving
        check pickup
        check drop
        check eat
    if (droppingItem)
        choose item to drop
        write to console
    if (eatingItem)
        choose item to eat
        write to console
    if (drinkingItem)
        choose item to drink
        apply potion effects
        write to console
Most of it is redundant, just like that. The change to the inventory removed a little bit of the redundancy and I feel speeds up inventory use quite a lot. I want to keep things fluent as possible.

I'll be using a simple interface to derive systems from, and contain all logic and state to these systems. The interface will basically just need to be over-ridden and used to dispatch to the specific actions that system handles.

    virtual bool onKeyPress(...)
Then the logic of the game will be separated into these systems;
item system
dungeon system
creature system
Unfortunately, for my sake, I'm going to restart this project. Taking whats still reusable and glueing it to the new system skeleton. I'm hoping that similar to starting this project after the last should go rather quickly. It'll make things easier for me in the long run. It's getting a little complicated to do these re-factorings any more. Unfortunately what I had designed before is not allowing what I want to do.

So ill leave you with a little snippet of what I had going before all this came to fruition. I have reimplemented all my items, with the new concepts already. Added a drop system similar to Diablo 2's drop class system. Drop classes contain lists of items that can drop and the chances for those items. Then things like creatures or chests are assigned a drop class. Got creatures and basic AI up and running.

Note: GameDev.net moderates comments.