Bin über einen 3D Effekt für 2D Spiele in der Vogelperspektive gestolpert
Eventuell hat jemand Interesse daran diesen Effekt für mehrere Objekte nutzbar zu machen.
Ich habe noch nicht herausgefunden was ich tun muss wenn das Objekt nicht zentral liegt.
Hier der Code:
Code: Alles auswählen
EnableExplicit
;Nautilus Engine
;Version: 0.26 beta
XIncludeFile "nautilus.pbi"
Structure VECTOR_STRUCT
x.f
y.f
EndStructure
Procedure.i Dummy(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 *sprite.NAUTILUS_SPRITE
Protected *light.NAUTILUS_LIGHT
Protected index.i
Protected player.VECTOR_STRUCT
Protected center_ground.VECTOR_STRUCT
Protected center_top.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()
*engine\ViewPortCenter(@screen_center)
Repeat
Repeat
win_msg = WindowEvent()
If win_msg = #PB_Event_CloseWindow
Break 2
EndIf
Until win_msg = #Null
If *engine\InputKey(#VK_W):player\y + 5 * engine_delta:EndIf
If *engine\InputKey(#VK_S):player\y - 5 * engine_delta:EndIf
If *engine\InputKey(#VK_A):player\x + 5 * engine_delta:EndIf
If *engine\InputKey(#VK_D):player\x - 5 * engine_delta:EndIf
*engine\RenderBegin(@engine_delta,@engine_fps,@engine_error)
*engine\DrawCircle(screen_center\x,screen_center\y,16)
*engine\DrawText(screen_center\x + 5,screen_center\y + 10,"Player",#True)
center_ground\x = screen_center\x + player\x
center_ground\y = screen_center\y + player\y
center_top\x = screen_center\x + (player\x * 1.2)
center_top\y = screen_center\y + (player\y * 1.2)
*engine\DrawLine(center_ground\x - 50,center_ground\y - 50,center_top\x - 50,center_top\y - 50)
*engine\DrawLine(center_ground\x + 50,center_ground\y - 50,center_top\x + 50,center_top\y - 50)
*engine\DrawLine(center_ground\x + 50,center_ground\y + 50,center_top\x + 50,center_top\y + 50)
*engine\DrawLine(center_ground\x - 50,center_ground\y + 50,center_top\x - 50,center_top\y + 50)
*engine\DrawText(screen_center\x + player\x,screen_center\y + player\y + 55,"House or Wall with Antenna",#True)
*engine\DrawBox(screen_center\x + player\x,screen_center\y + player\y,100,100,#True)
*engine\DrawBox(screen_center\x + (player\x * 1.2),screen_center\y + (player\y * 1.2),100,100,#True)
center_ground\x = screen_center\x + (player\x * 1.2) - 10
center_ground\y = screen_center\y + (player\y * 1.2) - 10
center_top\x = screen_center\x + (player\x * 1.4) - 10
center_top\y = screen_center\y + (player\y * 1.4) - 10
*engine\DrawLine(center_ground\x - 5,center_ground\y - 5,center_top\x - 5,center_top\y - 5)
*engine\DrawLine(center_ground\x + 5,center_ground\y - 5,center_top\x + 5,center_top\y - 5)
*engine\DrawLine(center_ground\x + 5,center_ground\y + 5,center_top\x + 5,center_top\y + 5)
*engine\DrawLine(center_ground\x - 5,center_ground\y + 5,center_top\x - 5,center_top\y + 5)
*engine\DrawBox(screen_center\x + (player\x * 1.2) - 10,screen_center\y + (player\y * 1.2) - 10,10,10,#True)
*engine\DrawBox(screen_center\x + (player\x * 1.4) - 10,screen_center\y + (player\y * 1.4) - 10,10,10,#True)
*engine\DrawText(10,10,"Nautilus Engine")
*engine\DrawText(10,25,"FPS " + Str(engine_fps))
*engine\DrawText(10,40,"DLT " + StrF(engine_delta,2))
*engine\RenderEnd()
If engine_error
Break
EndIf
ForEver
*engine\Release()
EndIf
CloseWindow(win)
EndIf
EndProcedure
Dummy(1080,720,#Null$,600,400,30)
End