Results 1 to 5 of 5

Thread: Help with custom type

  1. #1

    Help with custom type

    Code:
    tGameStatus = (gsLoadSettings, gsCreateDisplay, gsStart, gsTesting);
    
        gameStatus: tGameStatus;
        gameStatusNext: tGameStatus;
    Code:
      if (gameActive and gameFocus) then
      try
        case gameStatus of
          (gsLoadSettings): 
          begin
            if (gameStatusNext = nil) then
            gameStatus := gsCreateDisplay;
          end;
          (gsCreateDisplay):
          begin
            gameDisplay := cGraphics.Create(handle);
          end;
        else
          gameUtils.dialogFatal('Unknown Game Status!');
          application.Terminate;
        end;
      end;
    Anyway, it obviously fails at if gameStatusNext, if i have not assigned GameStatusNext, what is it? How do i see if there is a next status?

  2. #2
    Legendary Member cairnswm's Avatar
    Join Date
    Nov 2002
    Location
    Randburg, South Africa
    Posts
    1,537

    Help with custom type

    Enumerated types are always Ordinal (you can do Ord(Type)) which means they are effectivly integer values. The first value in the list is 0 (zero) and it will normally be the default value. Add an additional value at the start of the enumerated type of gtNone and check for gtNone instead of Null.
    William Cairns
    My Games: http://www.cairnsgames.co.za (Currently very inactive)
    MyOnline Games: http://TheGameDeveloper.co.za (Currently very inactive)

  3. #3

    Help with custom type

    That sounds like a good idea. I see what you mean. Thanks.

  4. #4

    Help with custom type

    Yes, I'd be inclined to add a gsNone there as a default.

    You can also consider using the High and Low functions, which will return the highest and lowest types:

    [pascal]if GameStatus = High(TGameStatus) then
    // last one
    else
    // not last one[/pascal]

    Since you're on the subject, I have an article on states on my (becoming a little neglected) web site.
    "All paid jobs absorb and degrade the mind."
    <br />-- Aristotle

  5. #5

    Help with custom type

    Thats funny, you wrote a whole tutorial about what I thought would be a good idea :lol:. Yeah now I'm gonna write a class. FINITO!

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
  •