PureBasic Forum
https://www.purebasic.fr/english/

[ENGINE] 2D Engine Nautilus (Win x86 & x64)
https://www.purebasic.fr/english/viewtopic.php?f=14&t=73077
Page 1 of 3

Author:  Mijikai [ Sun Jun 23, 2019 1:08 pm ]
Post subject:  [ENGINE] 2D Engine Nautilus (Win x86 & x64)

Image

Nautilus is a small 2D (OpenGL) Engine

Features:
- easy rendering interfaces
- simple animation system for tiles
- layer support (layer 0 - 9 or unlimited in succession)
- viewport can be locked to the aspect ration (window resizing)
- clipping (area masking)
- support for bitmap fonts
- easy drawing of primitives (box, circle, line, ...)
- keyboard and mouse support
- independent viewport dimensions

Note:
Use the Unicode compiler.
There is no documentation right now but most of the functions are self-explanatory.

If you have questions, ideas or critique let me know :)

Current Version / Last Update:
https://www.purebasic.fr/english/viewtopic.php?f=14&t=73077&p=557027#p557027

Author:  Mijikai [ Sat Jun 29, 2019 10:34 am ]
Post subject:  Re: [ENGINE] 2D Engine Nautilus (Win)

Update: Version 0.26 beta

Added functions to create lights within the Engine.

New core function:
Code:
;...
CreateLight(Width.i,Height.i)
;...


New interface:
Code:
Interface NAUTILUS_LIGHT;light texture object/interface created with CreateLight()
  Point.i(X.i,Y.i,Radius.i,ColorARGB.i = $FFFFFFFF)
  PointLinear.i(X.i,Y.i,Radius.i,X1.i,Y1.i,X2.i,Y2.i,ColorARGB.i = $FFFFFFFF)
  Box.i(X.i,Y.i,Width.i,Height.i,ColorARGB.i = $FFFFFFFF)
  BoxLinear.i(X.i,Y.i,Width.i,Height.i,X1.i,Y1.i,X2.i,Y2.i,ColorARGB.i = $FFFFFFFF)
  Area.i(X.i,Y.i,RadiusX.i,RadiusY.i,ColorARGB.i = $FFFFFFFF)
  AreaLinear.i(X.i,Y.i,RadiusX.i,RadiusY.i,X1.i,Y1.i,X2.i,Y2.i,ColorARGB.i = $FFFFFFFF)
  Save.i(File.s)
  CreateAtlas.i()
  Release.i()
EndInterface

Author:  linkerstorm [ Sat Jun 29, 2019 1:51 pm ]
Post subject:  Re: [ENGINE] 2D Engine Nautilus (Win)

Hi.

Just a message to thank you : this is a great job !

Keep the good work til the 1.0 relase :D

Congartulations.

Author:  Mijikai [ Sun Jun 30, 2019 11:36 am ]
Post subject:  Re: [ENGINE] 2D Engine Nautilus (Win)

linkerstorm wrote:
Hi.

Just a message to thank you : this is a great job !

Keep the good work til the 1.0 relase :D

Congartulations.


Thanks :)

Update: Version 0.30 beta

- Optimizations
- New Functions for Sprites & Tiles

Sprite and Tiles can now be transformed/distorted (with rotation, tint & alpha)
This for example could be used to map textures on walls in a pseudo 3D world (ex. Wolfenstein).

New Functions:
Code:
Interface NAUTILUS_TILE
  ;...
  DrawMap.i(Index.i,X1.f,Y1.f,X2.f,Y2.f,X3.f,Y3.f,X4.f,Y4.f,Alpha.a = #Null)
  DrawMapFx.i(Index.i,X1.f,Y1.f,X2.f,Y2.f,X3.f,Y3.f,X4.f,Y4.f,Alpha.a = #Null,AnchorX.f = #Null,AnchorY.f = #Null,Angle.f = #Null,Tint.l = #Null)
  ;...
  DrawLightMap.i(Index.i,X1.f,Y1.f,X2.f,Y2.f,X3.f,Y3.f,X4.f,Y4.f,Alpha.a = #Null)
  DrawLightMapFx.i(Index.i,X1.f,Y1.f,X2.f,Y2.f,X3.f,Y3.f,X4.f,Y4.f,Alpha.a = #Null,AnchorX.f = #Null,AnchorY.f = #Null,Angle.f = #Null,Tint.l = #Null)
  ;...
  LayerDrawMap.i(Layer.i,Index.i,X1.f,Y1.f,X2.f,Y2.f,X3.f,Y3.f,X4.f,Y4.f,Alpha.a = #Null)
  LayerDrawMapFx.i(Layer.i,Index.i,X1.f,Y1.f,X2.f,Y2.f,X3.f,Y3.f,X4.f,Y4.f,Alpha.a = #Null,AnchorX.f = #Null,AnchorY.f = #Null,Angle.f = #Null,Tint.l = #Null)
  ;...
  LayerLightMap.i(Layer.i,Index.i,X1.f,Y1.f,X2.f,Y2.f,X3.f,Y3.f,X4.f,Y4.f,Alpha.a = #Null)
  LayerLightMapFx.i(Layer.i,Index.i,X1.f,Y1.f,X2.f,Y2.f,X3.f,Y3.f,X4.f,Y4.f,Alpha.a = #Null,AnchorX.f = #Null,AnchorY.f = #Null,Angle.f = #Null,Tint.l = #Null)
  ;...
EndInterface

Interface NAUTILUS_SPRITE
  ;...
  DrawMap.i(X1.f,Y1.f,X2.f,Y2.f,X3.f,Y3.f,X4.f,Y4.f,Alpha.a = #Null)
  DrawMapFx.i(X1.f,Y1.f,X2.f,Y2.f,X3.f,Y3.f,X4.f,Y4.f,Alpha.a = #Null,Angle.f = #Null,AnchorX.f = #Null,AnchorY.f = #Null,Tint.l = #Null)
  ;...
  DrawLightMap.i(X1.f,Y1.f,X2.f,Y2.f,X3.f,Y3.f,X4.f,Y4.f,Alpha.a = #Null)
  DrawLightMapFx.i(X1.f,Y1.f,X2.f,Y2.f,X3.f,Y3.f,X4.f,Y4.f,Alpha.a = #Null,AnchorX.f = #Null,AnchorY.f = #Null,Angle.f = #Null,Tint.l = #Null)
  ;...
  LayerDrawMap.i(Layer.i,X1.f,Y1.f,X2.f,Y2.f,X3.f,Y3.f,X4.f,Y4.f,Alpha.a = #Null)
  LayerDrawMapFx.i(Layer.i,X1.f,Y1.f,X2.f,Y2.f,X3.f,Y3.f,X4.f,Y4.f,Alpha.a = #Null,AnchorX.f = #Null,AnchorY.f = #Null,Angle.f = #Null,Tint.l = #Null)
  ;...
  LayerLightMap.i(Layer.i,X1.f,Y1.f,X2.f,Y2.f,X3.f,Y3.f,X4.f,Y4.f,Alpha.a = #Null)
  LayerLightMapFx.i(Layer.i,X1.f,Y1.f,X2.f,Y2.f,X3.f,Y3.f,X4.f,Y4.f,Alpha.a = #Null,AnchorX.f = #Null,AnchorY.f = #Null,Angle.f = #Null,Tint.l = #Null)
  ;...
EndInterface



Example:
Image

Code:
Code:
EnableExplicit

;Nautilus Engine Example
;Version: 0.30 beta
;Author: Mijikai

XIncludeFile "nautilus.pbi"

Structure VECTOR_STRUCT
  x.f
  y.f
EndStructure

Procedure.i DrawPlant(*tile.NAUTILUS_TILE,X.f,Y.f,Distortion.f)
  *tile\DrawMap(-1,X + Distortion ,Y      ,X + 64 + Distortion,Y      ,X + 64,Y + 64,X,Y + 64)
  *tile\DrawMap(-1,X              ,Y + 64 ,X + 64             ,Y + 64 ,X + 64 + Distortion,Y + 128,X + Distortion,Y + 128)
  *tile\DrawMap(-1,X + Distortion ,Y +128 ,X + 64 + Distortion,Y + 128,X + 64,Y + 192,X,Y + 192)
EndProcedure

Procedure.i Main(Width.i,Height.i,Title.s,ViewWidth.i,ViewHeight.i,FPS.i)
  Protected win.i
  Protected win_handle.i
  Protected win_flag.i
  Protected win_msg.i
  Protected *engine.NAUTILUS_ENGINE
  Protected engine_delta.f
  Protected engine_fps.i
  Protected engine_error.i
  Protected screen_center.VECTOR_STRUCT
  Protected *atlas.NAUTILUS_ATLAS
  Protected *tile.NAUTILUS_TILE
  Protected dist.f
  Protected dist_flag.b
  win_flag|#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_MinimizeGadget
  win_flag|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget
  win = OpenWindow(#PB_Any,#Null,#Null,Width,Height,Title,win_flag)
  If win
    win_handle = WindowID(win)
    *engine = nautilusCreate(win_handle,ViewWidth,ViewHeight,FPS);init the engine
    If *engine
      *engine\RenderAspect()                ;keep the aspect ratio
      *engine\RenderColor($400A05)          ;change render color
      *engine\RenderFilter()
      *engine\ViewPortCenter(@screen_center);get the screen (viewport) center
      *engine\DrawTextResize(8,12)          ;set new size for standart text drawing with the ENGINE interface
      *engine\DrawTextSetSpacing(6)         ;and set the spacing between chars
      *atlas = *engine\CreateAtlas(?plant,#Null$)
      *tile  = *atlas\CreateTile(4,1,0,0,64,64)
      *tile\Animation(120,#True)
      Repeat
        Repeat
          win_msg = WindowEvent()
          If win_msg = #PB_Event_CloseWindow
            Break 2
          EndIf
        Until win_msg = #Null
        *engine\RenderBegin(@engine_delta,@engine_fps,@engine_error)
       
        If dist_flag
          dist - 0.25 * engine_delta
          If dist < -5
            dist_flag = #False
          EndIf
        Else
          dist + 0.25 * engine_delta
          If dist > 5
            dist_flag = #True
          EndIf
        EndIf
        DrawPlant(*tile,120,100,dist)
        DrawPlant(*tile,220,100,dist)
        DrawPlant(*tile,320,100,dist)
        DrawPlant(*tile,420,100,dist)
        *engine\DrawText(10,10,"Nautilus Engine",#False,#False,200,$FFDFBF)
        *engine\DrawText(10,25,"FPS " + Str(engine_fps),#False,#False,200,$FFDFBF)
        *engine\DrawText(10,40,"DLT " + StrF(engine_delta,2),#False,#False,200,$FFDFBF)
        *engine\RenderEnd()
        If engine_error
          Break
        EndIf
      ForEver
      *engine\Release()
    EndIf
    CloseWindow(win)
  EndIf
EndProcedure

Main(1080,720,"Example Nautilu Engine v.0.30 beta",600,400,30)

End

DataSection
  plant:
  ;{ File: plant.png - Size: 1265 Bytes
  !dw 05089h, 0474Eh, 00A0Dh, 00A1Ah, 00000h, 00D00h, 04849h, 05244h, 00000h, 00001h, 00000h, 04000h, 00208h, 00000h, 07A00h, 03E3Fh, 000E9h, 00000h, 07406h, 04E52h, 00053h, 00000h, 00000h, 06E00h, 007A6h, 00091h, 00000h, 07009h, 05948h, 00073h, 00E00h, 000C4h, 00E00h, 001C4h, 02B95h, 01B0Eh, 00000h, 09104h, 04449h, 05441h
  !dw 0DA78h, 09CEDh, 06E3Dh, 0311Bh, 08510h, 0C5E5h, 05222h, 0C290h, 0D406h, 08545h, 01700h, 00F86h, 052A1h, 001A5h, 0425Fh, 0D077h, 07419h, 05D07h, 080C2h, 0974Bh, 0443Eh, 0C290h, 00B80h, 08155h, 0A4E0h, 00AF2h, 038D8h, 00829h, 00410h, 0E5C9h, 067F2h, 0CB86h, 0DEB5h, 059D7h, 09612h, 0338Fh, 0C8F3h, 01FD9h, 0C5EFh, 09484h
  !dw 087EBh, 0D3BBh, 03FCFh, 0CFF2h, 0DF2Fh, 07DBFh, 0B7BCh, 0D7D5h, 0E3FAh, 06DBDh, 0CD8Fh, 0F6F4h, 0E5EAh, 071FEh, 03052h, 07FD0h, 0FA6Eh, 009ABh, 06700h, 00C0Ch, 06000h, 00000h, 00060h, 06000h, 00000h, 00060h, 06000h, 00000h, 08060h, 05912h, 0D7EEh, 0FDCBh, 0991Ah, 0E703h, 08068h, 04BF2h, 0FE1Fh, 054FCh, 0C806h, 0CB99h
  !dw 0B1DEh, 00FE4h, 0375Eh, 0654Fh, 006DAh, 03FA5h, 015BAh, 0F2A1h, 0A74Ch, 00698h, 04CDFh, 078C6h, 06C64h, 0457Dh, 08FE9h, 0CFABh, 0542Ah, 050E2h, 0F099h, 0D719h, 01BF1h, 02BEDh, 03F6Eh, 093BBh, 01D64h, 0F437h, 03873h, 0448Dh, 03576h, 0C98Ah, 0C2ABh, 0FDDCh, 0C94Fh, 0AE1Bh, 0985Bh, 05798h, 04397h, 0BB42h, 0BE3Eh, 0742Eh
  !dw 07BBCh, 03591h, 095B6h, 08663h, 08279h, 09BDEh, 05500h, 05B8Fh, 0FC92h, 0D876h, 09924h, 0B522h, 0A7B8h, 0B607h, 042C0h, 0E594h, 03BD5h, 041D9h, 07794h, 05A0Dh, 01215h, 0AEDFh, 00DDAh, 0A375h, 01C79h, 009F1h, 09993h, 051DDh, 06D0Ah, 054B4h, 03E91h, 05CEDh, 0D6E6h, 067C8h, 0EB07h, 02FD5h, 0CF3Eh, 05D5Ch, 0430Eh, 09E56h
  !dw 0F54Eh, 02029h, 061EDh, 08D6Eh, 03E7Ah, 0FBFBh, 0B9ABh, 0B87Eh, 05FF3h, 01738h, 055BBh, 092CAh, 0DCB9h, 0E5AFh, 07C11h, 0D388h, 09B4Fh, 0B14Bh, 0A9CBh, 010EDh, 07EB7h, 08B07h, 02ADDh, 0C3C8h, 007A6h, 0E358h, 02BDFh, 0EA4Ch, 0D477h, 0DD58h, 0E26Bh, 06EC5h, 0D875h, 08B3Eh, 0696Fh, 02D93h, 0A68Eh, 02A0Eh, 05886h, 0D7EEh
  !dw 09BAFh, 03927h, 00A6Eh, 07CF5h, 0E666h, 0AF80h, 053C7h, 0A443h, 01B8Eh, 09031h, 0543Ch, 06C7Bh, 0F9EAh, 07F2Ch, 0B0CFh, 0ADD8h, 0E3ACh, 0767Ah, 0DAA1h, 0662Ah, 05E5Dh, 07B59h, 0556Ch, 063BFh, 0DAA0h, 03267h, 01E7Ch, 04AE8h, 04A7Ch, 01C74h, 0493Bh, 0EACEh, 07749h, 01AAFh, 0CF7Fh, 01699h, 05FA5h, 0D870h, 0673Eh, 0BF8Bh
  !dw 0B159h, 05761h, 0DC81h, 04873h, 0469Ch, 06C7Bh, 0B7DAh, 04F93h, 0DBE8h, 04363h, 0DA9Bh, 0FA9Ch, 063DBh, 05843h, 00E3Dh, 0A1FDh, 03221h, 05BF5h, 0085Bh, 0FD6Eh, 099D1h, 0C775h, 0365Fh, 0628Dh, 07F20h, 095FDh, 01CFFh, 0977Ah, 097D2h, 0C7FBh, 0CDE9h, 0E3A5h, 0D307h, 04B9Bh, 0FFF7h, 08A74h, 0D3E3h, 05F46h, 0EFD3h, 07FE8h
  !dw 0A446h, 05ADFh, 0E946h, 0DBFAh, 02363h, 0EAC7h, 0AABAh, 0A893h, 0E1DFh, 04481h, 0AFFDh, 0A79Bh, 0FD2Eh, 026AEh, 0D439h, 062C7h, 0A60Ch, 0D76Dh, 01EACh, 07EC2h, 0EA5Dh, 028E7h, 04D50h, 0C73Fh, 0FC85h, 0FA3Ch, 0F9EBh, 0E98Ch, 0842Eh, 007DCh, 0F568h, 06ECBh, 01DD9h, 0027Fh, 0F003h, 0C1CDh, 07D1Dh, 04BC2h, 04C60h, 03C5Bh
  !dw 0FEABh, 0F1CCh, 0ED67h, 049D1h, 0217Ah, 025C7h, 06B07h, 0BBF5h, 0AA07h, 0AB3Dh, 01E47h, 03085h, 07207h, 05202h, 0B5BDh, 0987Ah, 007CEh, 06A48h, 04C48h, 0ABA1h, 0487Ah, 0786Eh, 04769h, 0E7ABh, 07233h, 0F30Fh, 06E75h, 0FA79h, 0AE88h, 0C7D5h, 0FE27h, 04475h, 06826h, 051D7h, 0FA35h, 0971Ch, 0CC35h, 00A63h, 051A7h, 057E9h
  !dw 04EFBh, 06456h, 0680Ah, 0C03Dh, 0FD5Dh, 06BDCh, 0A268h, 02AFEh, 07AA8h, 06DE4h, 09F1Ah, 0E273h, 0AAA2h, 09AC7h, 07492h, 0DCFDh, 063D5h, 0115Dh, 0E2A8h, 09DAFh, 0B235h, 05A86h, 02B3Bh, 0BB15h, 00965h, 0AFF1h, 072E3h, 0F5A0h, 01173h, 0E40Ah, 033E4h, 0FF57h, 0F4E8h, 0C773h, 0ED5Fh, 0F21Ch, 0FD3Ch, 05EA5h, 01FADh, 0FE3Ch
  !dw 0BA75h, 027B3h, 0F7E1h, 0C44Dh, 03A5Dh, 08F71h, 0F693h, 0B129h, 00F08h, 0BB88h, 029C5h, 0F3FAh, 0353Fh, 0A848h, 07ADFh, 08545h, 0BDDBh, 02F6Ah, 01E97h, 0B8FFh, 023D1h, 0600Dh, 06BD6h, 00E68h, 07AA4h, 09CF3h, 0833Dh, 0B419h, 04578h, 090D4h, 07FA9h, 0E790h, 0E567h, 0A1A0h, 0A435h, 09FE9h, 0FA0Ch, 06678h, 0FC7Ah, 0F513h
  !dw 0445Fh, 08D14h, 06999h, 069A9h, 07B7Ah, 07EE5h, 0E9B9h, 0C7E9h, 04D6Fh, 0E7BDh, 0E410h, 0AFD5h, 03F1Eh, 07F51h, 08B86h, 0D657h, 0A889h, 044BDh, 0FC62h, 087ADh, 060CDh, 07500h, 04D0Dh, 04FD7h, 0127Fh, 059ECh, 0879Ah, 0B3EDh, 033E7h, 05D5Bh, 07BEAh, 0F59Fh, 06D67h, 013ACh, 067F5h, 06F16h, 02466h, 0FE3Dh, 07799h, 07330h
  !dw 0261Fh, 0CFD1h, 003B2h, 05FF8h, 05D5Bh, 056ECh, 00E3Eh, 0EA1Eh, 0D7ACh, 06F67h, 0592Dh, 06F7Fh, 0C622h, 07F12h, 03EC7h, 05F9Ch, 0C07Fh, 0516Bh, 0D77Ah, 01F39h, 0C565h, 0FF56h, 0F4B8h, 0135Bh, 0BA31h, 09BF8h, 070FBh, 0FD7Eh, 097F1h, 00141h, 0E920h, 086DFh, 046A5h, 0C64Ah, 07C82h, 06472h, 04BD4h, 06952h, 061E2h, 05400h
  !dw 059CFh, 09783h, 002E3h, 00018h, 01800h, 00000h, 00018h, 01800h, 00000h, 00018h, 01800h, 00000h, 0C018h, 0F21Bh, 0F357h, 00665h, 0CFFAh, 03F50h, 00076h, 01D80h, 00000h, 08018h, 0F69Bh, 0E4EDh, 06AF3h, 062C1h, 0FE81h, 0A94Fh, 0D29Fh, 03D00h, 0B6AFh, 0F8FBh, 0FBD7h, 0BE6Ah, 08161h, 033FEh, 08FD4h, 00816h, 005A0h, 00002h
  !dw 00006h, 00600h, 00000h, 00006h, 00600h, 00000h, 00006h, 00600h, 00000h, 00006h, 00600h, 00000h, 00006h, 00600h, 00000h, 00006h, 00600h, 00000h, 00006h, 00600h, 06000h, 0FC7Ch, 0BA07h, 0D3D6h, 0562Dh, 0CDB2h, 0009Bh, 00000h, 04900h, 04E45h, 0AE44h, 06042h, 00082h
  ;}
EndDataSection

Author:  applePi [ Mon Jul 01, 2019 2:47 pm ]
Post subject:  Re: [ENGINE] 2D Engine Nautilus (Win)

Thanks, certainly nice, the dancing trees example is animated and wonderful
i have tested these: with nautilus_demo.pb added it before line: *engine\RenderEnd():
*engine\DrawCircle(200,200,100,#False,$FFFFFFFF)
*engine\DrawLineSize(3)
*engine\DrawLine(200,100,400,450,$FFFFFFFF)
it seems to me but not sure that the thick line is beautified, ie there is no cracks in it.
i suggest more simple and complex examples added gradually will be great you can add it also to the engine package.

Regards

Author:  Mijikai [ Mon Jul 01, 2019 9:12 pm ]
Post subject:  Re: [ENGINE] 2D Engine Nautilus (Win)

applePi wrote:
Thanks, certainly nice, the dancing trees example is animated and wonderful
i have tested these: with nautilus_demo.pb added it before line: *engine\RenderEnd():
*engine\DrawCircle(200,200,100,#False,$FFFFFFFF)
*engine\DrawLineSize(3)
*engine\DrawLine(200,100,400,450,$FFFFFFFF)
it seems to me but not sure that the thick line is beautified, ie there is no cracks in it.
i suggest more simple and complex examples added gradually will be great you can add it also to the engine package.

Regards


Thanks :)
Ill try to add examples over time.

For now i can share this text drawing demo:
Code:
EnableExplicit

;SYNTHETIC DREAMS
;Author Mijikai

XIncludeFile "nautilus.pbi"

Structure VECTOR_STRUCT
  x.f
  y.f
EndStructure

Structure FX
  a.f
  b.VECTOR_STRUCT
  c.i
EndStructure

Procedure.i Main(Width.i,Height.i,Title.s,ViewWidth.i,ViewHeight.i,FPS.i)
  Protected win.i
  Protected win_handle.i
  Protected win_flag.i
  Protected win_msg.i
  Protected *engine.NAUTILUS_ENGINE
  Protected engine_delta.f
  Protected engine_fps.i
  Protected engine_error.i
  Protected screen_center.VECTOR_STRUCT
  Protected index.f
  Protected flip.i
  Protected anc.f
  Protected rot.f
  Protected w.f
  Protected h.f
  Protected draw.i
  Protected NewList npos.FX()
  Protected rest.f
  Protected aa.f
  Protected bb.f
  Protected af.f
  Protected bf.f
  win_flag|#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_MinimizeGadget
  win_flag|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget
  win = OpenWindow(#PB_Any,#Null,#Null,Width,Height,Title,win_flag)
  If win
    win_handle = WindowID(win)
    *engine = nautilusCreate(win_handle,ViewWidth,ViewHeight,FPS);Version: 0.30 beta
    If *engine
      *engine\RenderAspect() 
      *engine\RenderColor($2E0000)
      *engine\ViewPortCenter(@screen_center)
      aa = 20
      bb = 20
      af = 70
      bf = 40
      Repeat
        Repeat
          win_msg = WindowEvent()
          If win_msg = #PB_Event_CloseWindow
            Break 2
          EndIf
        Until win_msg = #Null
        *engine\RenderBegin(@engine_delta,@engine_fps,@engine_error)
        draw = 0 
        If index > 6
          If flip
            anc - 4
            flip = Bool(anc > -af)
          Else
            anc + 1
            flip = Bool(anc > bf)
          EndIf
          index = engine_delta
        Else
          index + 1 * engine_delta
          rot + 1 * engine_delta
          If rot > 359
            rot = 0
          EndIf
        EndIf
        w = aa - anc
        h = bb + anc
        ForEach npos()
          *engine\DrawTextModEx(screen_center\x,screen_center\y,"SYNTHETIC DREAMS",npos()\b\x,npos()\b\y,#True,#True,60,npos()\a,npos()\c)
          *engine\DrawTextModEx(screen_center\x,screen_center\y,"SYNTHETIC DREAMS",npos()\b\x,npos()\b\y,#True,#True,60,-npos()\a,npos()\c)
          draw + 32
        Next
        If ListSize(npos()) < 168
          If AddElement(npos())
            npos()\a = anc
            npos()\b\x = -200 + Abs(w) + rot
            npos()\b\y = 800 + Abs(h) - rot
            npos()\c = RGB(rot,0,255 - rot)
          EndIf
        EndIf
        *engine\DrawTextLightModEx(screen_center\x,screen_center\y,"SYNTHETIC DREAMS",w,h,#True,#True,anc,$FFFFFFFF)
        *engine\DrawTextLightModEx(screen_center\x + 3,screen_center\y + 1,"SYNTHETIC DREAMS",w,h,#True,#True,anc,$FF4060FF)
        draw + 32
        ;*engine\DrawText(10,10,Str(draw))
        ;*engine\DrawText(10,20,Str(engine_fps))
        If rest > 100
          ClearList(npos())
          rest = engine_delta
          aa = 20 + Random(100)
          bb = 20 + Random(200)
          af = 40 + Random(300)
          bf = 40 + Random(300)
        Else
          rest + engine_delta
        EndIf
        *engine\RenderEnd()
        If engine_error
          Break
        EndIf
      ForEver
      *engine\Release()
    EndIf
    CloseWindow(win)
  EndIf
EndProcedure

Main(1080,720,"SYNTHETIC DREAMS by Mijikai",900,300,60)

End

Author:  Mijikai [ Sat Jul 06, 2019 11:39 am ]
Post subject:  Re: [ENGINE] 2D Engine Nautilus (Win)

Update: Version 0.31 beta

Added a new Interface for collision detection.

Code:
Interface NAUTILUS_ENGINE
  ;...
  CreateCollision.i();<- create collision interface
  ;...
EndInterface

Interface NAUTILUS_COLLISION
  Box(X1.f,Y1.f,W1.f,H1.f,X2.f,Y2.f,W2.f,H2.f)
  BoxEx(*PosA,W1.f,H1.f,*PosB,W2.f,H2.f)
  Sprite.i(X1.f,Y1.f,*SpriteA,X2.f,Y2.f,*SpriteB);<- sprites or tiles (or both)!
  SpriteEx.i(*PosA,*SpriteA,*PosB,*SpriteB);<- sprites or tiles (or both)!
  LineLine.i(*LineA_XY1,*LineA_XY2,*LineB_XY1,*LineB_XY2,*Offset = #Null)
  LineLineEx.i(*LineA,*LineB,*Offset = #Null)
EndInterface


Currently theres no support for rotated sprites and tiles!

Example:
Image

Code:
EnableExplicit

;Nautilus Engine Demo
;Version: 0.31 beta
;Author: Mijikai

;Look at nautilus.pbi to see all interfaces and functions!

XIncludeFile "nautilus.pbi"

Structure VECTOR_STRUCT
  x.f
  y.f
EndStructure

Structure LINE_STRUCT
  a.VECTOR_STRUCT
  b.VECTOR_STRUCT
EndStructure

Procedure.i Demo(Width.i,Height.i,Title.s,ViewWidth.i,ViewHeight.i,FPS.i)
  Protected win.i
  Protected win_handle.i
  Protected win_flag.i
  Protected win_msg.i
  Protected *engine.NAUTILUS_ENGINE
  Protected engine_delta.f
  Protected engine_fps.i
  Protected engine_error.i
  Protected *collision.NAUTILUS_COLLISION
  Protected LineA.LINE_STRUCT
  Protected LineB.LINE_STRUCT
  Protected Intersect.VECTOR_STRUCT
  Protected BoxPos.VECTOR_STRUCT
  win_flag|#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_MinimizeGadget
  win_flag|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget
  win = OpenWindow(#PB_Any,#Null,#Null,Width,Height,Title,win_flag)
  If win
    win_handle = WindowID(win)
    *engine = nautilusCreate(win_handle,ViewWidth,ViewHeight,FPS)
    If *engine
      *engine\RenderAspect()
      *collision = *engine\CreateCollision()
      LineA\a\x = 300
      LineA\a\y = 100
      LineA\b\x = 400
      LineA\b\y = 500
      LineB\a\x = 10
      LineB\a\y = 100
      Repeat
        Repeat
          win_msg = WindowEvent()
          If win_msg = #PB_Event_CloseWindow
            Break 2
          EndIf
        Until win_msg = #Null
        *engine\InputMouse(@LineB\b)
        BoxPos = LineB\b
        BoxPos\x - 50
        BoxPos\y - 50
        *engine\RenderBegin(@engine_delta,@engine_fps,@engine_error)
        *engine\DrawLine(LineA\a\x,LineA\a\y,LineA\b\x,LineA\b\y)
        *engine\DrawLine(LineB\a\x,LineB\a\y,LineB\b\x,LineB\b\y)
        If *collision\LineLineEx(@LineA,@LineB,@Intersect)
          *engine\DrawCircle(Intersect\x,Intersect\y,10)
          *engine\DrawText(Intersect\x + 20,Intersect\y,"LINE INTERSECTION!")
        EndIf
        *engine\DrawBox(200,200,100,100)
        *engine\DrawBox(BoxPos\x,BoxPos\y,100,100)
        If *collision\Box(200,200,100,100,BoxPos\x,BoxPos\y,100,100)
          *engine\DrawText(BoxPos\x,BoxPos\y - 20,"BOX COLLISION!")
        EndIf
        *engine\RenderEnd()
        If engine_error
          Break
        EndIf
      ForEver
      *engine\Release()
    EndIf
    CloseWindow(win)
  EndIf
EndProcedure

Demo(1080,720,"Box Collosion & Line Intersection - Nautilus Engine v.0.31 beta",600,400,30)

End

Author:  Mijikai [ Sat Jul 13, 2019 9:46 am ]
Post subject:  Re: [ENGINE] 2D Engine Nautilus (Win)

Update: Version 0.33 beta

Added a new Interface with 2D TileMap & Camera functions :)

Interface:
Code:

Interface NAUTILUS_ENGINE
  ;...
  CreateOrtho.i(TilesX.i,TilesY.i,TileWidth.i,TileHeight.i);<- Create NAUTILUS_ORTHO object/interface
  ;...
EndInterface

Interface NAUTILUS_ORTHO
  Tiles.i()
  TilesX.i()
  TilesY.i()
  TileWidth.i()
  TileHeight.i()
  CameraCreate.i(X.f,Y.i,Width.f,Height.f)
  CameraOrigin.i(Camera.i,*Origin,*Offset = #Null)
  CameraMove.i(Camera.i,*Move,*Offset = #Null)
  CameraIndex.i(Camera.i,*Index)
  CameraPosition.i(Camera.i,*Position)
  CameraClamp.i(Camera.i,TilesX.i = 2,TilesY.i = 2)
  CameraZoom.f(Camera.i,Min.f,Max.f,*Scale = #Null)
  CameraScale.f(Camera.i)
  CameraUpdate.i(Camera.i,*Clamp = #Null,*Translation = #Null)
  CameraDestroy.i(Camera.i)
  Mouse.i(Camera.i,*Mouse,*Position,*Index = #Null)
  WorldToScreen.i(Camera.i,*Input,*Output)
  ScreenToWorld.i(Camera.i,*Input,*Output)
  TileMapCreate.i()
  TileMapToScreen.i(Camera.i,X.i,Y.i,*Position,*Link = #Null)
  TileMapGet.i(X.i,Y.i)
  TileMapSet.i(X.i,Y.i,Link.i)
  TileMapDestroy.i()
  Release.i()
EndInterface


Example:
Image

Code:
Code:

EnableExplicit

;Nautilus Engine
;Version: 0.33 beta
;Author: Mijikai

;Ortho Camera Example

XIncludeFile "nautilus.pbi"

Macro WindowEvents()
  Repeat
    win_msg = WindowEvent()
    If win_msg = #PB_Event_CloseWindow
      Break 2
    EndIf
  Until win_msg = #Null
EndMacro

Procedure.i Demo(Width.i,Height.i,Title.s,ViewWidth.i,ViewHeight.i,FPS.i)
  Protected win.i
  Protected win_handle.i
  Protected win_flag.i
  Protected win_msg.i
  Protected *engine.NAUTILUS_ENGINE
  Protected engine_delta.f
  Protected engine_fps.i
  Protected engine_error.i
  Protected screen_center.NAUTILUS_VECTOR_STRUCT
  Protected *atlas.NAUTILUS_ATLAS
  Protected *tile.NAUTILUS_TILE
  ;---------------------------------------------------------
  Protected mouse.NAUTILUS_VECTOR_STRUCT
  Protected *ortho.NAUTILUS_ORTHO
  Protected cam.i
  Protected cam_scale.f
  Protected cam_origin.NAUTILUS_VECTOR_STRUCT
  Protected cam_move.NAUTILUS_VECTOR_STRUCT
  Protected cam_clamp.NAUTILUS_CLAMP_STRUCT
  Protected px.i
  Protected py.i
  Protected tile_position.NAUTILUS_VECTOR_STRUCT
  Protected tile_link.i
  Protected mouse_active.i
  Protected mouse_position.NAUTILUS_VECTOR_STRUCT
  Protected mouse_index.NAUTILUS_INDEX_STRUCT
  ;---------------------------------------------------------
  win_flag|#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_MinimizeGadget
  win_flag|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget
  win = OpenWindow(#PB_Any,#Null,#Null,Width,Height,Title,win_flag)
  If win
    win_handle = WindowID(win)
    *engine = nautilusCreate(win_handle,ViewWidth,ViewHeight,FPS)
    If *engine
      *engine\RenderFilter()
      *engine\RenderAspect()
      *engine\RenderColor($400A05)         
      *engine\ViewPortCenter(@screen_center)
      *atlas = *engine\CreateAtlas(?floor,#Null$)
      *tile = *atlas\CreateTile(2,1,0,0,32,32)
      ;---------------------------------------------------------
      *ortho = *engine\CreateOrtho(100,100,32,32) ;<- create the ortho object/interface
      *ortho\TileMapCreate()                      ;<- create a tilemap (not needed a camera can also be used with a custom tilemap!)
      For py = 0 To *ortho\TilesY() - 1
        For px = 0 To *ortho\TilesX() - 1
          *ortho\TileMapSet(px,py,Random(1))      ;<- set the link - the link stores informations related to the tile
        Next
      Next
      cam = *ortho\CameraCreate(100,100,400,200)  ;<- create a camera
      cam_scale = 1                               ;<- initial scale/zoom factor
      cam_origin\x = 16                           ;<- camera origin
      cam_origin\x = 16
      *ortho\CameraOrigin(cam,@cam_origin)        ;<- set camera origin
      ;---------------------------------------------------------
      Repeat
        WindowEvents()
        If *engine\InputKey(#VK_ESCAPE):Break:EndIf
        If *engine\InputKey(#VK_W):cam_move\y - 4 * engine_delta:EndIf
        If *engine\InputKey(#VK_S):cam_move\y + 4 * engine_delta:EndIf
        If *engine\InputKey(#VK_A):cam_move\x - 4 * engine_delta:EndIf
        If *engine\InputKey(#VK_D):cam_move\x + 4 * engine_delta:EndIf
        *engine\InputMouse(@mouse)
        cam_scale + (*engine\InputMouseWheel() / 1000)                        ;<- camera zoom
        Round(cam_scale ,#PB_Round_Nearest)
        mouse_active = *ortho\Mouse(cam,@mouse,@mouse_position,@mouse_index)  ;<- get the tile map mouse positions
        *ortho\CameraMove(cam,@cam_move)                                      ;<- move the camera to new position
        *ortho\CameraZoom(cam,0.5,3,@cam_scale)                               ;<- zoom the camera
        *engine\RenderBegin(@engine_delta,@engine_fps,@engine_error)
        ;---------------------------------------------------------
        *engine\RenderClip(100,100,400,200)                                   ;<- clip the camera
        *engine\RenderPush()                                                  ;<- backup the current render matrix
        *ortho\CameraUpdate(cam,@cam_clamp)                                   ;<- update the camera
        For py = cam_clamp\min\y To cam_clamp\max\y
          For px = cam_clamp\min\x To cam_clamp\max\x
            *ortho\TileMapToScreen(cam,px,py,@tile_position,@tile_link)       ;<- translate all tiles that are visible
            If mouse_active
              If px = mouse_index\x And py = mouse_index\y
                *tile\DrawEx(tile_link,tile_position\x,tile_position\y,#False,#Null,#Null,$FF00FF)
              Else
                *tile\Draw(tile_link,tile_position\x,tile_position\y)
              EndIf
            Else
              *tile\Draw(tile_link,tile_position\x,tile_position\y)
            EndIf
          Next
        Next
        *engine\RenderPop()                                                   ;<- restore render matrix
        *engine\RenderUnclip()                                                ;<- unclip the camera
        *engine\DrawBox(100,100,400,200)
        ;---------------------------------------------------------
        *engine\DrawText(10,10,"Nautilus Engine",#False,#False,200)
        *engine\DrawText(10,25,"FPS " + Str(engine_fps),#False,#False,200)
        *engine\DrawText(10,40,"DLT " + StrF(engine_delta,2),#False,#False,200)
        *engine\DrawText(10,55,"Mouse Index: " + Str(mouse_index\x) + " x " + Str(mouse_index\y),#False,#False,200)
        *engine\RenderEnd()
        If engine_error;exit if there is an error
          Break
        EndIf
      ForEver
      *engine\Release();this will free all resources and objects/interfaces
    EndIf
    CloseWindow(win)
  EndIf
EndProcedure

Demo(1080,720,"Nautilus Engine (Ortho Camera) v.0.33 beta",600,400,60)

End

DataSection
  floor:
  ;{ floor.png - Size: 236 Bytes
  !dw 05089h, 0474Eh, 00A0Dh, 00A1Ah, 00000h, 00D00h, 04849h, 05244h, 00000h, 04000h, 00000h, 02000h, 00208h, 00000h, 02D00h, 0E9FFh, 000D3h, 00000h, 049B3h, 04144h, 05854h, 0EDC3h, 0C198h, 00409h, 00C21h, 03345h, 0F4CBh, 055E0h, 06CF0h, 0E917h, 032C5h, 0C3ACh, 0925Eh, 0522Ah, 05D85h, 0C1ECh, 09645h, 07765h, 01660h, 0701Dh
  !dw 039F8h, 08129h, 05F07h, 03BC9h, 0CB64h, 0D339h, 0B5CAh, 09113h, 07AAAh, 067EFh, 043D0h, 0B308h, 07BF9h, 0A53Bh, 08694h, 04BD3h, 0FD29h, 08F3Ch, 00AFFh, 02220h, 0C631h, 07481h, 0DCE7h, 0F5FBh, 06F80h, 0CC66h, 06B5Ch, 0D53Dh, 0FCEAh, 02D07h, 0085Eh, 00080h, 03403h, 04D7Ah, 0D999h, 096AFh, 09C88h, 0F56Dh, 0BE21h, 0002Eh
  !dw 0AF33h, 003FDh, 06D5Fh, 08D08h, 00022h, 04002h, 0D0A3h, 03428h, 00B0Ah, 00021h, 00A34h, 0428Dh, 018A3h, 00462h, 083B8h, 00F46h, 0F734h, 07D47h, 0E66Ch, 06BA6h, 05554h, 03EC7h, 0034Ch, 0E5B6h, 054EEh, 0B6FEh, 07AFAh, 009FDh, 00798h, 0BD79h, 02B92h, 094DFh, 00000h, 00000h, 04549h, 0444Eh, 042AEh, 08260h
  ;}
EndDataSection

Author:  Mijikai [ Sat Jul 13, 2019 6:53 pm ]
Post subject:  Re: [ENGINE] 2D Engine Nautilus (Win)

Update: Version 0.34 beta

Added new Function for Fake 3D effects :)

Code:
Interface NAUTILUS_ORTHO
  ;...
  ProjectionFx.i(*Origin,*Target,*Position,Factor.f = 10)
  ;...
EndInterface


Example:
Image

Code:
Code:
EnableExplicit

;Nautilus Engine
;Version: 0.34 beta
;Author: Mijikai

;Ortho - ProjectionFx example

XIncludeFile "nautilus.pbi"

Macro WindowEvents()
  Repeat
    win_msg = WindowEvent()
    If win_msg = #PB_Event_CloseWindow
      Break 2
    EndIf
  Until win_msg = #Null
EndMacro

Procedure.i DrawPilon(*engine.NAUTILUS_ENGINE,*ortho.NAUTILUS_ORTHO,X.f,Y.f,*Translate.NAUTILUS_VECTOR_STRUCT,*Player.NAUTILUS_VECTOR_STRUCT,Factor.f)
  Protected pos.NAUTILUS_VECTOR_STRUCT
  Protected pro.NAUTILUS_VECTOR_STRUCT
  pos\x = X + *Translate\x
  pos\y = Y + *Translate\y
  *engine\DrawCircle(pos\x,pos\y,10)
  *ortho\ProjectionFx(*Player,@pos,@pro,Factor);<- 2d to fake 3d!
  *engine\DrawLine(pos\x,pos\y,*Player\x,*Player\y,$88888888)
  *engine\DrawLine(pos\x,pos\y,pro\x,pro\y)
  *engine\DrawCircle(pro\x,pro\y,10,#True,$AAFF00FF)
EndProcedure

Procedure.i Demo(Width.i,Height.i,Title.s,ViewWidth.i,ViewHeight.i,FPS.i)
  Protected win.i
  Protected win_handle.i
  Protected win_flag.i
  Protected win_msg.i
  Protected *engine.NAUTILUS_ENGINE
  Protected engine_delta.f
  Protected engine_fps.i
  Protected engine_error.i
  ;---------------------------------------------------------
  Protected *ortho.NAUTILUS_ORTHO
  Protected player.NAUTILUS_VECTOR_STRUCT
  Protected translate.NAUTILUS_VECTOR_STRUCT
  Protected index.i
  Protected fac.f = 10
  ;---------------------------------------------------------
  win_flag|#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_MinimizeGadget
  win_flag|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget
  win = OpenWindow(#PB_Any,#Null,#Null,Width,Height,Title,win_flag)
  If win
    win_handle = WindowID(win)
    *engine = nautilusCreate(win_handle,ViewWidth,ViewHeight,FPS)
    If *engine
      *engine\RenderFilter()
      *engine\RenderAspect()
      *engine\RenderColor($400A05)
      *ortho = *engine\CreateOrtho();<- create 'empty' ortho object / we just need access to the ProjectFx() function!
      translate\x = 300
      translate\y = 200
      player\x = 300
      player\y = 200
      ;---------------------------------------------------------
      Repeat
        WindowEvents()
        If *engine\InputKey(#VK_W):translate\y + 5 * engine_delta:EndIf
        If *engine\InputKey(#VK_S):translate\y - 5 * engine_delta:EndIf
        If *engine\InputKey(#VK_A):translate\x + 5 * engine_delta:EndIf
        If *engine\InputKey(#VK_D):translate\x - 5 * engine_delta:EndIf
        fac + (*engine\InputMouseWheel() / 100)
        If fac > 100:fac = 100:EndIf
        If fac < 1:fac = 1:EndIf
        *engine\RenderBegin(@engine_delta,@engine_fps,@engine_error)
        *engine\DrawCircle(300,200,10,#True)
        For index = - 100 To 100 Step 10
          DrawPilon(*engine,*ortho,index,100,@translate,@player,fac)
          DrawPilon(*engine,*ortho,index,index,@translate,@player,fac)
          DrawPilon(*engine,*ortho,100,index,@translate,@player,fac)
        Next
        *engine\RenderEnd()
        If engine_error
          Break
        EndIf
      ForEver
      *engine\Release()
    EndIf
    CloseWindow(win)
  EndIf
EndProcedure

Demo(1080,720,"Nautilus Engine (Ortho ProjectionFx) v.0.34 beta",600,400,60)

End

Author:  Mijikai [ Wed Jul 17, 2019 4:09 pm ]
Post subject:  Re: [ENGINE] 2D Engine Nautilus (Win)

Update: Version 0.35 beta

New Functions :)
Direct Pixel access for Sprites, Tiles and Fonts.

Code:
Interface NAUTILUS_ATLAS
  Pixel.i();<- returns the texture as buffer
  PixelSize.i(*Bits);<- size of the texture buffer
  PixelGet.i(*Bits,X.i,Y.i)
  PixelSet.i(*Bits,X.i,Y.i,ColorABGR.i)
  PixelUpdate.i(X.i,Y.i,Width.i,Height.i,*Bits);<- update/ change the displayed texture
  PixelFree.i(*Bits);<- free the texture buffer
  ;...
EndInterface

Author:  Mijikai [ Tue Jul 30, 2019 11:06 am ]
Post subject:  Re: [ENGINE] 2D Engine Nautilus (Win)

Version 1.00 :)

Finally :D

New functions (Pathfinding):
Code:
Interface NAUTILUS_COLLISION
  ;...
  AStarMaskCreate.i(*Buffer,Width.i,Height.i)
  AStarMaskWidth.i(Mask.i)
  AStarMaskHeight.i(Mask.i)
  AStarMaskSet.i(Mask.i,X.i,Y.i,Flag.b = #True)
  AStarMaskGet.i(Mask.i,X.i,Y.i)
  AStarMaskFree.i(Mask.i)
  AStarPathCreate.i(Mask.i,*Start,*Stop,Diagonal.b = #False,Smooth.b = #False,Steps.i = #Null)
  AStarPath.i(Path.i,*Offset)
  AStarPathFree.i(Path.i)
EndInterface


Thanks @diceman for helping me with the pathfinding :)

Author:  gurj [ Wed Jul 31, 2019 3:42 am ]
Post subject:  Re: [ENGINE] 2D Engine Nautilus (Win)

Line 33: nautilusCreate() is not a function, array, list, map or macro

Author:  Mijikai [ Wed Jul 31, 2019 7:38 am ]
Post subject:  Re: [ENGINE] 2D Engine Nautilus (Win)

gurj wrote:
Line 33: nautilusCreate() is not a function, array, list, map or macro


Have you included the pbi?
Code:
XIncludeFile "nautilus.pbi"


Is it possible to get more information?

Author:  gurj [ Wed Jul 31, 2019 1:41 pm ]
Post subject:  Re: [ENGINE] 2D Engine Nautilus (Win)

yes,has this:
XIncludeFile "nautilus.pbi"
it is your first post codes.

Author:  gurj [ Wed Jul 31, 2019 3:58 pm ]
Post subject:  Re: [ENGINE] 2D Engine Nautilus (Win)

In your first post, no 'nautilusCreate' was found.
and, i test your first Example: Image...

Page 1 of 3 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/