#option_explicit
//MR 02.01.2018
SetViewZoomMode(1) // 1 = Center
type Ball
spr as integer
sx as float
sy as float
magnitute as float
endtype
Main()
End
Function Main()
local ball as Ball
ball.spr = CreateSprite(0)
SetSpritePositionByOffset(ball.spr,50,50)
local x as float,y as float, z as float
local dx as float,dy as float
Do
print("Use Cursor Keys")
//Joy Input
dx = GetDirectionX()
dy = GetDirectionY()
//Add
ball.sx = ball.sx + dx / 100.0
ball.sy = ball.sy + dy / 100.0
ball.sx = ball.sx * 0.999 //Friction
ball.sy = ball.sy * 0.999
x = GetSpriteXByOffset(ball.spr)
y = GetSpriteYByOffset(ball.spr)
x = x + ball.sx
y = y + ball.sy
//--------------- in screen
if x<0
x=0
ball.sx=-ball.sx
endif
if x>100.0
x=100.0
ball.sx=-ball.sx
endif
if y<0
y=0
ball.sy=-ball.sy
endif
if y>100.0
y=100.0
ball.sy=-ball.sy
endif
//---------------
SetSpritePositionByOffset(ball.spr,x,y)
ball.magnitute = sqrt(ball.sx*ball.sx + ball.sy*ball.sy)
print("Ball")
print(ball.magnitute)
z = ball.magnitute
if z > 0.8 then z = 0.8
z = 1.0 - z
print("Zoom")
print(z)
SetViewZoom(z)
Border()
Sync()
Loop
EndFunction
Function Border()
local col as Integer
col = MakeColor(255,255,0)
DrawBox( WorldToScreenX(0),WorldToScreenY(0),WorldToScreenX(100),WorldToScreenY(100),col,col,col,col,0)
EndFunction
Help make AGK better by submitting an example for this command! (All examples are subject to approval)