Page 4 of 5 FirstFirst ... 2345 LastLast
Results 31 to 40 of 42

Thread: SvPascal

  1. #31
    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.

  2. #32
    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

  3. #33
    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.

  4. #34
    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

  5. #35
    simvector
    Guest
    This is what ParamStr(0) does with the exception of the loop. In the end I will simply bind to ParamStr but in the current build this is not done so the only way to do it is to call on win32 to do it. The good thing is that SvPascal is able to do it in it's current state. I was pleasantly surprised that I actually got it to work. Normally you can typecast the buffer array to string which is currently not working correctly. So I had to loop and copy the buffer.

    SvPascal binds directly to SvEngine.pas and SvEngineFramework.pas (SvEngine, bindings folder) so you can view directly what's going on from those units. Here is the current implementation:
    Code:
    procedure TSvPrototypeGame.RenderFrame;
    begin
      FScene.Render(FSceneAttr);
      FStateMachine.Render;
    end;
    You can override renderframe like this:
    Code:
    procedure TMyGame.RenderFrame;
    begin
      StateMachine.Render;
      Scene.Render(SceneAttr);
    end;
    You can also take advantage of the attribute feature and tell Scene.Render to only render specific objects with attributes set. Each TSvObject can have up to 256 attributes, numbered from 0-255. They can be on/off. So player can be 0, enemy can be 1, rocks 2 and so on. If you do not want to render anything, set MyGame.SceneAttr := [255] for example and nothing will be rendered in this case. If you only want to update certain object and not others, just tell game which ones and only they will render/update.

    Glad to see you trying the AI stuff. What I've implemented is what I call an event driven state machine. Makes it very easy to organize your game into be and ran by states. I'm currently working on a game project that will be using them also. My goal for this game project is to make the code very data driven and build a level editor around it. I will be taking advantage of component based design. SvEngine framework is built around this principle already. Actors have children which can update/render, can have a state machine and the game classes has a state machine for use at the upper level.
    Last edited by simvector; 16-07-2011 at 11:51 PM.

  6. #36
    simvector
    Guest
    This is an early screenshot of the redesign we are doing to SvPascal. We got some great user feedback and we will try to incorporate as many as we can. Another big change is that SvPascal will be using a different compiler back end (FreePascal) which required some architectural changes to accommodate this. I've been experimenting with adding debugging support (GDB) and it's looking like it will happen too. I've now figured out how to talk to the debugger and control it from the IDE. Pretty cool stuff. First step will be to step through the code from the IDE and then later to add more advanced features. More information coming soon.

    Last edited by simvector; 29-07-2011 at 03:22 AM.

  7. #37
    yay! Go Jarrod

    cheers,
    Paul

  8. #38
    That definitely looks like an improved editor IMO. Looking foreward to try it out sometime.
    Imagine I've written something clever here inspiring you to make something awesome. If that happens give me credits

  9. #39
    simvector
    Guest
    @paul_nicholls, @pstudio

    Thanks. Things are coming along well. Learning lots of great and new stuff especially with external debugging and interfacing to and controlling an external process. Capturing console output can be tricky, but I now think I've got that sorted out as you can see in the message output window. The first redesign release most likely will not have debugging yet. I want to get the core solid with minimal bugs then start to add more features from there. If you would like to try WIP builds, let me know. The feedback would invaluable. Thanks.

  10. #40
    simvector
    Guest
    This is what I've got working so far:


    • menus now work
    • you can change editor, syntax highlighting and key mapping
    • sync editing
    • will reload last project on start up
    • forcibly terminate a process
    • can run the FontStudio util (I forgot to add it to this build however, doh!)
    • now display info in the caption like Delphi
    • smart compile, full build and final build
    • run without debug info, run with debug info (in preparation for integrated debugging)
    • final build will pack executable using UPX (if enabled)
    • toggle run-time theme support
    • toggle version info
    • change editor options
    • change syntax highlighting options
    • change key mapping
    • toggle code folding
    • toggle visible line numbers
    • sync editing
    • tabs across top of edit window for quick access to files
    • project manager tree view
    • source structure tree view
    • print and print preview
    • feedback dialog
    • make program and dll projects
    • add units and include files in projects
    • minimalist freepascal now used for compiler back end
    • more bug fixes.


    Screenshot
    svpascal_wip.jpg

    Download (temp link only up for a few days)
    Last edited by simvector; 02-08-2011 at 06:59 AM.

Page 4 of 5 FirstFirst ... 2345 LastLast

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
  •