you can use
x= getPointerX()
then x is int
pointer use float because 0-100%.
i missing float(x) and int(x#) too.
for a grid i use this:
x#=getpointerx()
y#=getpointery()
x1=Grid(x#,10.0)
y1=Grid(y#,10.0)
setspriteposition(sprite,x1,y1)
function Grid(v#,grid#)
v#=floor(v#/grid#)*grid#
endfunction v#
rem
rem AGK Application 1.08 Beta 11
rem
rem MR 26.01.2013
Test()
end
Function Test()
sprite=createsprite(0)
bench=1
do
Print("hello snap")
//if bench then ShowBenchmarking()
if getpointerpressed()=1 then exit
x#=getpointerx()
y#=getpointery()
PrintXY("mouse",x#,y#)
x#=LimitFloat(x#,10.0,90.0)
y#=LimitFloat(y#,10.0,90.0)
PrintXY("limited mouse",x#,y#)
DrawCrossLine(x#,y#,255,255,0)
x#=SnapToGridX(x#,5)
y#=SnapToGridY(y#,5)
PrintXY("snap",x#,y#)
DrawCrossLine(x#,y#,255,128,64)
a=LimitFloat(1,10,90)
b=LimitFloat(95,10,90)
PrintXY("Test",a,b)
x#=getpointerx()
y#=getpointery()
x1=Grid(x#,10.0)
y1=Grid(y#,10.0)
setspriteposition(sprite,x1,y1)
Sync()
loop
endfunction
function Grid(v#,grid#)
v#=floor(v#/grid#)*grid#
endfunction v#
function LimitFloat(a#,min#,max#)
if a#<min#
a#=min#
exitfunction a#
endif
if a#>max#
a#=max#
exitfunction a#
endif
endfunction a#
function LimitFloatOpt(a#,min#,max#)
//From Marl
if a#<min# then exitfunction min#
if a#>max# then exitfunction max#
endfunction a#
function LimitInteger(a,min,max)
if a<min
a=min
exitfunction a
endif
if a>max
a=max
exitfunction a
endif
endfunction a
function SnapToGridX(x#,distance#) //example snapping x positions
x#=Snap( 0.0,x#,distance#)
x#=Snap( 10.0,x#,distance#)
x#=Snap( 20.0,x#,distance#)
x#=Snap( 30.0,x#,distance#)
x#=Snap( 40.0,x#,distance#)
x#=Snap( 50.0,x#,distance#)
x#=Snap( 60.0,x#,distance#)
x#=Snap( 70.0,x#,distance#)
x#=Snap( 80.0,x#,distance#)
x#=Snap( 90.0,x#,distance#)
x#=Snap(100.0,x#,distance#)
endfunction x#
function SnapToGridY(y#,distance#) //example snapping y positions
y#=Snap( 0.0,y#,distance#)
y#=Snap( 10.0,y#,distance#)
y#=Snap( 20.0,y#,distance#)
y#=Snap( 30.0,y#,distance#)
y#=Snap( 40.0,y#,distance#)
y#=Snap( 50.0,y#,distance#)
y#=Snap( 60.0,y#,distance#)
y#=Snap( 70.0,y#,distance#)
y#=Snap( 80.0,y#,distance#)
y#=Snap( 90.0,y#,distance#)
y#=Snap(100.0,y#,distance#)
endfunction y#
function Snap(sn#,a#,distance#)
//MR 26.01.2013
//snap position sn#
//position a#
//snapping <= distance#
if abs(sn#-a#)<=distance#
a#=sn#
endif
endfunction a#
function DrawCrossLine(x#,y#,r,g,b)
//MR 26.01.2013
//draw a cross
drawline(x#,0,x#,100,r,g,b)
drawline(0,y#,100,y#,r,g,b)
endfunction
function PrintXY(text$,x#,y#)
//MR 26.01.2013
//print text and the x and y value
print(text$)
print("X:"+str(x#))
print("Y:"+str(y#))
endfunction
function ShowBenchmarking()
print ("FPS "+str(screenfps()))
print ("Drawing Setup Time "+str(GetDrawingSetupTime()))
print ("Drawing Time "+str(GetDrawingTime()))
print ("Pixels Drawn "+str(GetPixelsDrawn()))
print ("Update Time "+str(GetUpdateTime()))
print ("Physics Time "+str(GetPhysicsTime()))
print ("Managed Sprite Count "+str(GetManagedSpriteCount()))
print ("Managed Sprite Draw Calls "+str(GetManagedSpriteDrawCalls()))
print ("Managed Sprite Drawn Count "+str(GetManagedSpriteDrawnCount()))
print ("Managed Sprite Sorted Count "+str(GetManagedSpriteSortedCount()))
print ("Particle Drawn Point Count "+str(GetParticleDrawnPointCount()))
print ("Particle Drawn Quad Count "+str(GetParticleDrawnQuadCount()))
print ("Loaded Images "+str(GetLoadedImages()))
UnassignedImages=GetUnassignedImages()
print ("Unassigned Images "+str(UnassignedImages))
for i=1 to UnassignedImages
print ("Unassigned Image FileName "+GetUnassignedImageFileName(i))
next
endfunction