ok, it will not work with GLFW:
Import mojo
Class Test Extends App
Field mX:Int
Field mY:Int
Field w:Float
Field h:Float
Field rot:Float
Field fps:Int
Field tmpFps:Int
Field time:Int
Field dx:Float
Field dy:Float
Field ix:Float
Field iy:Float
Field screen:Image
Field monkey:Image
Field bName:String
Method OnCreate:Int()
screen = LoadImage("screen.jpg")
monkey = LoadImage("monkey.png")
mX = 0.0
mY = 0.0
rot = 0.0
time = Millisecs()
dx = 1.0
dy = 1.0
ix = 0.0
iy = 0.0
SetUpdateRate(900)
Return 0
End
Method OnUpdate:Int()
Local cw:Float = DeviceWidth()
Local ch:Float = DeviceHeight()
If cw <> w Or ch <> h
w = cw
h = ch
If cw > ch Then rot = 0.0 Else rot = 0.5
Endif
mX = MouseX()
mY = MouseY()
ix = ix + dx
iy = iy + dy
If ix + monkey.Width() > w
dx = -1
Endif
If iy + monkey.Height() > h
dy = -1
Endif
If ix < 0
dx = 1
Endif
If iy < 0
dy = 1
Endif
tmpFps = tmpFps + 1
Local tmpTime:Int = Millisecs()
If tmpTime - time > 1000
fps = tmpFps
tmpFps = 0
time = tmpTime
Endif
Return 0
End
Method changeDirection:Float(dir:Float)
Return 0 - dir
End
Method OnRender:Int()
DrawImage(screen, 0, 0, 0.0, w / screen.Width(), h / screen.Height())
DrawImage(monkey, ix, iy)
DrawText(mX + ", " + mY + " @" + w + "x" + h + " : " + fps + "FPS on " + bName, 10, 10)
Return 0
End
Method MidHandle:Void(image:Image)
image.SetHandle( Floor(image.Width() * 0.5), Floor(image.Height() * 0.5) )
End
End
Function Main:Int()
New Test
Return 0
End
|