Results 1 to 10 of 42

Thread: SvPascal

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    I can't seem to make it work. It doesn't appear that OnAppEvent is called :?

    Code:
    type
      TShooterGame = class(TSvPrototypeGame)
      public  
        procedure OnAppEvent; override;
      end;
    
    procedure TShooterGame.OnAppEvent;
    begin
      inherited;
    
      WriteLn('AppEvent');
      WriteLn(SV.Active);
      WriteLn(SV.Minimized);
      if not SV.Active or SV.Minimized then
        StopSong(Music)
      else
        PlaySong(Music, False);
    end;
    Nothing is written in the console window when the window loses focus or is minimized.
    Imagine I've written something clever here inspiring you to make something awesome. If that happens give me credits

  2. #2
    simvector
    Guest
    Ahh your right, it's not working. Sigh. In investigating this I discovered it does not like Assigning the event handler which I'm sure is the source of this problem. If I try to manually assign it, I'm getting an incompatible type. I have to dig into it a bit more. Thanks for reporting. The SvEngine equivalent works as expected.

  3. #3
    How can I disable that Escape quits the game. And how can I make sure that 'Alt' won't make the window loose focus so I can actually use that button in a game?
    I've tried to overwrite UpdateInput(a: Single) without calling inherited but that doesn't change anything.
    Last edited by pstudio; 16-07-2011 at 05:38 PM.
    Imagine I've written something clever here inspiring you to make something awesome. If that happens give me credits

  4. #4
    simvector
    Guest
    Hi,

    1) Override TSvPrototypeGame.ProcessTerminate; By default it does this:
    Code:
    procedure TSvPrototypeGame.ProcessTerminate;
    begin
      // ESC key terminated by default
      if SV.Input.KeyHit(Key_Escape) then
      begin
        Terminated := True;
      end;
    end;
    2) You can get the KEY_LALT and/or the KEY_RALT keys but pressing ALT by itself will cause the window to loose the input focus. I have the system menu attribute added to the app window (so an icon can display) and I thinking maybe this is what's grabbing the focus. Pressing ALT will usually activate the window's menu.

    You can override and capture ALT like what I've done below. I tried to call Win32 SetFocus but it does not seem to work. I will have to look into this. I never use ALT (alway in combination with another key) by itself is why I guess I've never ran into this issue.


    Code:
    function SetFocus(hWnd: Cardinal): Cardinal; stdcall; external 'User32.dll';
    
    type
    
      TGame = class(TSvPrototypeGame)
      public
        procedure UpdateInput(aElapsedTime: single); override;
      end;
    
    procedure TGame.UpdateInput(aElapsedTime: single);
    begin
      inherited;
      if SV.Input.KeyHit(KEY_LALT) then
      begin
        Title := 'Jarrod';
        SetFocus(SV.DisplayDevice.Handle);
      end;
    end;
    Thanks for reporting.
    Last edited by simvector; 16-07-2011 at 08:07 PM.

  5. #5
    Ok, I'll look into it,

    another question: how do I get the absolute application path in SvPascal?
    Imagine I've written something clever here inspiring you to make something awesome. If that happens give me credits

  6. #6
    simvector
    Guest
    You can do this for now:
    Code:
    function GetModuleFileNameW(Module: Integer; Filename: PWideChar;
      Size: Integer): Integer; stdcall; external 'kernel32.dll';
    
    function SvStartupPath: string;
    var
      Buffer: array[0..260] of WideChar;
      i: Integer;
    begin
      Result := '';
      GetModuleFileNameW(0, Buffer, 260);
      for i := 0 to 260 do
      begin
        if Buffer[i] = #0 then
          break
        else
          Result := Result + Buffer[i];
      end;
      Result := ExtractFilePath(Result);
    end;
    You have to copy the buffer this way ATM until I get string conversion working properly.

  7. #7
    wow, seems more invovled than I would have expected . I'm gonna check it out now.

    Could you list the order of how things are rendered in TSvPrototypeGame.
    Right now it seems the TSvRenderScene.Render is called before TSvAIStateMachine.Render but I need it the other way round. I decided to use the state machine as a quick implementation for game screens. The result is that my background is drawn on top of the entities in the game.
    My guess is that I'll have to make my own implementation of RenderFrame in TSvPrototypeGame so I would like to now which things are called in it so that I don't forget to call some render function.
    Imagine I've written something clever here inspiring you to make something awesome. If that happens give me credits

Tags for this Thread

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
  •