from elf2d import *

#-----------------------------------------------
def myGameInitialise():
	global angle
	
	angle = 0

#-----------------------------------------------
def myGameShutdown():
	pass
	
#-----------------------------------------------
def myGameUpdate(deltaTime):
	global angle
	
	angle += deltaTime * 45

#-----------------------------------------------
def myGameRender(deltaTime):
	global angle
	
	elfVideo_Clear(0xFF000000)

	elfQuads_begin()
	elfQuads_setColour(0xFFFF0000)
	
	elfQuads_setShapeRotation(0)
	elfQuads_drawRectangle(32, 32, 64, 64)
	
	elfQuads_setShapeRotation(angle)
	coords = ElfShapeFloat8(0, 0, 10, 0, 10, 10, 0, 15)
	elfQuads_drawShapeOffset(300, 200, coords)
	
	elfQuads_end()

#-----------------------------------------------
myGameInitFunc = TCallbackFunction2(myGameInitialise)
myGameShutFunc = TCallbackFunction2(myGameShutdown)

myGameUpdateFunc = TCallbackFunction1(myGameUpdate)
myGameRenderFunc = TCallbackFunction1(myGameRender)

#-----------------------------------------------
if __name__ == "__main__":

	elfConfig_SetWindowParams(640, 480, True, "Elf2D Python sample")
	print("Elf2D Python sample")
		
	elfConfig_SetInitialiseCallback(myGameInitFunc)
	elfConfig_SetShutdownCallback(myGameShutFunc)
	elfConfig_SetUpdateCallback(myGameUpdateFunc)
	elfConfig_SetRenderCallback(myGameRenderFunc)
	
	if elfSystem_Initialise():
		elfSystem_Run()
		elfSystem_Shutdown()
