[ENGINE] 2D Engine Nautilus (Win)

Anwendungen, Tools, Userlibs und anderes nützliches.
Benutzeravatar
Mijikai
Beiträge: 754
Registriert: 25.09.2016 01:42

Re: [ENGINE] 2D Engine Nautilus (Win)

Beitrag von Mijikai »

Update: Version 0.33 beta

Es gibt ein neues Interface mit 2D TileMap & Camera Funktionen :)

Interface:

Code: Alles auswählen


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
Beispiel:
Bild

Code:

Code: Alles auswählen


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 ti 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
Benutzeravatar
diceman
Beiträge: 347
Registriert: 06.07.2017 12:24
Kontaktdaten:

Re: [ENGINE] 2D Engine Nautilus (Win)

Beitrag von diceman »

Ganz doofe Frage vielleicht, aber was kann ich mit der Demo anstellen?
Der Titelbildschirm lädt soweit ... und das war's dann schon. Egal wo ich mit welcher Maustaste hinklicke, und welche Tasten ich drücke, nichts passiert.
Der einzige Button der funktioniert, ist der closeWindow-Button oben rechts. :wink:
Now these points of data make a beautiful line,
And we're out of Beta, we're releasing on time.
Benutzeravatar
Mijikai
Beiträge: 754
Registriert: 25.09.2016 01:42

Re: [ENGINE] 2D Engine Nautilus (Win)

Beitrag von Mijikai »

diceman hat geschrieben:Ganz doofe Frage vielleicht, aber was kann ich mit der Demo anstellen?
Der Titelbildschirm lädt soweit ... und das war's dann schon. Egal wo ich mit welcher Maustaste hinklicke, und welche Tasten ich drücke, nichts passiert.
Der einzige Button der funktioniert, ist der closeWindow-Button oben rechts. :wink:
Die Demo die sich im zip Archiv befindet zeigt nur ein paar Grundfunktionen der Engine.
- Initialsierung und Einbindung in PureBsic
- Erstellung von Textur Atlanten, Sprites und Licht Objekten
- Rendern von Atlanten, Sprites und Text (normal, rotiert, eingefärbt, gespiegelt bzw. als Licht)

Beispiele zu neuen Funktionen werden ergänzt und sind momentan in den jeweiligen Posts zu den Updates zu finden.
Tiefergehende Beispiele sowie eine Dokumentation der einzelnen Funktionen gibt es zum aktuellen Zeitpunkt noch nicht.
Benutzeravatar
Mijikai
Beiträge: 754
Registriert: 25.09.2016 01:42

Re: [ENGINE] 2D Engine Nautilus (Win)

Beitrag von Mijikai »

Update: Version 0.34 beta

Neue Funktion hinzugefügt um Fake 3D Effekte zu erzeugen.

Code: Alles auswählen

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

Code:

Code: Alles auswählen

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
Benutzeravatar
Mijikai
Beiträge: 754
Registriert: 25.09.2016 01:42

Re: [ENGINE] 2D Engine Nautilus (Win)

Beitrag von Mijikai »

Update: Version 0.35 beta

Neue Funktionen :)
Direktzugriff auf die Pixel von Sprites, Tiles and Fonts.
Für Effekte oder die Bildbearbeitung (z.B. interner Textur Editor)

Code: Alles auswählen

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
Benutzeravatar
Mijikai
Beiträge: 754
Registriert: 25.09.2016 01:42

Re: [ENGINE] 2D Engine Nautilus (Win)

Beitrag von Mijikai »

Version 1.00 :)

Finally :D

Es gib neue Funktionen (Pathfinding):

Code: Alles auswählen

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
Danke @diceman für die Unterstützung beim Pathfinding. :allright:
Benutzeravatar
Rings
Beiträge: 971
Registriert: 29.08.2004 08:48

Re: [ENGINE] 2D Engine Nautilus (Win)

Beitrag von Rings »

Sorry Mijikai,

ich habe mit den Download gegönnt und auch in den kleine Quellcode reingeschaut.

Keine Doku, keine samples zu den Befehlen.

Sowas ist bei mir nicht Version 1, sondern irgendwas mit Alpha und vor Beta.

Leider kann ich auch so überhaupt nichts über die Qualität deiner Engine
richtig urteilen, weil ich überhaupt nicht weiss wie ich sie anwende.

Nicht alle hier im Forum sind Autoditakten......
Rings hat geschrieben:ziert sich nich beim zitieren
Benutzeravatar
Mijikai
Beiträge: 754
Registriert: 25.09.2016 01:42

Re: [ENGINE] 2D Engine Nautilus (Win)

Beitrag von Mijikai »

Rings hat geschrieben:Sorry Mijikai,
Keine Doku, keine samples zu den Befehlen.
Beispiele sind geplant, da ich jedoch alleine daran arbeite wird es es noch eine Weile dauern.
Hab die Veröffentlichung zurückgezogen.
Benutzeravatar
Mijikai
Beiträge: 754
Registriert: 25.09.2016 01:42

Re: [ENGINE] 2D Engine Nautilus (Win)

Beitrag von Mijikai »

Version 1.00 kann jetzt getestet werden.
Ich arbeite immer noch an Beispielen bei Fragen einfach melden.
Antworten