Page 15 of 16 FirstFirst ... 513141516 LastLast
Results 141 to 150 of 159

Thread: The Probe

  1. #141
    Hi all,
    I have uploaded the latest version of The Probe to it's dedicated website now (scary!!)
    http://theprobegame.com/

    See the downloads page to get it

    Here is the latest change log:
    Version: 2012.01.25
    * Change - Added module music (.xm, .mod) playing code to reduce game footprint size (Thanks BeRo!).
    * Change - Added module music tracks into game; one for the menu and the rest for in-game levels.
    * Change - Added scrolling credits to bottom of menu screens.
    * Change - Change default fire key from SPACE to Left-CTRL key due to user request.
    * Change - In-game music now starts playing after player teleports into a level, and plays a random track each new level (track restarts when level restars).
    * Change - Renamed 'options' menu item.
    * Change - Editor Mode: Added W,S,A,D keys to scroll level (independant of scroll bars) to allow clicking outside level boarders to expand level size automatically.
    * Change - Editor Mode: Added Space, 'X', 'Y' keys to rotate and flip (where applicable) the selected tile.
    * Change - Updated switch graphics to much nicer ones!
    * Change - Updated "The Probe_Help.pdf" with Background Story, game objective, and new fire key, new switch graphics and new editor information.
    * Change - Added some more test levels to the main game for users to try out.
    * Fix - Fixed editor bug where cursor not moving (thanks SilverWarior)!
    Here is a challenge: Now that the editor is working again, and is more user friendly (I believe)...it would be great if you guys could try making some levels if you get time
    When done, can you send them to me, or post them here?
    If I like them good enough I will add them into the game itself!

    cheers,
    Paul

  2. #142
    Again I found several bugs:
    1. In audio options menu you can move your selection down, but you can't move it up (UP key not responding).
    2. In audio options it is not posible to use enter for checking or unchecking the checkboxes or for presing butons.
    3. When you are returned to the main menu after death the ingame music doesnt stop so you got both ingame music and menu music playing at the same time.
    4. For some reason my probe won't fire, so I cant get past level 3. Or should I always run around?
    5. After geting on travelators it is almost imposible to get off. Is this how it is suposed to be?
    6. When working with editor it is posible to start (test ) a level without probe in it. You should add a safety check to se if probe was placed anywhere in the level before alowing to proceed.

    I'm I the only bug hunter in your game? Or is it just that I find them before others do?

    Some feture requests:
    1. Add ability to chose wich level you want to load.
    2. Add ability to chose the desired filename when saving level.
    3. Make editor available from games main menu (only when there is no current active game)
    4. Another great feture will be ability for players to be able to do their own campaigns (series of levels joined into special file). I belive this will atract more pepole.

    That's it for now.

  3. #143
    Quote Originally Posted by SilverWarior View Post
    Again I found several bugs:
    1. In audio options menu you can move your selection down, but you can't move it up (UP key not responding).
    2. In audio options it is not posible to use enter for checking or unchecking the checkboxes or for presing butons.
    3. When you are returned to the main menu after death the ingame music doesnt stop so you got both ingame music and menu music playing at the same time.
    4. For some reason my probe won't fire, so I cant get past level 3. Or should I always run around?
    5. After geting on travelators it is almost imposible to get off. Is this how it is suposed to be?
    6. When working with editor it is posible to start (test ) a level without probe in it. You should add a safety check to se if probe was placed anywhere in the level before alowing to proceed.
    1. Bug Confirmed! I am sure that worked ages ago...I must have broken it at some point I usually don't use the keys to control the GUI so this one slipped past. Thanks for finding it
    2. The enter key triggers buttons only, not check boxes (and works for me just fine), and space works for check boxes/radio buttons - again this is working fine right now for me.
    Hmm...are you trying the main enter key? The keypad keys don't work with the GUI at this point in time...
    3. Another confirmed! I obviously didn't try going back to the menu using fire since I added the music! I will fix this one too...
    4. Hmm...I have never had this issue before. Again, are you trying to use the keypad keys (or equivalent)? This might explain the firing not working...what fire key are you using, and have you tried reconfiguring to another key?
    PS, you don't need the fire key in the third level anyway...just keep moving around
    5. Yes, that is how travellators work in the game at this time.
    6. I know this one, but since it doesn't break the game or cause crashes, and the player just can't move, I left it how it was Maybe I might change it later.

    Quote Originally Posted by SilverWarior View Post
    I'm I the only bug hunter in your game? Or is it just that I find them before others do?

    Some feture requests:
    1. Add ability to chose wich level you want to load.
    2. Add ability to chose the desired filename when saving level.
    3. Make editor available from games main menu (only when there is no current active game)
    4. Another great feture will be ability for players to be able to do their own campaigns (series of levels joined into special file). I belive this will atract more pepole.

    That's it for now.
    1. I want to add this feature in but I wasn't quite sure how to do this...have the user enter some level code, or click on a level GUI selection to run it?
    2. I am having trouble making a GUI text box ATM so I can't do this yet...unless I make a GUI with characters on it like an arcade game when entering your name?
    3. I am going to do this at some point
    4. I was planning on including my level packer program with the game so people can make level pack files (a campaign?) so other users can play the combined levels too as well as single levels

    It seems you are the only one testing (or at least reporting on my game)!

    Thanks so much for all the feedback so far, I will fix the issues you have addressed and I am always trying to improve The Probe
    EDIT: Besides the bugs, how do you like The Probe so far?

    cheers,
    Paul
    Last edited by paul_nicholls; 25-01-2012 at 09:05 PM. Reason: Updated post

  4. #144
    Quote Originally Posted by paul_nicholls View Post
    Hmm...are you trying the main enter key? The keypad keys don't work with the GUI at this point in time...
    Unfortunatly I have one of those laptops where both enter keys act as a NumpadEnter (hardware isue), so the problem lies on my part.

    Quote Originally Posted by paul_nicholls View Post
    Hmm...I have never had this issue before. Again, are you trying to use the keypad keys (or equivalent)? This might explain the firing not working...what fire key are you using, and have you tried reconfiguring to another key?
    I tried reconfiguring my keys. No luck?

    Quote Originally Posted by paul_nicholls View Post
    I want to add this feature in but I wasn't quite sure how to do this...have the user enter some level code, or click on a level GUI selection to run it?
    I see you didn't understand me correctly. I was talking about the Editor.

    Quote Originally Posted by paul_nicholls View Post
    I am having trouble making a GUI text box ATM so I can't do this yet...unless I make a GUI with characters on it like an arcade game when entering your name?
    That could be nice idea. Actualy I think that having the whole GUI made in game theme would look very nice. Currently I'm stil busy writing my article, but when I finish it I will prbably look into SDL graphics, so maybe I might be able to help you with the GUI.

    After giving some thought about curent and past bugs that I managed to find in The Probe I suspect that you have bad overal code structure of your game. I might be wrong. If it isn't a secret can you tell me what's the basic structure of your code.

    Quote Originally Posted by paul_nicholls View Post
    Besides the bugs, how do you like The Probe so far?
    It seems preety nice especialy now with music. I like the ingame music a lot, very energetic.
    Also I see a lot of potential in this game. That is probably the main rason why I'm so eager in monitoring its progress.
    To be honest I'm monitoring progress of many games. Belive it or not by doing so you can learn a lot about the game mechanics even without seing a single line of source code.

    Anyway keep up the good work!

  5. #145
    Quote Originally Posted by SilverWarior View Post
    Unfortunatly I have one of those laptops where both enter keys act as a NumpadEnter (hardware isue), so the problem lies on my part.
    Bummer...I will see what I can do about that on my end

    Quote Originally Posted by SilverWarior View Post
    I tried reconfiguring my keys. No luck?
    Unfortunately, I don't know how to help you on this one Do you have a game controller (joystick, game pad, etc.) that you can try instead?
    If you do, plug it in before running the game...

    Quote Originally Posted by SilverWarior View Post
    I see you didn't understand me correctly. I was talking about the Editor.
    Ah, ok LOL Well I will see if I can make the editor load up a user requested file from in the editor itself instead of via the command line as it currently is

    Quote Originally Posted by SilverWarior View Post
    That could be nice idea. Actualy I think that having the whole GUI made in game theme would look very nice. Currently I'm stil busy writing my article, but when I finish it I will prbably look into SDL graphics, so maybe I might be able to help you with the GUI.
    Thanks for the offer...in the meanwhile I will see what I can do about a replacement GUI instead of the text box

    Quote Originally Posted by SilverWarior View Post
    After giving some thought about curent and past bugs that I managed to find in The Probe I suspect that you have bad overal code structure of your game. I might be wrong. If it isn't a secret can you tell me what's the basic structure of your code.
    erm, yes, well... I do admit that some of the code in the main project .dpr file is a bit messy and could use refactoring, like separate methods for different states...that would make things easier to fix bugs and stuff during different game states

    Currently I am doing different things in the RenderMethod, UpdateFrame, and UpdateInput methods depending on the game states, but all that code is mixed in together and not separated into different routines, so it is too easy for bugs to slip in as it is...

    OnUpdateFrame method:
    Code:
    procedure TTheProbe.OnUpdateFrame(aTimeSlice: single; var aExecuting: boolean);var
      t: Single;
    begin
      inherited;
    
    
      FTimeSlice := aTimeSlice;
    
    
      if FGameMode in [gmGamePlaying,gmGameLevelComplete] then
        FPlayingGame := True
      else
        FPlayingGame := False;
    
    
      if Assigned(FResumeGameItem) then
        FResumeGameItem.Enabled := (FGameMode = gmMenu) and (FLastGameMode <> gmNone);
    
    
      if FDoors.Status = cDoors_Closed then
      // change mode depending on game mode
      begin
        if FGameMode = gmMenu then
        begin
          if Assigned(FMenuMusic) then FMenuMusic.Pause;
          FGameMode := FLastGameMode;
          FDoors.Status := cDoors_Opening;
          SetDoorsMinWidth(cPlayingModeDoorsWidth);
        end
        else
        if FGameMode <> gmMenu then
        begin
          FLastGameMode := FGameMode;
          if FLives = 0 then
            FLastGameMode := gmNone;
    
    
          FGameMode     := gmMenu;
    
    
          if FConfiguration.MusicEnabled then
            if Assigned(FMenuMusic) then FMenuMusic.Resume;
    
    
          FDoors.Status := cDoors_Opening;
          ResetCredits;
          SetDoorsMinWidth(cMenuModeDoorsWidth);
        end
      end
      else
      if (FGameMode = gmMenu) and Assigned(FActiveMenu) then
      begin
        UpdateCredits;
      end;
    
    
      FProbeEngine.EditorMode    := FShowEditorGUI;
      FProbeEngine.UpdateTLSBeam := (FDoors.Status = cDoors_Open) and (FGameMode = gmGamePlaying);
    
    
      if not FShowEditorGUI then
      begin
        if (FDoors.Status = cDoors_Open) and (FGameMode <> gmMenu) then
          FProbeEngine.Update(aTimeSlice);
      end;
    
    
      if FShowEditorGUI or Assigned(FRenderActiveGUI) then
        xeEngine.GUI.Update(aTimeSlice);
    
    
      PlayRequestedSounds;
    
    
      FProbeAnimateCount := FProbeAnimateCount + aTimeSlice;
      if FProbeAnimateCount >= cProbeAnimateRate then
      begin
        Inc(FProbeIndex,FProbeIndexDelta);
    
    
        if (FProbeIndex = 3) and (FProbeIndexDelta = 1) then
            FProbeIndexDelta := -1
        else
        if (FProbeIndex = 1) and (FProbeIndexDelta = -1) then
            FProbeIndexDelta := 1;
    
    
        FProbeAnimateCount := 0;
      end;
    
    
      FAnimateCount := FAnimateCount + aTimeSlice;
      if FAnimateCount >= cAnimateRate then
      begin
        Inc(FTravellatorIndex);
        if FTravellatorIndex > 3 then FTravellatorIndex := 1;
        FAnimateCount := 0;
      end;
    
    
      if (FDoors.Status = cDoors_Open) and (FPlayerData.PlayerMode = pmNormal) and (FGameMode = gmGameLevelComplete) and (FLevelCompleteTimer > 0) then
      begin
        FLevelCompleteTimer := FLevelCompleteTimer - FTimeSlice;
        if FLevelCompleteTimer <= 0 then FLevelCompleteTimer := 0;
      end;
    
    
      if (FDoors.Status = cDoors_Open) and (FGameMode = gmGamePlaying) then
      begin
        if FPlayerData.PlayerMode <> pmNormal then
        begin
          if FPlayerData.PlayerMode = pmTeleportingIn then
          begin
            if FTeleportInDelay <= 0 then
            begin
              FPlayerData.TeleportCount := FPlayerData.TeleportCount + FTimeSlice;
    
    
              if FPlayerData.TeleportCount >= cTeleportTime then
              begin
                FPlayerData.TeleportCount := cTeleportTime;
                FPlayerData.PlayerMode    := pmNormal;
    
    
                if FConfiguration.MusicEnabled then
                  if Assigned(FGameMusic) then FGameMusic.Play(FConfiguration.MusicVolume,True);
              end;
            end
            else
            begin
              FTeleportInDelay := FTeleportInDelay - FTimeSlice;
    
    
              if not FShowEditorGUI and (FTeleportInDelay <= 0) and FConfiguration.SfxEnabled then
                FTeleportLevel.Play(FConfiguration.SfxVolume * 0.5);
            end;
          end
          else
          if FPlayerData.PlayerMode = pmTeleportingOut then
          begin
            FPlayerData.TeleportCount := FPlayerData.TeleportCount - FTimeSlice;
    
    
            if FPlayerData.TeleportCount <= 0 then
            begin
              FPlayerData.TeleportCount := 0;
              FPlayerData.PlayerMode    := pmNormal;
              FGameMode                 := gmGameLevelComplete;
            end;
          end;
        end
        else
        if FTLSData.Charge >= 100 then
        begin
          FLevelCompleteTimer       := 16 * FProbeEngine.UpdateRate;
          FPlayerData.TeleportCount := cTeleportTime;
          FPlayerData.PlayerMode    := pmTeleportingOut;
          if Assigned(FPlayerData.PlayerObj) then
            FPlayerData.PlayerObj^.Value := cObjPostProbe;
    
    
          // stop any player movement from before
          FProbeEngine.MoveUp       := False;
          FProbeEngine.MoveDown     := False;
          FProbeEngine.MoveLeft     := False;
          FProbeEngine.MoveRight    := False;
          FProbeEngine.Firing       := False;
    
    
          if not FShowEditorGUI and FConfiguration.SfxEnabled then
            FTeleportLevel.Play(FConfiguration.SfxVolume * 0.5);
        end;
      end;
    
    
      UpdateDoors;
    
    
      if xeEngine.Window.KeyIsHit(KEY_ESCAPE) then
      begin
        if Assigned(FRenderActiveGUI) then
        // deactivate current GUI
          ActivateGUI(nil);
    
    
        if FEditorEnabled or FSingleLevelMode then
          aExecuting := False
        else
        if not FUpdatingControl and (FDoors.Status = cDoors_Open) then
        begin
          if (FGameMode = gmMenu) and (FLastGameMode <> gmNone) then
            FDoors.Status := cDoors_Closing
          else
          if (FGameMode <> gmMenu) then
          begin
            FDoors.Status := cDoors_Closing;
    
    
            // pause playing game music
            if Assigned(FGameMusic) then FGameMusic.Pause;
          end;
        end;
      end;
    
    
      FSentryCount := FSentryCount + aTimeSlice;
      if FSentryCount >= cSentryAnimateRate then
      begin
        Inc(FSentryIndex);
        if FSentryIndex > 2 then FSentryIndex := 1;
        FSentryCount := 0;
      end;
    
    
      FTeleporterCount := FTeleporterCount + aTimeSlice;
      if FTeleporterCount >= cTeleporterAnimateRate then
      begin
        Dec(FTeleporterIndex);
        if FTeleporterIndex < 0 then FTeleporterIndex := High(FTeleporterId[True]);
        FTeleporterCount := 0;
      end;
    
    
      FVortexAngle := FVortexAngle + cVortexRotationRate * aTimeSlice;
      if FVortexAngle >= 360 then FVortexAngle := FVortexAngle - 360;
    
    
      if not FShowEditorGUI and (FGameMode = gmGamePlaying) then
      begin
        FPlayerData.Health := 0;
        if FProbeEngine.GetPlayerData(FPlayerData.PlayerFound,FPlayerData.x,FPlayerData.y,FPlayerData.Position,FPlayerData.Health,FPlayerData.PlayerObj) then
        begin
          FOffsetX := Trunc(FScreenWidth  / 2 - FPlayerData.x);
          FOffsetY := Trunc(FScreenHeight / 2 - FPlayerData.y);
          FProbeEngine.UseViewPort := True;
          FProbeEngine.SetViewPort(Trunc(FPlayerData.x - cGameViewPortW/2),Trunc(FPlayerData.y - cGameViewPortH/2),cGameViewPortW,cGameViewPortH);
        end;
    
    
        FProbeEngine.GetTLSData(FTLSData.Emitter,FTLSData.EmitterPos,FTLSData.Charge);
    
    
        if (FDoors.Status = cDoors_Open) and (FPlayerData.PlayerMode = pmNormal) and (FGameMode = gmGamePlaying) then
        begin
          FTimeCount := FTimeCount + aTimeSlice;
          if FTimeCount >= 1 then
          begin
            FTimeCount := 0;
            Inc(FTime.Seconds);
    
    
            if FTime.Seconds >= 60 then
            begin
              FTime.Seconds := 0;
              Inc(FTime.Minutes);
    
    
              if FTime.Minutes >= 60 then
              begin
                FTime.Minutes := 0;
                Inc(FTime.Hours);
              end;
            end;
          end;
        end;
      end
      else
        FProbeEngine.UseViewPort := False;
    
    
      FFlashingTimer := FFlashingTimer + 10 * aTimeSlice;
      If FFlashingTimer >= 360 Then FFlashingTimer := FFlashingTimer - 360;
    
    
      t := Sin(FFlashingTimer)/2 + 0.5;
      FFlashingAlpha := Trunc(255 * (0.4 + (1 - 0.4) * t));
    end;
    Quote Originally Posted by SilverWarior View Post
    It seems preety nice especialy now with music. I like the ingame music a lot, very energetic.
    Also I see a lot of potential in this game. That is probably the main rason why I'm so eager in monitoring its progress.
    To be honest I'm monitoring progress of many games. Belive it or not by doing so you can learn a lot about the game mechanics even without seing a single line of source code.

    Anyway keep up the good work!
    Thanks mate for the kind words, and bugs! haha
    I will be fixing these as soon as I can!

    cheers,
    Paul

  6. #146
    and here is the
    OnUpdateInput method:
    Code:
    procedure TTheProbe.OnUpdateInput(aTimeSlice: single; var aExecuting: boolean);
    const
      cFileName = 'untitled_level.lvl';
    
    
    var
      MouseX,MouseY        : LongInt;
      SelectedTile         : PEngineObject;
      MousePosValid        : Boolean;
      ClickedButton        : TEditorButton;
      Firing               : Boolean;
      KeyCode              : LongInt;
      MouseButton          : LongInt;
      GameControllerIndex  : LongInt;
      GameControllerButton : LongInt;
      LeftDown             : Boolean;
      RightDown            : Boolean;
      XDiff                : Integer;
      YDiff                : Integer;
      x,y                  : Integer;
    begin
      // update any controls that need programming
      if FUpdatingControl then
      begin
        xeEngine.Window.GetFirstHitInput(KeyCode,MouseButton,GameControllerIndex,GameControllerButton);
    
    
        if KeyCode = KEY_ESCAPE then
          FUpdatingControl := False
        else
        begin
          if KeyCode <> -1 then
          begin
            if FControlToUpdate in[GameKey_MoveUp,GameKey_MoveDown,GameKey_MoveLeft,GameKey_MoveRight,GameKey_Fire] then
            begin
              FConfiguration.Controls[FControlToUpdate] := KeyCode;
              FUpdatingControl := False;
            end;
          end;
    
    
          if GameControllerButton <> -1 then
          begin
            if FControlToUpdate = GameJoy_Fire then
            begin
              FConfiguration.Controls[FControlToUpdate] := GameControllerButton;
              FUpdatingControl := False;
            end;
          end;
        end;
      end;
    
    
      if not FUpdatingControl and not Assigned(FRenderActiveGUI) and not FSingleLevelMode and (FDoors.Status = cDoors_Open) and (FGameMode = gmMenu) and Assigned(FActiveMenu) then
      begin
        if xeEngine.Window.KeyIsHit(FConfiguration.Controls[MenuKey_MoveUp]) or
           GameControllerMovedUp then
          FActiveMenu.MoveUp
        else
        if xeEngine.Window.KeyIsHit(FConfiguration.Controls[MenuKey_MoveDown]) or
           GameControllerMovedDown then
          FActiveMenu.MoveDown
        else
        if xeEngine.Window.KeyIsHit(FConfiguration.Controls[MenuKey_Execute]) or
           (xeEngine.Window.KeyIsHit(KEY_KP_ENTER)) or
           GameControllerFired(FConfiguration.Controls[GameJoy_Fire]) then
        begin
          FActiveMenu.ExecuteSelectedItem;
    
    
          if FTerminated then aExecuting := False;
        end;
      end;
    
    
      if not FUpdatingControl and not Assigned(FRenderActiveGUI) and not FShowEditorGUI then
      begin
        if (FGameMode = gmGamePlaying) and (FPlayerData.PlayerMode = pmNormal) then
          GetPlayerInput
        else
        begin
          if FGameMode = gmGamePlayerDead then
          begin
            Firing := PlayerFiring;
    
    
            if Firing and (FProbeEngine.NumScansSinceProbeSeenAlive >= cMaxPlayerScansBeforeDead) then
            begin
              if not FSingleLevelMode and not FEditorEnabled and (FLives = 0) then
              begin
              // go back to menu
                FDoors.Status := cDoors_Closing;
                FLastGameMode := gmNone;
              end
              else
              // no menu, so just restart game again
              begin
                ResetGame;
                if FLives = 0 then
                  FLives := cDefaultLives;
                FGameMode := gmGamePlaying;
              end;
            end;
          end
          else
          if FGameMode = gmGameLevelComplete then
          begin
            Firing := PlayerFiring;
    
    
            if Firing and (FLevelCompleteTimer <= 0) then
            begin
              NextLevel;
            end;
          end;
        end;
    
    
        if not FUpdatingControl and not Assigned(FRenderActiveGUI) and FEditorEnabled and (xeEngine.Window.KeyIsDown(KEY_LCTRL) or xeEngine.Window.KeyIsDown(KEY_RCTRL)) and xeEngine.Window.KeyIsHit(KEY_E) then
        begin
          FShowEditorGUI         := True;
          FPlayerData.PlayerMode := pmNormal;
    
    
          if FConfiguration.MusicEnabled then
          begin
            if Assigned(FMenuMusic) then FMenuMusic.Resume;
            if Assigned(FGameMusic) then FGameMusic.Stop;
          end;
    
    
          ResetGame;
        end;
    
    
        if not FUpdatingControl and not Assigned(FRenderActiveGUI) and xeEngine.Window.KeyIsHit(KEY_S) and (xeEngine.Window.KeyIsDown(KEY_LCTRL) or xeEngine.Window.KeyIsDown(KEY_RCTRL)) then
        begin
          // commit suicide since playing game
          FProbeEngine.CommitSuicide;
        end;
      end
      else
      if not FUpdatingControl and not Assigned(FRenderActiveGUI) and FShowEditorGUI then
      begin
        // scroll editor level to allow clicking outside the level
        // to place items and expand level automatically.
        if xeEngine.Window.KeyIsDown(KEY_W) then
          SetMapOffsetY(GetMapOffsetY - cEditorScrollSpeed * FTimeSlice)
        else
        if xeEngine.Window.KeyIsDown(KEY_S) then
          SetMapOffsetY(GetMapOffsetY + cEditorScrollSpeed * FTimeSlice)
        else
        if xeEngine.Window.KeyIsDown(KEY_A) then
          SetMapOffsetX(GetMapOffsetX - cEditorScrollSpeed * FTimeSlice)
        else
        if xeEngine.Window.KeyIsDown(KEY_D) then
          SetMapOffsetX(GetMapOffsetX + cEditorScrollSpeed * FTimeSlice);
    
    
        // previous/next tile list in editor
        if xeEngine.Window.KeyIsHit(KEY_UP) then
          PreviousTiles(cTileHeight + 1)
        else
        if xeEngine.Window.KeyIsHit(KEY_DOWN) then
          NextTiles(cTileHeight + 1);
    
    
        SelectedTile := GetSelectedTile;
        if Assigned(SelectedTile) and (SelectedTile^.Id in cTurnableObjects) and (SelectedTile^.Value <> cObjTravelTube_ud) and (SelectedTile^.Value <> cObjTravelTube_lr) then
        begin
          if xeEngine.Window.KeyIsHit(KEY_SPACE) then
          // rotate selected tile right
            SelectedTile^.Attrib := NewDirection(SelectedTile^.Attrib,cTurnRight)
          else
          if (xeEngine.Window.KeyIsHit(KEY_X) and (SelectedTile^.Attrib in [cLeft,cRight])) or
             (xeEngine.Window.KeyIsHit(KEY_Y) and (SelectedTile^.Attrib in [cUp,cDown])) then
          // flip selected tile around perpendicular axis
          begin
            SelectedTile^.Attrib := NewDirection(NewDirection(SelectedTile^.Attrib,cTurnRight),cTurnRight);
          end;
        end;
    
    
        xeEngine.Window.GetMousePos(MouseX,MouseY);
    
    
        MousePosValid := (MouseX < cPageWidth) and (MouseY >= GetMapY) and (MouseY < (GetMapY + cPageHeight)) and not FScrolling;
    
    
        if MousePosValid then
        begin
          MouseX := Floor((MouseX - GetMapX + GetMapOffsetX) / cTileWidth);
          MouseY := Floor((MouseY - GetMapY + GetMapOffsetY) / cTileHeight);
    
    
          if xeEngine.Window.KeyIsDown(KEY_LSHIFT) or xeEngine.Window.KeyIsDown(KEY_RSHIFT) then
          // mode where starting or finishing a link
          begin
            if FActiveLinkInfo.PointIndex = 1 then
            // draw active link to current mouse tile if valid
            begin
              FActiveLinkInfo.Points[1]  := Position(MouseX,MouseY);
            end;
    
    
            if xeEngine.Window.MouseIsHit(cMouseButton_Left) then
            begin
              if FActiveLinkInfo.PointIndex = 0 then
              begin
                FActiveLinkInfo.PointIndex := 1;
                FActiveLinkInfo.Points[0]  := Position(MouseX,MouseY);
              end
              else
              if FActiveLinkInfo.PointIndex = 1 then
              begin
                FActiveLinkInfo.PointIndex := 0;
                FActiveLinkInfo.Points[1]  := Position(MouseX,MouseY);
    
    
                FProbeEngine.AddLink(FActiveLinkInfo.Points[0].x,FActiveLinkInfo.Points[0].y,
                                     FActiveLinkInfo.Points[1].x,FActiveLinkInfo.Points[1].y);
              end;
            end
            else
            if xeEngine.Window.MouseIsHit(cMouseButton_Right) then
            begin
              FProbeEngine.DeleteLinksAt(MouseX,MouseY);
    
    
              if FActiveLinkInfo.PointIndex = 1 then
              begin
                if (FActiveLinkInfo.Points[0].x = MouseX) and (FActiveLinkInfo.Points[0].y = MouseY) then
                // delete active link as clearing links at same location as link start
                  FActiveLinkInfo.PointIndex := 0;
              end;
            end;
          end
          else
          begin
            FActiveLinkInfo.PointIndex := 0;
    
    
            LeftDown  := xeEngine.Window.MouseIsDown(cMouseButton_Left);
            RightDown := xeEngine.Window.MouseIsDown(cMouseButton_Right);
    
    
            if LeftDown or RightDown and Assigned(SelectedTile) then
            begin
              if MouseX < 0 then
              // expand level left
              begin
                XDiff := Abs(MouseX);
                FProbeEngine.InsertLeftColumns(XDiff);
                MouseX := 0;
                // update offset to support insertion
                SetMapOffsetX(GetMapOffsetX + cTileWidth * xDiff);
              end
              else
              if MouseX >= FProbeEngine.Width then
              // expand level right
              begin
                XDiff := Abs(MouseX - FProbeEngine.Width) + 1;
                FProbeEngine.InsertRightColumns(XDiff);
                MouseX := FProbeEngine.Width - 1;
              end;
    
    
              if MouseY < 0 then
              // expand level up
              begin
                YDiff := Abs(MouseY);
                FProbeEngine.InsertTopRows(YDiff);
                MouseY := 0;
                // update offset to support insertion
                SetMapOffsetY(GetMapOffsetY + cTileHeight * YDiff);
              end
              else
              if MouseY >= FProbeEngine.Height then
              // expand level down
              begin
                YDiff := Abs(MouseY - FProbeEngine.Height) + 1;
                FProbeEngine.InsertBottomRows(YDiff);
                MouseY := FProbeEngine.Height - 1;
              end;
            end;
    
    
            if LeftDown then
            begin
              SelectedTile := GetSelectedTile;
              if Assigned(SelectedTile) then
                SetObjectAt(FProbeEngine,MouseX,MouseY,SelectedTile.Value);
            end
            else
            if RightDown then
              SetObjectAt(FProbeEngine,MouseX,MouseY,cObjSpace);
          end;
        end
        else
        begin
          ClickedButton := GetLastEditorButton;
    
    
          if ClickedButton = ebNewLevel then
          // do new blank level
          begin
            LoadLevel(
            [
              'TTTTTTTTTTTTT',
              'T           T',
              'T           T',
              'T           T',
              'T           T',
              'T    P      T',
              'T     3     T',
              'T    222    T',
              '>   11111   <',
              'TTTTTTTTTTTTT'
            ]
            );
            SetMapOffsetX(0);
            SetMapOffsetY(0);
          end
          else
          if ClickedButton = ebSaveLevel then
          // TODO: add GUI to ask for location + filename
          begin
            if FileExists(FLevelName) then
              FProbeEngine.SaveLevelToFile(FLevelName)
            else
              FProbeEngine.SaveLevelToFile(ExtractFilePath(ParamStr(0)) + cFileName);
          end
          else
          if ClickedButton = ebLoadLevel then
          // TODO: add GUI to ask for location + filename
          begin
            if FileExists(ExtractFilePath(ParamStr(0)) + cFileName) then
              FProbeEngine.LoadLevelFromFile(ExtractFilePath(ParamStr(0)) + cFileName);
            SetMapOffsetX(0);
            SetMapOffsetY(0);
          end
          else
          if ClickedButton = ebTestLevel then
          begin
            FProbeEngine.BackupLevel;
            FShowEditorGUI := False;
            ResetGame;
            FGameMode := gmGamePlaying;
    
    
            if FConfiguration.MusicEnabled then
            begin
              if Assigned(FMenuMusic) then FMenuMusic.Pause;
    
    
              LoadMusicTrack(FMusicTrackOrder[FMusicTrack]);
            end;
          end
          else
          if ClickedButton = ebCountCrystals then
          begin
            FProbeEngine.CountCrystals;
          end;
        end;
      end;
    
    
      if xeEngine.Window.KeyIsHit(KEY_F5) then
        xeEngine.Graphics.SaveTGAScreenShotToFile('screenshot_'+FormatDateTime('yyyymmdd_hhnnss',Now)+'.tga');
    end;
    As you can see it could use some refactoring! haha

    cheers,
    Paul

  7. #147
    From what I see your do have a bad overal code structure. No offense but I think you should do a compleete rewrite of the code. Yes I know that it would be a lot of work, but in the end you will benefit from much nicer structure wich will alow you to track bugs more easily and even lower the chances of new bugs hapenning, add new fetures, etc.
    I would recomend to use overal code structure similar to somethink like this (writen from head):
    1. Game initialization
    1.1. Initialize graphic engine
    1.2. Initialize sound engine
    1.3. Initialize input conrols
    1.4. Load most necessary graphics (the ones requred for main menu)
    1.5. Load most necessary sounds
    1.6. Set the game state to gsMainMenu
    2. Check the current gamestate
    2.1. If gamasteate is gsMainMenu then do te code for main menu
    2.1.1. Set input controls for main menu
    2.1.2. Render the main menu
    2.1.2. Make sure only main menu music is playing
    Here I asume your sond engine alows you to have mupltiple chanels for playing of multiple streams
    2.1.2.1. If some other music is playing except Main Menu music make transition by lowering lowering volume of those chanels, start playing main menu but do so with low volume. Then avery cycle repeat process except that this time jou just lower the volume of other chanels and raise volume of MainMenu music chanel. When the volume of other chanels reaches zero you stop their plaback.
    The amount of decreasing and increasing volume should be calculated based on volume settings so that the transition is done in certain amount of cylces.
    2.1.3. Check wich menu item is presed
    2.1.3.1. If new game is presed then check if there is already an active game
    2.1.3.1.1. If there is already an active game notify the user that by starting the new game he will lose all the progres off a current game
    2.1.3.1.1.1. If user confirms set gamestate to gsNewGame
    2.1.3.1.1.2. If user does not confirm return to main menu
    2.1.3.1.2. If there isnt an active game already set gamestate to gsNewGame
    2.1.3.2. If Resume game is presed change gamestate to gsGame
    2.1.3.3. If Options is presed change gamestate to gsOptions
    2.1.3.4. If Exit game is presed check if there is already an active game
    2.1.3.4.1. If there is an active game notiffy player that by exiting the game he will lose all the progres
    2.1.3.4.1.1. If the player confirms then set gamestate to gsExit
    2.1.3.4.1.2. Else return to main menu
    2.2. If gamestate is gsNew game do new game initialization
    2.2.1. Check if there is an active game already
    2.2.1.1. If it is clear the resources of the current game
    2.2.1.2. Else initialize the new game
    2.2.1.2.1. Load necessary resources
    2.2.1.2.2. Load level
    2.2.1.2.3. set gamestate to gsGame
    2.3. If gamestate is gsGame then
    2.3.1. Check if inoly ingame music is playing
    2.3.1.1. If not make transition similar than win main menu code
    2.3.1.2. Else continue wit oher code related to gameplay
    2.3.2. Set input controls to ingame controls
    2.3.3. Do teh game related procesing
    2.3.4. If game is over set gamestate to gsEndGame
    2.3.5. Render game
    2.4. If gamestate is gsEndGame clear ingame resources
    2.5. If gamestate is gsOption do stuf necessary for option menu
    2.6. If gamestate is gsExit start finilizing input, soung engine, graphic engine and finally close application.
    While this can look quite scarry at first it actualy isn't so cary. Especialy when you se that by having this kind of structure for your game would alow much more understanding code and also prevent bugs to ocur in any other parts of your code except the one you have been changing. The only ecpetion to this is if you change some code related to graphic engine, sound engine, etc.

  8. #148
    Thanks for the details mate
    I definitely am going to re-factor the code to help reduce bugs as you suggest, but I think I am going to use separate routines for each game state to separate out the stuff more and make the code less bug free...

    We will see how I go

  9. #149
    Using seperate routines for each gamestate is a good idea. Also I suggest using regions. While regions don't affect how the program will run, they can make code much more readable. The main advantage of regions is the fact that they alow you to fold the code wich is inside the region. And since you can define region boundaries as you see fit (any line you want) you gain ability for folding any part of the code. Another neat function is ability to name them with any string. So by chosing suitable name or. decription you can easily know what code in certain region is used for.
    For instance:

    Code:
    {$REGION 'Make sure only menu music is playing'}
    if IngameMusic.Playing then
    begin
      {$REGION 'Fade from ingame music to menu music'}
      if not MenuMusic.Playing then
      begin
        MenuMusic.Volume := 0;
        MenuMusic.Play;
      end;
      if IngameMusic.Volume = 0 then 
      begin
        IngameMusic.Stop;
        Exit;
      end;
      //Reduce volume of ingame music channel
      if IngameMusic.Volume > 0 then IngameMusic.Volume := IngameMusic.Volume - 10;
      //Increase volume for main menu music chanel
      if MenuMusic.Volume < 100 then MenuMusic.Volume := MenuMusic.Volume + 10;
      {ENDREGION}
    end;
    {ENDREGION}

  10. #150
    Regions, eh? Hmm...might be a good idea
    I don't know if Lazarus/Freepascal supports them though...I need my code to compile under Lazarus to make a Linux version.

    cheers,
    Paul

Page 15 of 16 FirstFirst ... 513141516 LastLast

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
  •