Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.






Rogue restart

Posted by coremarq, 07 May 2014 · 273 views

roguelike 2d rpg sfml c++ adventure
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

game
    onKeyPress
    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.

game
    onKeyPress
    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.

system
    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.






December 2014 »

S M T W T F S
 123456
78910111213
14151617 18 1920
21222324252627
28293031   

Recent Comments

PARTNERS