I will add some new examples for now there is only the asteroids game.
Edit:
Heres is another example adapted to the newest version:
Example Plant (texture (aka. sprite), tiles and animation):
Code: Select all
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