January 27, 2021, 07:54:09 AM

Author Topic: Targeting AGK Tier2 with Cerberus X  (Read 327 times)

Offline MikeHart

  • Hero Member
  • *****
  • Posts: 756
  • Cerberus X developer
    • Cerberus X
Targeting AGK Tier2 with Cerberus X
« on: June 17, 2020, 07:29:12 PM »
Hi folks,


as some here are AGK users and might want to target Tier 2 for the extra performance of their game logic, using Cerberus X instead of C++ might be an option. You still need to set up Microsoft Visual Studio 2017 and build the modules and targets, but after that it is quite easy. You can use ALL of the AGK API.


CX supports AGK Tier2 on Windows, OSX and IOS so far with Android coming soon.


Here is a small example:


Code: [Select]
Strict

#TEXT_FILES+="*.obj"


#AGK_DEVICE_WIDTH = 640
#AGK_DEVICE_HEIGHT = 480
#AGK_DEVICE_POS_X = 32
#AGK_DEVICE_POS_Y = 32
#AGK_FULLSCREEN = False


Import agk2


Global game:myGame = Null


'*********************************************************************
Class cShip
Field _id:Int
Field _img:Int
Field _name:String
'---------------------------------------------
Method New()
SetSyncRate(9999,0)
SetVSync(0)
_id = LoadObjectWithChildren("media/Lifeboat.obj")
_img = LoadImage("media/lifeboat_diffuse.png")


SetObjectImage(_id, _img, 0)
SetObjectScale(_id,3,3,3)
SetObjectCastShadow(_id, 1)
SetObjectPosition(_id,0,-0.1,0)
SetObjectRotation(_id,0,135,0)
End
'---------------------------------------------
Method Remove:Int()
DeleteImage(Self._img)
DeleteObject(Self._id)
Return 0
End
'---------------------------------------------
Method Update:Int()
SetObjectRotation(_id,0,GetObjectAngleY(_id)+10*GetFrameTime() ,0)
Return 0
End
End


'*********************************************************************
Class myGame
Field ship:cShip
Field counter:Int = 1
'---------------------------------------------
Method LoadMedia:Int()
'The ship
ship = New cShip

'Water plane
Local plane := CreateObjectPlane(150,150)
Local img2 := LoadImage("media/water.jpg")
SetObjectImage(plane, img2, 0)
SetObjectRotation( plane, 90,0,0)
Return 0
End

'---------------------------------------------
Method Setup_Camera:Int()
SetCameraRange(1,1,1510)
SetCameraPosition( 1,-2,2,4 )
SetCameraLookAt( 1,0,0,0,0 )
SetPrintSize(20)
SetShadowMappingMode( 2 )
Return 0
End

'---------------------------------------------
Method Setup_Lights:Int()
SetSunColor( 255,255,155 )
SetSunActive(1)
'SetSunDirection( -0.3, -0.3, 0.5 )
SetAmbientColor( 80,80,180 )
Return 0
End

'---------------------------------------------
Method Setup_Window:Int()
SetWindowTitle("Cerberus X -> AppGameKit")
SetVirtualResolution(GetDeviceWidth(),GetDeviceHeight())
SetClearColor(0,0,100)
SetAntialiasMode( 1 )
SetGenerateMipmaps(0)

SetSyncRate(0,0)
SetVSync(0)
SetScissor(0,0,0,0)
Return 0
End

'---------------------------------------------
Method New()
' Setup stuff
Setup_Window()
Setup_Camera()
Setup_Lights()
LoadMedia()
End

'---------------------------------------------
Method Update:Int()
' Update the ship
ship.Update()

' Delete and recreate the ship when ESCAPE is pressed
If GetRawKeyState(KEY_ESCAPE) = 1
ship.Remove()
ship = New cShip
counter += 1
Endif
Return 0
End

'---------------------------------------------
Method Render:Int()
' Print out some debug informations
agk_PrintC( "ScreenFPS= " ) ; agk_Print( ScreenFPS() )
agk_PrintC( "Polygons= " ) ; agk_Print( GetPolygonsDrawn() )
agk_PrintC( "Memory= " ) ; agk_Print( GetImageMemoryUsage() )
agk_PrintC( "Objects created= " ) ; agk_Print( counter )


' Render everything
Sync()
Return 0
End
End


'*********************************************************************
Function Main:Int()
' The Main function will be called from the AGK template continuously
' in every frame/loop, till you return a value of 1. That will close the app.

' Create our main class
If game = Null Then game = New myGame

' Update and render the content
game.Update()
game.Render()

Return GetPointerPressed()
End

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal