Where is it possible to download this engine ?
Where is it possible to download this engine ?
Hi, the latest version will always be the download link in the 1st post.
Starting to implement a physics system (basic for now). Here is what I have so far:
PHYSICS
EXAMPLECode: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);
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.
Currently working in an IMGUI system. It very much WIP but coming along well.
MEDIA
CODE
DEMOCode: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;
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.
Added more controls, enough now I think for use in an upcoming project.
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).
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
Games:
Seafox
Pages:
Syntax Error Software
itch.io page
Online Chess
http://gameknot.com/#paul_nicholls
Bookmarks