Results 1 to 3 of 3

Thread: Interface and game itself

  1. #1

    Interface and game itself

    I'm new on this forum and I've been learning directx for 6months now..
    How should I split up my code so that MenuInterface has its own functions and the actual game its own. I dont want to have a lot of flags that tell which function to call.. Is there a good way of doing this?
    and I hope my english is readable.
    I am not crazy. It's the TV that's crazy. Aren't you, TV?

  2. #2

    Interface and game itself

    Simply make variable procedures or functions and when shifting the games state to menu or game mode make them point to whatever you need. For example:

    [pascal]var
    DoProcessrocedure;

    procedure SwitchState(const newstate:cardinal);
    begin
    case newstate of
    0: DoProcess:=@ProcMenu;
    1: DoProcess:=@ProcGame;
    end;//ProcMenu and ProcGame are simple procedures
    end;[/pascal]

  3. #3

    Interface and game itself

    I have an article on how to separate out the states: http://www.alistairkeys.co.uk/states.shtml. I've refined the method a bit for my own projects but the article is about right. The only addition I'd make to the article is to allow states to be killed immediately after changing states, e.g. for a one-time intro, instead of being caught in the finalization. This can save you from having a few states sitting around unnecessarily. That's just a boolean per state and a couple of lines of code to change or thereabouts.
    "All paid jobs absorb and degrade the mind."
    <br />-- Aristotle

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •