It is currently Tue Mar 09, 2021 9:55 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 49 posts ]  Go to page Previous  1, 2, 3, 4
Author Message
 Post subject: Re: [ENGINE] 2D Engine Nautilus (Win x86 & x64)
PostPosted: Sun Nov 29, 2020 12:08 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Sep 11, 2016 2:17 pm
Posts: 846
Its written in PureBasic (compiled with PB v.5.73) :)
I will add some new examples for now there is only the asteroids game.

Edit:
Heres is another example adapted to the newest version:

Image

Example Plant (texture (aka. sprite), tiles and animation):
Code:
EnableExplicit

;Example Plant

XIncludeFile "nautilus.pbi"

Structure VECTOR_STRUCT
  x.f
  y.f
EndStructure

Procedure.i DrawPlant(*tile.NAUTILUS_TILE,*animation.NAUTILUS_ANIMATION,X.f,Y.f,Distortion.f)
  *tile\DrawMap(-1,*animation,X + Distortion,Y,X + 64 + Distortion,Y,X + 64,Y + 64,X,Y + 64);if tile is -1 the tile index of the animation is taken
  *tile\DrawMap(-1,*animation,X,Y + 64 ,X + 64,Y + 64,X + 64 + Distortion,Y + 128,X + Distortion,Y + 128)
  *tile\DrawMap(-1,*animation,X + Distortion,Y +128 ,X + 64 + Distortion,Y + 128,X + 64,Y + 192,X,Y + 192)
  ProcedureReturn #Null
EndProcedure

Procedure.i LimitFramerate(FPS.i);function to limit the framerare (good enough for testing purposes)
  Static tmr_clock.q
  Protected tmr_duration.q
  Protected tmr_target.q
  Protected tmr_exit.q
  tmr_target = 1000 / FPS
  tmr_exit = tmr_target - 1
  Repeat
    tmr_duration = ElapsedMilliseconds() - tmr_clock
    If tmr_duration < tmr_target
      Delay(tmr_target - tmr_duration)
    EndIf
  Until tmr_duration > tmr_exit
  tmr_clock = ElapsedMilliseconds()
  ProcedureReturn #Null
EndProcedure

Procedure.i Main()
  Protected *engine.NAUTILUS_ENGINE
  Protected *texture.NAUTILUS_TEXTURE
  Protected *tile.NAUTILUS_TILE
  Protected *animation.NAUTILUS_ANIMATION
  Protected dist.f
  Protected dist_flag.b
  If nautilusVersion() = #NAUTILUS_VERSION
    If OpenWindow(0,0,0,600,400,#Null$,#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_MinimizeGadget)
      *engine = nautilusEngine(WindowID(0),600,400)
      If *engine
        *engine\RenderVSyncMode(#False);disable vsync
        *texture = *engine\CreateTexture(?plant,#Null$);load a texture from memory (*.bmp or *.png!)
        If *texture
          *tile = *texture\CreateTile(4,1,0,0,64,64);create a tile object/interface from the texture
          *animation = *engine\CreateAnimation(0,3,10,#True,#False);<- create a animation (cycle = frames) / go from one tile to the next every x cycles!
          If *tile And *animation
            Repeat
              LimitFramerate(60)
              Repeat
                Select WindowEvent()
                  Case #PB_Event_CloseWindow
                    Break 2
                  Case #Null
                    Break
                EndSelect
              ForEver
              If dist_flag
                dist - 0.25
                If dist < -5.0
                  dist_flag = #False
                EndIf
              Else
                dist + 0.25
                If dist > 5.0
                  dist_flag = #True
                EndIf
              EndIf
              *engine\RenderUpdate();needed for animations! (will generate a cycle)
              *engine\RenderBegin()
              *engine\DrawText(200,40,"Tile:")
              *texture\DrawMod(350,50,160,40,#True);draw the whole texture resized to show all tiles at once
              *engine\DrawBox(180,20,260,60)
              DrawPlant(*tile,*animation,120,140,dist)
              DrawPlant(*tile,*animation,220,140,dist + Sin(dist / 2) * 20)
              DrawPlant(*tile,*animation,320,140 + dist * 10,dist)
              DrawPlant(*tile,*animation,420,140,dist)
              *tile\Draw(0,#Null,10,10);only draw the tile at index 0 without animation
              *engine\RenderEnd()
            ForEver
          EndIf
        EndIf
        *engine\Release()
      EndIf
      CloseWindow(0) 
    EndIf 
  EndIf
  ProcedureReturn #Null
EndProcedure

Main()

End

DataSection
  plant:;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


Top
 Profile  
Reply with quote  
 Post subject: Re: [ENGINE] 2D Engine Nautilus (Win x86 & x64)
PostPosted: Sun Nov 29, 2020 4:52 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Sep 11, 2016 2:17 pm
Posts: 846
Worked some more on it :)

Update v.1.110 (most important changes):
- Fixed a bug in the font mapper

Download:
https://www.dropbox.com/s/njvxaufih7ssbx8/ne_v.1.110.zip?dl=0

Here is a example that shows how easy it is to add custom fonts :)

Image

Code:
Code:
EnableExplicit

XIncludeFile "nautilus.pbi"

;Nautilus Engine v.1.110
;EXAMPLE: CUSTOM FONTS

Procedure.i LimitFramerate(FPS.i);function to limit the framerare (good enough for testing purposes)
  Static tmr_clock.q
  Protected tmr_duration.q
  Protected tmr_target.q
  Protected tmr_exit.q
  tmr_target = 1000 / FPS
  tmr_exit = tmr_target - 1
  Repeat
    tmr_duration = ElapsedMilliseconds() - tmr_clock
    If tmr_duration < tmr_target
      Delay(tmr_target - tmr_duration)
    EndIf
  Until tmr_duration > tmr_exit
  tmr_clock = ElapsedMilliseconds()
  ProcedureReturn #Null
EndProcedure

Procedure.i Main()
  Protected *engine.NAUTILUS_ENGINE
  Protected *texture.NAUTILUS_TEXTURE
  Protected *tile.NAUTILUS_TILE
  Protected *font.NAUTILUS_FONT
  Protected tw.f
  Protected th.f
  If nautilusVersion() = #NAUTILUS_VERSION
    If OpenWindow(0,0,0,800,600,#Null$,#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_MinimizeGadget)
      *engine = nautilusEngine(WindowID(0),800,600)
      If *engine
        *engine\RenderVSyncMode(#False);disable vsync
        *texture = *engine\CreateTexture(?font)
        *tile = *texture\CreateTile(4,2,0,0,16,16,0,0);(4 * 16) x (2 * 16) tile - each char is 16 x 16
        *font = *engine\CreateFont(0,"12345678");layout (the position of the chars) for the font mapper (the offset is the count of 'emtpy' or 'space' chars at the beginning!)
        ;the layout limited to the ascii range(0 - 255)/chars
        ;if no layout position for a chr is set the chr is mapped to the first entry
        ;thats why a 'empty' chr is often used as the first entry (the null-chr)
        *tile\SizeSet(256,256);make the font bigger by resizing the tile
        Repeat
          LimitFramerate(60)
          Repeat
            Select WindowEvent()
              Case #PB_Event_CloseWindow
                Break 2
              Case #Null
                Break
            EndSelect
          ForEver
          *engine\RenderBegin()
          *engine\DrawTextMod(400,150,"CUSTOM FONT:",20,20,#True);<- debug font
          *tile\DrawText(*font,400,350,"123",#True,#True)        ;<- new font
          *engine\DrawText(40,40,"Font Tile:")
          *texture\Draw(140,40)
          *engine\DrawBox(20,20,200,70)
          *engine\RenderEnd()
        ForEver
        *engine\Release()
      EndIf
      CloseWindow(0) 
    EndIf 
  EndIf
  ProcedureReturn #Null
EndProcedure

Main()

End

DataSection
  font:
  !dw 05089h, 0474Eh, 00A0Dh, 00A1Ah, 00000h, 00D00h, 04849h, 05244h, 00000h, 04000h, 00000h, 02000h, 00208h, 00000h, 02D00h, 0E9FFh, 000D3h, 00100h, 04960h, 04144h, 05854h, 0D585h, 0DB58h, 00311h, 00821h, 032F4h, 094D6h, 0D23Eh, 0AC68h, 0D723h, 0F254h, 08CE1h, 01071h, 04161h, 0C4BDh, 03DFDh, 0E5C0h, 070A5h, 0FBC7h, 00AF9h
  !dw 0233Bh, 01086h, 0E3C2h, 08A8Eh, 0F3A7h, 0E4DFh, 034E3h, 05973h, 0A338h, 0A955h, 0E2BFh, 00136h, 01DF4h, 04720h, 048CAh, 097E7h, 0AB13h, 03358h, 0A74Eh, 09FC1h, 032DAh, 08E87h, 02503h, 026F6h, 04037h, 04210h, 01FC5h, 05A57h, 0071Ah, 0E30Ah, 05979h, 09056h, 0F20Fh, 08A46h, 0C0CBh, 0EA52h, 094EEh, 0B276h, 0A914h, 02910h
  !dw 01056h, 00375h, 0FEC8h, 0B293h, 08594h, 05681h, 08A89h, 0F584h, 0420Ah, 0DBE4h, 00918h, 05A5Ah, 08981h, 028D7h, 0C182h, 0C99Eh, 01109h, 056F2h, 0E753h, 01ACEh, 04073h, 0AEB3h, 0C96Bh, 02A00h, 0EC73h, 0601Dh, 02C1Fh, 00DB9h, 0371Ch, 0C8A6h, 07FA4h, 0FA8Dh, 053CEh, 0DD25h, 0D695h, 0E341h, 065C0h, 03FD7h, 0910Eh, 0EDD2h
  !dw 01A32h, 0708Bh, 03EECh, 06F4Eh, 0819Fh, 0F7EDh, 07981h, 05819h, 0B731h, 0D002h, 0D1AEh, 0E40Ch, 01A6Dh, 0BF79h, 089F0h, 01948h, 010E6h, 02373h, 02D60h, 0A9CBh, 04523h, 044D5h, 0466Ah, 02109h, 00FE1h, 07103h, 07711h, 0E1BDh, 08E61h, 0B698h, 044B2h, 0C73Ah, 0425Ch, 0BCF8h, 08ADEh, 0FE39h, 0A803h, 09383h, 0A328h, 0128Dh
  !dw 07960h, 0EAD4h, 0506Ah, 071C1h, 08C8Bh, 0E6BAh, 07469h, 04C1Dh, 05BEBh, 0EC91h, 00364h, 02FF8h, 008B4h, 0DCA6h, 0FBF6h, 0D9B8h, 05989h, 0B9B5h, 0386Ch, 06E1Eh, 06D15h, 04627h, 0D650h, 09342h, 04411h, 0BCCCh, 0BBD4h, 0E2B1h, 0C3EDh, 0FE6Ch, 01A68h, 0E79Dh, 0F6F0h, 0C0FBh, 00907h, 0B393h, 041ECh, 05078h, 00040h, 00000h
  !dw 04900h, 04E45h, 0AE44h, 06042h, 00082h
EndDataSection


Top
 Profile  
Reply with quote  
 Post subject: Re: [ENGINE] 2D Engine Nautilus (Win x86 & x64)
PostPosted: Sun Dec 06, 2020 12:47 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Sep 11, 2016 2:17 pm
Posts: 846
Update 1.115 (most important changes):
- Added support for multiple outputs
- Improved the quality of the debug font

Download:
https://www.dropbox.com/s/4gyaxi1fcb1ol7c/ne_v1.115.zip?dl=0

Render to multiple outputs example:

Image

Example code:
Code:
EnableExplicit

XIncludeFile "nautilus.pbi"

Procedure.i Main()
  Protected Dim *engine.NAUTILUS_ENGINE(1)
  Protected index.i
  If nautilusVersion() = #NAUTILUS_VERSION
    If OpenWindow(0,0,0,800,600,#Null$,#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_MinimizeGadget)
      For index = 0 To 1
        CanvasGadget(index,10 + (index * 330),10,320,200)
        *engine(index) = nautilusEngine(GadgetID(index),320,200)
      Next
      Repeat
        Repeat
          Select WindowEvent()
            Case #PB_Event_CloseWindow
              Break 2
            Case #Null
              Break
          EndSelect
        ForEver
        For index = 0 To 1
          *engine(index)\RenderBegin()
          *engine(index)\DrawText(160,100,"Hello World! - Context: " + Str(index),#True,#True)
          *engine(index)\RenderEnd()
        Next
      ForEver
    EndIf
    For index = 0 To 1
      *engine(index)\Release()
    Next
    CloseWindow(0) 
  EndIf 
  ProcedureReturn #Null
EndProcedure

Main()

End


Top
 Profile  
Reply with quote  
 Post subject: Re: [ENGINE] 2D Engine Nautilus (Win x86 & x64)
PostPosted: Wed Dec 30, 2020 9:44 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Sep 11, 2016 2:17 pm
Posts: 846
Update v.1.117:
- Changed debug font
- Added the ability to capture ingame screenshots

Download:
https://www.dropbox.com/s/2yk29y3mg07rsmg/ne_v.1.117.zip?dl=0


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 49 posts ]  Go to page Previous  1, 2, 3, 4

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 17 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye