Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: dRezEngine

  1. #1

    dRezEngine




    WHY
    After months of working on this project, I'm at a point where I can actually start working on the game (I think). The goal was to make a 2d engine that would allow me to create the whole game with minimal dependencies. I took my 10+ year engine and modernized it while adding some missing features. I was take advantage of an existing and stable code base as well as incorporate tech developed over the past few years. Its free for both commercial/non-commercial use for anyone that wants to use it. My goal in releasing it at this point is to get some feedback to see how well it work on different configurations. It's feature set was built to manage whatever project that I'm currently working on. At this stage it has all the features needed to complete the shoot'em up project that working on (planning stages at the moment).


    OVERVIEW
    dRez Engine™ is a 2D game engine for PC's running Microsoft Windows® and uses Direct3D® for hardware accelerated rendering. It's robust, designed for easy use and suitable for making all types of 2D games and other graphic simulations.

    You access the features from a simple and intuitive procedural API to allow you to rapidly and efficiently develop your graphics simulations. There is support for buffers, textures, sprites, sound, archives, tweeting, IAP, databases, remote high scores, video playback and much more.

    You can also use the thin, object oriented layer to manage your game projects in a more structured, OOP manner. You can define your game in terms of actors, where these active live and are managed on an actor list. These actors can interact by sending messages and do collisions. All of this can be encapsulated into an application using the game class.

    FEATURES
    • Made in Delphi, for Delphi developers
    • Procedural low-level access plus higher level thin OOP framework
    • Uses SDL2 2D hardware rendering
    • Uses 32bit surfaces and textures
    • Free scaling, rotation, alpha blending and other special effects
    • Windowed and fullscreen desktop modes
    • Frame based timing support
    • Memory mapped buffer support
    • Zip archive support (resourced loaded from archive or file system)
    • TrueType font support
    • Graphic primitives (lines, circles, rects, points)
    • Advanced polygon rendering (scale, rotate, control line segment visibility)
    • Advanced sprite management
    • Polypoint collision system for fast precise collision detection
    • Mouse and keyboard input management
    • Unified audio system with support for WAV, MP3, MID, OGG, MOD, IT, S3M and XM music formats
    • Comprehensive math routines (vectors, angles, line intersection, clipping)
    • Log file support
    • SQL database support (MySQL local & remote, SQLite local only)
    • High-level support for Entities
    • Basic networking (reliable UDP)
    • Tweet (with media) directly to a twitter account
    • IAP support (in-app purchase using stripe.com)
    • Includes dRezArc, an archive utility for making compressed zip archives for use in your game
    • Includes dRezPathEd, an object path editing utility for making object paths for use in your game


    MEDIA




    SOCIAL MEDIA

    Last edited by drezgames; 25-06-2018 at 01:19 AM.
    Jarrod Davis
    Proprietor @ dRez Games

  2. #2
    CHANGELOG
    Version 2018.2.alpha:
    • Misc fixes and enhancements.
    • Added BasicScript and CallScriptRoutine demos to show case how to create compile a script, create an standalone exe and how to directly call a script routine from host side.
    • Added compiled scripting support. Supports adding verinfo, exe icon, console & gui app and runtime themes. Supports making both EXE and DLLs. Good for adding scripting support for your project, modding etc all in Object Pascal.


    SCRIPTING ROUTINES
    Code:
    function  Script_Create: TScript; external cDllName;
    procedure Script_Destroy(var aScript: TScript); external cDllName;
    procedure Script_Reset(aScript: TScript); external cDllName;
    function  Script_Compile(aScript: TScript; aArchive: TArchive; aFilename: PChar): Boolean; external cDllName;
    function  Script_CreateModule(aScript: TScript; aName: PChar; aConsoleApp: Boolean; aAddVerInfo: Boolean; aArchive: TArchive; aIconFilename: PChar; aEnableRuntimeThemes: Boolean): PChar; external cDllName;
    function  Script_ErrorCount(aScript: TScript): Integer; external cDllName;
    function  Script_WarningCount(aScript: TScript): Integer; external cDllName;
    function  Script_ErrorMessage(aScript: TScript; aIndex: Integer): PChar; external cDllName;
    function  Script_WarningMessage(aScript: TScript; aIndex: Integer): PChar; external cDllName;
    procedure Script_SaveProgram(aScript: TScript; aFilename: PChar); external cDllName;
    procedure Script_LoadProgram(aScript: TScript; aArchive: TArchive; aFilename: PChar); external cDllName;
    procedure Script_Run(aScript: TScript); external cDllName;
    function  Script_CallRoutine(aScript: TScript; aFullname: PChar; aParamList: array of OleVariant): OleVariant; external cDllName;
    function  Script_CreateObject(aScript: TScript; aClassName: PChar; aParamList: array of const): TObject; external cDllName;
    procedure Script_DestroyObject(aScript: TScript; aObject: TObject); external cDllName;
    function  Script_CallMethod(aScript: TScript; aFullname: PChar; aInstance: TObject; aParamList: array of OleVariant): OleVariant; external cDllName;
    function  Script_GetAddress(aScript: TScript; aFullname: PChar): Pointer; external cDllName;
    procedure Script_SetCompileEvent(aScript: TScript; aSender: Pointer; aHandler: TScriptCompileEvent); external cDllName;
    procedure Script_GetCompileEvent(aScript: TScript; var aSender: Pointer; var aHandler: TScriptCompileEvent); external cDllName;
    procedure Script_SetMessageEvent(aScript: TScript; aSender: Pointer; aHandler: TScriptMessageEvent); external cDllName;
    procedure Script_GetMessageEvent(aScript: TScript; var aSender: Pointer; var aHandler: TScriptMessageEvent); external cDllName;
    function  Script_RegisterNamespace(aScript: TScript; aLevelId: Integer; aNamespaceName: PChar): Integer; external cDllName;
    function  Script_RegisterRecordType(aScript: TScript; aLevelId: Integer; aTypeName: PChar): Integer; external cDllName;
    function  Script_RegisterRecordTypeField(aScript: TScript; RecordTypeId: Integer; aFieldName: PChar; aFieldTypeID: Integer): Integer; external cDllName;
    function  Script_RegisterSubrangeType(aScript: TScript; aLevelId: Integer; aTypeName: PChar; aTypeBaseId: Integer; aB1: Integer; aB2: Integer): Integer; external cDllName;
    function  Script_RegisterArrayType(aScript: TScript; aLevelId: Integer; aTypeName: PChar; aRangeTypeId: Integer; aElemTypeId: Integer): Integer; external cDllName;
    function  Script_RegisterPointerType(aScript: TScript; aLevelId: Integer; aTypeName: PChar; aOriginTypeId: Integer): Integer; external cDllName;
    function  Script_RegisterSetType(aScript: TScript; aLevelId: Integer; aTypeName: PChar; aOriginTypeId: Integer): Integer; external cDllName;
    function  Script_RegisterProceduralType(aScript: TScript; aLevelId: Integer; aTypeName: PChar; aSubId: Integer): Integer; external cDllName;
    function  Script_RegisterVariableType(aScript: TScript; aLevelId: Integer; aName: PChar; aTypeId: Integer): Integer; external cDllName;
    function  Script_RegisterVariable(aScript: TScript; aLevelId: Integer; aDeclaration: PChar; aAddress: Pointer): Integer; external cDllName;
    function  Script_RegisterClassType(aScript: TScript; aLevelId: Integer; aClass: TClass): Integer; external cDllName;
    function  Script_RegisterHeader(aScript: TScript; aLevelId: Integer; aHeader: PChar; aAddress: Pointer): Integer; external cDllName;
    function  Script_RegisterConstant(aScript: TScript; aLevelId: Integer; aDeclaration: PChar): Integer; external cDllName;
    function  Script_RegisterConstantValue(aScript: TScript; aLevelId: Integer; aName: PChar; aValue: Variant): Integer; external cDllName;
    function  Script_LookupTypeId(aScript: TScript; aTypeName: PChar): Integer; external cDllName;
    function  Script_LookupTypeNamespaceId(aScript: TScript; aTypeName: PChar): Integer; external cDllName;
    procedure Script_SetVersionInfo(aScript: TScript; aCompanyName: PChar; aFileVersion: PChar;
      aFileDescription: PChar; aInternalName: PChar; aLegalCopyright: PChar;
      aLegalTrademarks: PChar; aOriginalFilename: PChar; aProductName: PChar;
      aProductVersion: PChar; aComments: PChar); external cDllName;
    EXAMPLE
    Code:
    unit uBasicScriptDemo;
    
    interface
    
    uses
      System.SysUtils,
      dRez.Engine,
      uCommon;
    
    type
    
    { --- TBasicScriptDemo ------------------------------------------------------ }
      TBasicScriptDemo = class(TdeBaseGame)
      protected
        FArchive: TArchive;
        FScript: TScript;
        procedure ShowWarnings;
        procedure ShowErrors;
      public
        procedure CompileEvents(aFilename: string);
        procedure MessageEvents(aMessage: string);
        procedure Run; override;
      end;
    
    
    implementation
    
    uses
      System.IOUtils;
    
    { --- TBasicScriptDemo ------------------------------------------------------ }
    procedure TBasicScriptDemo_ScriptCompileEvents(aSender: Pointer; aFilename: PChar);
    begin
      TBasicScriptDemo(aSender).CompileEvents(aFilename);
    end;
    
    procedure TBasicScriptDemo_ScriptMessageEvents(aSender: Pointer; aMessage: PChar);
    begin
      TBasicScriptDemo(aSender).MessageEvents(aMessage);
    end;
    
    procedure TBasicScriptDemo.CompileEvents(aFilename: string);
    begin
      if not ConsoleApp then Exit;
    
      // display the current file being compiled
      WriteLn('Compiling ', aFilename, '...');
    end;
    
    procedure TBasicScriptDemo.MessageEvents(aMessage: string);
    begin
      if not ConsoleApp then Exit;
    
      WriteLn(aMessage);
    end;
    
    procedure TBasicScriptDemo.ShowWarnings;
    var
      i,c: Integer;
    begin
      if not ConsoleApp then Exit;
    
      // get warning count
      c := Script_WarningCount(FScript);
    
      // display wanring message
      for i := 0 to c-1 do
      begin
        WriteLn(Script_WarningMessage(FScript, i));
      end;
    end;
    
    // show compile errors
    procedure TBasicScriptDemo.ShowErrors;
    var
      i,c: Integer;
    begin
      if not ConsoleApp then Exit;
    
      // get error count
      c := Script_ErrorCount(FScript);
    
      // display error message
      for i := 0 to c-1 do
      begin
        WriteLn(Script_ErrorMessage(FScript, i));
      end;
    end;
    
    procedure TBasicScriptDemo.Run;
    var
      fn: string;
    begin
      // check if archive exist, open it
      fn := TPath.ChangeExtension(ParamStr(0), 'arc');
      if TFile.Exists(fn) then
        begin
          FArchive := Archive_Create;
          Archive_Open(FArchive, cArcPassword, 'Examples.arc');
        end
      else
        begin
          // otherwise make sure its nil
          FArchive := nil;
        end;
    
      // create script object
      FScript := Script_Create;
    
      // set script compile event handler
      Script_SetCompileEvent(FScript, Self, TBasicScriptDemo_ScriptCompileEvents);
    
      // set script mesage event handler
      Script_SetMessageEvent(FScript, Self, TBasicScriptDemo_ScriptMessageEvents);
    
      // compile script. if FArchive is not nil will load from archive else
      // directly from filesystem
      if Script_Compile(FScript, FArchive, 'arc/scripts/test.pas') then
        begin
          // show compiler warnings
          ShowWarnings;
    
          // run whole script
          //Script_Run(FScript);
          Script_SetVersionInfo(FScript,
            'dRez Games',                     // CompanyName
            '1.0.0.0',                        // FileVersion (must use x.x.x.x format)
            'Basic Script Demo',              // FileDescription
            'Basic Script Demo',              // InternalName
            'Copyright (c) 2018 dRez Games',  // LegalCopyright
            'All Rights Reserved',            // LegalTrademarks
            'BasicScriptDemo.exe',            // OriginalFilename
            'Basic Script Demo',              // ProductName
            '1.0.0.0',                        // ProductVersion
            'https://drez.games');            // Comments
          fn := Script_CreateModule(FScript, 'BasicScriptDemo', False, True, FArchive, 'arc/icons/icon-2.ico', True);
          if fn <> '' then
          begin
            if ConsoleApp then
            begin
              WriteLn('Created module: ', fn);
            end;
            fn := Tpath.GetFullPath(fn);
            SelectFileInExplorer(PChar(fn));
          end;
        end
      else
        begin
          // show comopiler errors
          ShowErrors;
        end;
    
      // destroy script object
      Script_Destroy(FScript);
    
      // dispose archive
      Archive_Destroy(FArchive);
    end;
    
    end.
    SCRIPT
    Code:
    unit uTest;
    
    interface
    
    procedure Example_Script;
    
    implementation
    
    uses
      dRez.Engine;
    
    const
      cWindowWidth        = 480;
      cWindowHeight       = 600;
      cFullscreen         = False;
      
    // window ready event handler - can be used for example to pause music/sound
    // if window does not have focus, mininized etc.
    procedure Window_ReadyEvent;
    begin
      if not ConsoleApp then Exit;
      
      if Window_Ready then
        WriteLn('Window ready...')
      else
        WriteLn('Window not ready...');
    end;
    
    procedure Example_Script;
    var
      Starfield: TStarfield;
    begin
      // open app window
      Window_Open('dRez Engine - Basic Script Demo', cWindowWidth, cWindowHeight, cFullscreen, False);
    
      // set event handle that will be called if window is ready or not
      Window_SetReadyEvent(nil, @Window_ReadyEvent);
      
      Starfield := Starfield_Create;
    
      // LGL game loop - until app has terminated
      while not Terminated do
      begin
        // process events (kbd, mouse, window, etc)
        ProcessEvents;
    
        // check if app window is ready (has focus, not minimized)
        if not Window_Ready then
        begin
          // delay for 1 millisecond (allow background tasks to run)
          Delay(1);
    
          // continue to process events
          continue;
        end;
    
        // terminate on ESC
        if Keyboard_Pressed(KEY_ESCAPE) then
          Terminate(True);
    
        // toggle fullscreen on F11
        if Keyboard_Pressed(KEY_F11) then
          Window_ToggleFullscreen;
    
        // screenshot on F12
        if Keyboard_Pressed(KEY_F12) then
          Screenshot_Take;
    
        Starfield_Update(Starfield, DeltaTime);  
          
        // clear background to a color
        Renderer_ClearFrame(BLACK);
    
        Starfield_Render(Starfield);
        
        // display hud
        Font_DrawFPS(ConsoleFont, 3, 3, GREEN, 12);
        Font_DrawText(ConsoleFont, 3, 15, GREEN, 12, 'ESC - Quit');
        Font_DrawText(ConsoleFont, 3, 30, GREEN, 12, 'F11 - Toggle Fullscreen');
        Font_DrawText(ConsoleFont, 3, 45, GREEN, 12, 'F12 - Screenshot');
    
        // show frame buffer
        Renderer_ShowFrame;
    
      end;
    
      Starfield_Destroy(Starfield);
      
      // close app window
      Window_Close;
    end;
    
    end.
    Jarrod Davis
    Proprietor @ dRez Games

  3. #3
    Where is it possible to download this engine ?

  4. #4
    Hi, the latest version will always be the download link in the 1st post.
    Jarrod Davis
    Proprietor @ dRez Games

  5. #5
    Starting to implement a physics system (basic for now). Here is what I have so far:



    PHYSICS
    Code:
    procedure Physics_Open;
    procedure Physics_Close;
    function  Physics_Opened: Boolean;
    procedure Physics_Reset;
    procedure Physics_SetGravity(aX: Single; aY: Single);
    procedure Phsycis_GetGravity(aX: PSingle; aY: PSingle);
    procedure Physics_Destroy(aBody: TPhysicsBody);
    function  Physics_CreateCircleBody(aX: Single; aY: Single; aRadius: Single; aDensity: Single): TPhysicsBody;
    function  Physics_CreateRectangleBody(aX: Single; aY: Single; aWidth: Single; aHeight: Single; aDensity: Single): TPhysicsBody;
    function  Physics_CreatePolygonBody(aX: Single; aY: Single; aRadius: Single; aSides: Integer; aDensity: Single): TPhysicsBody;
    procedure Physics_GetPosition(aBody: TPhysicsBody; aX: PSingle; aY: PSingle);
    function  Physics_Enabled(aBody: TPhysicsBody): Boolean;
    procedure Physics_SetEnabled(aBody: TPhysicsBody; aValue: Boolean);
    procedure Physics_UseGravity(aBody: TPhysicsBody; aValue: Boolean);
    procedure Physics_AddForce(aBody: TPhysicsBody; aX: Single; aY: Single);
    procedure Physics_AddTorque(aBody: TPhysicsBody; aAmount: Single);
    procedure Physics_Rotate(aBody: TPhysicsBody; aAngle: Single);
    function  Physics_Orientation(aBody: TPhysicsBody): Single;
    function  Physics_BodyCount: Integer;
    function  Physics_Body(aIndex: Integer): TPhysicsBody;
    function  Physics_Shape(aBody: TPhysicsBody): Integer;
    function  Physics_ShapeVertexCount(aIndex: Integer): Integer;
    function  Physics_ShapeVertex(aBody: TPhysicsBody; aVertex: Integer): TPointf;
    procedure Physics_RenderShapes(aColor: dRez.Engine.TColor);
    function  Physics_Visible(aBody: TPhysicsBody): Boolean;
    procedure Physics_SetVisible(aBody: TPhysicsBody; aValue: Boolean);
    function  Physics_Radius(aBody: TPhysicsBody): Single;
    procedure Physics_Size(aBody: TPhysicsBody; aWidth: PSingle; aHeight: PSingle);
    EXAMPLE
    Code:
    program physac_test;
    
    {$APPTYPE CONSOLE}
    
    {$R *.res}
    
    uses
      System.SysUtils,
      dRez.Engine in '..\..\..\libs\dRez.Engine.pas';
    
    const
      screenWidth = 800;
      screenHeight = 450;
    
    var
      logoX: Integer;
      logoY: Integer;
      needsReset: Boolean;
      floor, circle, body: TPhysicsBody;
      bodiesCount: Integer;
      i, fw: Integer;
      mx,my: Integer;
      bx,by: Single;
      hx,hy: Integer;
    begin
      // open app window
      Window_Open('Physics Demo', screenWidth, screenHeight, False, False);
    
      Font_TextSize(Font, 30, 'dRezPhysics', @fw, nil);
    
      logoX := screenWidth - fw - 10;
      logoY := 15;
      needsReset := false;
    
      Physics_Open;
    
      floor := Physics_CreateRectangleBody(screenWidth/2, screenHeight, 500, 100, 10);
      Physics_SetEnabled(floor, False);
      Physics_SetVisible(floor, True);
    
      circle := Physics_CreateCircleBody(screenWidth/2, screenHeight/2, 45, 10);
      Physics_SetEnabled(circle, False);
      Physics_SetVisible(circle, True);
    
      // game loop - until app has terminated
      while not Terminated do
      begin
        // process events (kbd, mouse, window, etc)
        ProcessEvents;
    
        // check if app window is ready (has focus, not minimized)
        if not Window_Ready then
        begin
          // delay for 1 millisecond (allow background tasks to run)
          Delay(1);
    
          // continue to process events
          continue;
        end;
    
        if (needsReset) then
        begin
          floor := Physics_CreateRectangleBody(screenWidth/2, screenHeight, 500, 100, 10);
          Physics_SetEnabled(floor, False);
          Physics_SetVisible(floor, True);
    
          circle := Physics_CreateCircleBody(screenWidth/2, screenHeight/2, 45, 10);
          Physics_SetEnabled(circle, False);
          Physics_SetVisible(circle, True);
    
          needsReset := False;
        end;
    
        if Keyboard_Pressed(KEY_R) = true then
        begin
          Physics_Reset;
          needsReset := True;
        end;
    
        if (Mouse_Pressed(MOUSE_BUTTON_LEFT) or Keyboard_Pressed(KEY_1)) then
          begin
            Mouse_GetPosition(@mx, @my);
            body := Physics_CreatePolygonBody(mx, my, Random_Rangef(20, 80), Random_Rangei(3, 8), 10);
            Physics_SetVisible(body, True);
    
          end
        else if (Mouse_Pressed(MOUSE_BUTTON_RIGHT) or Keyboard_Pressed(KEY_2)) then
          begin
            Mouse_GetPosition(@mx, @my);
            body := Physics_CreateCircleBody(mx, my, Random_Rangef(10, 45), 10);
            Physics_SetVisible(body, True);
          end;
    
    
        bodiesCount := Physics_BodyCount;
        for i := bodiesCount - 1 downto 0 do
        begin
          body := Physics_Body(i);
          Physics_GetPosition(body, @bx, @by);
          if (body <> nil) and (by > screenHeight * 2) then
            begin
              Physics_Destroy(body);
            end;
        end;
    
        // clear background to a color
        Renderer_ClearFrame(BLACK);
    
        Physics_RenderShapes(GREEN);
    
        Font_DrawFPS(ConsoleFont, 3, 3, WHITE, 12);
    
        hx := 100;
        hy := 30;
        Font_DrawTextY(ConsoleFont, hx, hy, 15, WHITE, 12, 'Left mouse button to create a polygon');
        Font_DrawTextY(ConsoleFont, hx, hy, 15, WHITE, 12, 'Right mouse button to create a circle');
        Font_DrawTextY(ConsoleFont, hx, hy, 15, WHITE, 12, 'Press "R" to reset example');
    
        Font_DrawText(Font, logoX, logoY, WHITE, 30, 'dRezPhysics');
        Font_DrawText(ConsoleFont, logoX+45, logoY-13, WHITE, 12, 'Powered by');
    
        // show frame buffer
        Renderer_ShowFrame;
    
      end;
    
      Physics_Close;
    
      // close app window
      Window_Close;
    end.
    Jarrod Davis
    Proprietor @ dRez Games

  6. #6
    Currently working in an IMGUI system. It very much WIP but coming along well.

    MEDIA


    CODE
    Code:
      TdeGuiSliderEvent = procedure(aSender: Pointer; aId: Integer; aValue: Single; aMinValue: Single; aMaxValue: Single);
      TdeGuiButtonEvent = procedure(aSender: Pointer; aId: Integer);
    
    { --- TdeIMGUI -------------------------------------------------------------- }
      TdeIMGUI = class(TdeBaseObject)
      protected
        FStyle: array[DEFAULT_BACKGROUND_COLOR..LISTVIEW_TEXT_COLOR_DISA  BLED] of Integer;
        FGuiState: TdeGuiControlState;
        FGuiAlpha: Single;
        FCursorTimer: Single;
        FCursorBlink: Boolean;
        function VALIGN_OFFSET(aHeight: Integer): Integer; inline;
        function GetColor(aValue: Cardinal): TColor;
        function Fade(aColor: TColor; aAlpha: Single): TColor;
        function CheckCollisionPointRec(aX: Integer; aY: Integer; aBounds: TRect): Boolean;
        function IsMouseButtonDown(aButton: Integer): Boolean;
        function IsMouseButtonReleased(aButton: Integer): Boolean;
        function IsMouseButtonUp(aButton: Integer): Boolean;
        function GetKeyPressed: Integer;
        function IsKeyPressed(aKey: Integer): Boolean;
        function IsKeyDown(aKey: Integer): Boolean;
        procedure DrawRectangleLines(aBounds: TRect;  aThick: Integer; aColor: TColor);
        procedure DrawRectangle(aX: Integer; aY: Integer; aWidth: Integer; aHeight: Integer; aColor: TColor);
        procedure DrawRectangleRec(aRec: TRect; aColor: TColor);
        function MeasureText(aText: string; aFontSize: Integer): Integer;
        procedure DrawText(aText: string; aX: Integer; aY: Integer; aFontSize: Integer; aColor: TColor);
        procedure SetGuiFade(aValue: Single);
      public
        property GuiAlpha: Single read FGuiAlpha write SetGuiFade;
        constructor Create; override;
        destructor Destroy; override;
        procedure SetProperty(aProperty: TdeGuiProperty; aValue: Cardinal);
        function GetProperty(aProperty: TdeGuiProperty): Cardinal;
        procedure Enable;
        procedure Disable;
        procedure &Label(aBounds: TRect; aText: string);
        function LabelButton(aBounds: TRect; aText: string): Boolean;
        function Button(aBounds: TRect; aText: string; aSender: Pointer=nil; aId: Integer=-1; aEventHandler: TdeGuiButtonEvent=nil): Boolean;
        function TextBox(aBounds: TRect; var aText: string; aTextSize: Integer; aEditMode: Boolean): Boolean;
        function CheckBox(aBounds: TRect; var aChecked: Boolean): Boolean;
        function CheckBoxExt(aBounds: TRect; var aChecked: Boolean; aText: string): Boolean;
        function Slider(aBounds: TRect; var aValue: Single; aMinValue: Single; aMaxValue: Single; aSender: Pointer=nil; aId: Integer=-1; aEventHandler: TdeGuiSliderEvent=nil): Single;
    
        procedure UseDefaultLightStyle;
        procedure UseDefaultDarkStyle;
      end;
    DEMO
    Code:
    program gui_test;
    
    {$APPTYPE CONSOLE}
    
    {$R *.res}
    
    uses
      System.SysUtils,
      dRez.Engine.IMGUI in '..\..\libs\dRez.Engine.IMGUI.pas',
      dRez.Engine in '..\..\libs\dRez.Engine.pas';
    
    const
      cWindowWidth        = 480;
      cWindowHeight       = 600;
      cFullscreen         = False;
    
    var
      Starfield: TStarfield;
      Gui: TdeIMGUI;
      name: string = 'Jarrod';
      check1: boolean = True;
      check2: Boolean = False;
      check3: Boolean = False;
      enable_disable: array[false .. true] of string = ('disabled', 'enabled');
      volume: Single = 1;
      music: TMusic;
      button_status: array[0 .. 1] of string;
    
      procedure UpdateMusicVolume(aSender: Pointer; aId: Integer; aValue: Single; aMinValue: Single; aMaxValue: Single);
      begin
        Music_SetVolume(aValue);
      end;
    
      procedure ButtonClicked(aSender: Pointer; aId: Integer);
      var
        s: string;
      begin
        s := '';
        case aId of
          0:
          begin
            button_status[0] :='Button 1 clicked';
            button_status[1] :='';
          end;
          1:
          begin
            button_status[0] :='';
            button_status[1] :='Button 2 clicked';
          end;
        end;
    
      end;
    
    begin
    
      // open app window
      Window_Open('dRez Engine - Basic GUI Demo', cWindowWidth, cWindowHeight, cFullscreen, False);
    
      music := Music_Load(nil, 'arc/music/opus.mp3');
      Music_Play(music, volume, -1);
    
      Starfield := Starfield_Create;
    
      gui := TdeIMGUI.Create;
      //gui.SetProperty(SLIDER_SLIDER_WIDTH, 5);
    
      // LGL game loop - until app has terminated
      while not Terminated do
      begin
        // process events (kbd, mouse, window, etc)
        ProcessEvents;
    
        // check if app window is ready (has focus, not minimized)
        if not Window_Ready then
        begin
          // delay for 1 millisecond (allow background tasks to run)
          Delay(1);
    
          // continue to process events
          continue;
        end;
    
        // terminate on ESC
        if Keyboard_Pressed(KEY_ESCAPE) then
          Terminate(True);
    
        // toggle fullscreen on F11
        if Keyboard_Pressed(KEY_F11) then
          Window_ToggleFullscreen;
    
        // screenshot on F12
        if Keyboard_Pressed(KEY_F12) then
          Screenshot_Take;
    
        if Keyboard_Pressed(KEY_1) then
          gui.GuiAlpha := 0.1;
    
        if Keyboard_Pressed(KEY_2) then
          gui.GuiAlpha := 1.0;
    
    
        Starfield_Update(Starfield, DeltaTime);
    
        // clear background to a color
        Renderer_ClearFrame(BLACK);
    
        Starfield_Render(Starfield);
    
        // display hud
        Font_DrawFPS(ConsoleFont, 3, 3, GREEN, 12);
        Font_DrawText(ConsoleFont, 3, 15, GREEN, 12, 'ESC - Quit');
        Font_DrawText(ConsoleFont, 3, 30, GREEN, 12, 'F11 - Toggle Fullscreen');
        Font_DrawText(ConsoleFont, 3, 45, GREEN, 12, 'F12 - Screenshot');
        //Font_DrawText(ConsoleFont, 3, 60, GREEN, 12, PChar('hex - ' + gui.Test));
    
    
        gui.&Label(TRect.Create(3, 100, 50, 15), 'A LABEL');
    
        gui.Button(TRect.Create(3, 120, 70, 30), 'BUTTON 1', nil, 0, ButtonClicked);
        gui.&Label(TRect.Create(80, 128, 50, 15), button_status[0]);
    
    
        gui.Button(TRect.Create(3, 160, 70, 30), 'BUTTON 2', nil, 1, ButtonClicked);
        gui.&Label(TRect.Create(80, 168, 50, 15), button_status[1]);
    
        gui.TextBox(TRect.Create(3, 200, 70, 30), name, 30, true);
        gui.CheckBox(TRect.Create(3, 240, 20, 20), check1);
    
        if gui.LabelButton(TRect.Create(3, 270, 70, 30), 'LABEL BUTTON') then WarningDlg('Label Button');
    
        gui.CheckBoxExt(TRect.Create(3, 300, 10, 10), check2, 'Item 1 (' + enable_disable[check2] + ')' );
        gui.CheckBoxExt(TRect.Create(3, 320, 10, 10), check3, 'Item 2 (' + enable_disable[check3] + ')');
    
        gui.Slider(TRect.Create(10, 340, 50, 10), volume, 0, 1, nil, 0, UpdateMusicVolume);
        gui.&Label(TRect.Create(70, 340, 50, 15), 'Music Volume');
    
    
        // show frame buffer
        Renderer_ShowFrame;
    
      end;
    
      gui.Free;
    
      Starfield_Destroy(Starfield);
    
      Music_Destroy(music);
    
      // close app window
      Window_Close;
    
    end.
    Jarrod Davis
    Proprietor @ dRez Games

  7. #7
    Added more controls, enough now I think for use in an upcoming project.

    Jarrod Davis
    Proprietor @ dRez Games

  8. #8
    At this point (I hope) I got all the features needed for current project. I got the IMGUI system finished off. You can now save/load styles with a few styles available (dark, light, candy and cherry). In addition you can do in app purchase via Stripe.com and even tweet directly to a twitter account. Below is an example of the TdeMenu class. It's a basic text based menu system that's very flexible (lots of event handlers so you can control/customize many features).

    Jarrod Davis
    Proprietor @ dRez Games

  9. #9
    Glad to see you are still working on this project mate

    Have you used yet another name for your company? It is hard to keep track I must admit

    Keep up all the hard work bro!!
    Looking good

    cheers,
    Paul

  10. #10
    Quote Originally Posted by paul_nicholls View Post
    Glad to see you are still working on this project mate

    Have you used yet another name for your company? It is hard to keep track I must admit

    Keep up all the hard work bro!!
    Looking good

    cheers,
    Paul
    Paul, sup man. How have you been my friend? Hope all is well. Yea, finally got old code base modernized and all the features that I wanted to get in. Just wanted everything to be in place to do my projects. You know, I tried to contact you a time or two. The last time I made contact was GMS humble bundle sale (I think). Later, I emailed you the changes in direction I was making and seeing if you could give me some feedback on some things I was working on. No response. Any old emails you would have at the time would have still redirected back to me. But any way, glad to hear from you. How goes your gamedev projects? I think I tried to contact via your syntax error software domain. It was/is down. Do you still have this anywhere? At the time, the email I had of yours, it was getting flagged and my emails returning. The IPs I had at the time for my server, apparently was abused by a previous user so it had gotten on some spam blocking sites that I had to spend so much time to get clean. What a PITA that was. (Note, if you ever get a server, make sure you request clean IPs). I have not been back to PGD in about 6-8 months maybe? Forgot to try to PM you from PGD, oh well, haha.
    Jarrod Davis
    Proprietor @ dRez Games

Page 1 of 2 12 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
  •  
Comodo SSL