2/15/2012

a bit of progress, again

imported the location and world classes from the old version of frogue, implemented the party class, made everything report error messages to the system pane.  also figured out how to actually use resources outside the main .cpp file, which was sort of necessary for getting objects to work.

working with windows is kind of confusing.  it's not linear - windows basically runs a single, continuous loop that listens for whatever input the keyboard / buttons give, and then runs functions based on whatever input you give it.  so it ends up looking something like this:

if(button pushed = keypad 0) {
    if gamestate = 1 { do this }
    else if gamestate = 2 { do this}
    etc
}
if(button pushed = keypad 1) {
    etc
}

so basically, i need to write ten statements for each possible input to tell the program how it should respond if the game is, say, in 'movement' mode (go north/go south/etc).  it's a massive pain to keep everything straight.  still - progress is progress.  at the very least, i think i know how everything should go together now.

3 comments:

  1. If you set up the possible key entries as arrays in advance, you can then make subroutines which listen for general input and then discern whether to act based on what key was pressed in what context. It may make things a tiny bit less organized, but there's less redundancy. Because instead of having a dozen {if... do} loops you just have one that governs what to do given the situation, and then a dozen possible outcomes within that subroutine. Umm, it sounds kinda confusing now that I read this, and maybe it's not helpful, but...
    Anyway, I like nestling input data as tags myself, and having subroutines read the e.sender data. But I'm not entirely sure how things work in Visual cpp.
    Anyway, your commitment to your project helps inspire me to stay motivated on mine :)

    ReplyDelete
    Replies
    1. i get what you're saying, but it won't work. i'm reusing functions as much as i can; in the WM_COMMAND switch of the message loop, it fires the same function for both when you press a button on the 10key and when you click it, but since i'm specifically trying to avoid redundant functionality within the buttons (eg. two buttons that let you save your game), i can't really reuse anything for the actual commands that are called from that universal key function.

      Delete