here is the code i am using
rem
rem AGK Application
rem
rem Landscape App
SetVirtualResolution (1024, 768)
SetDisplayAspect ( 4.0/3.0 )
// display a background
CreateSprite (1, LoadImage("gameboard.png"))
SetSpriteSize (1, 1024, 768)
//Load First PLayer
LoadImage (2, "woman_001.png")
CreateSprite (2, 2)
SetSpritePosition (2, 500, 240)
SetSpriteAnimation (2, 39, 98, 9)
global g_flagPlayerSelected = 1;
global sprite = 0
global flag = 0
rem A Wizard Did It!
do
if (GetPointerPressed() = 1)
// store the location of input
x = GetPointerX ( )
y = GetPointerY ( )
if ( move = 0 )
flag = 1
move = 1
// save the current position
originalX# = GetSpriteX ( 2 )
originalY# = GetSpriteY ( 2 )
// work out the destination
destinationX# = x
destinationY# = y
distanceX# = destinationX# - originalX#
distanceY# = destinationY# - originalY#
distanceFromAtoB# = sqrt ( ( distanceX# * distanceX# ) + ( distanceY# * distanceY# ) )
if ( distanceFromAtoB# <> 0.0 )
directionX# = distanceX# / distanceFromAtoB#
directionY# = distanceY# / distanceFromAtoB#
endif
endif
endif
// check if it's okay to move
if ( flag = 1 )
// work out new location
newX# = originalX# + directionX# * move
newY# = originalY# + directionY# * move
// increment our move variable as long as we haven't reached our destination
if ( move < distanceFromAtoB# )
move = move + 0.51
else
// reset variables
move = 0
flag = 0
endif
// start the walk animation
animatePlayer(2)
// update position of our sprite
movePlayer(2, newX#, newY#)
else
StopAnimatingPlayer(2)
endif
Sync()
loop
function animatePlayer(spriteID as integer)
PlaySprite (2, 7, 1, 1, 9)
endfunction
function StopAnimatingPlayer(spriteID as integer)
StopSprite(2)
endfunction
function movePlayer(spriteID as integer, x as integer, y as integer)
SetSpritePosition (spriteID, x, y)
endfunction
just as a side not though, if i comment out the
SetSpritePosition (spriteID, x, y)
it takes like 4 seconds til the animation truely starts animating. the file isnt to big i have it attached.
i guess what i dont understand is that the main game loop will always be running, from direct x past, its fairly easy to start animating a sprite then move it all at the same time, by doing much what i already have above.
thanks for the help
p.s. is there a equivelent to vb's doevents function that will force the animation to run while moving by using the above code?
Cheers,
Deion G.