hmm... that sounds like it should work, but the variables within the datatype still seem to be behaving the same... I notice this by the way my sprite only moves at one constant speed as I press each of the arrow keys. I think it should be accelerating.
type gamesprites
global spritexposition as integer
global spriteyposition as integer
global spritexspeed as float
global spriteyspeed as float
endtype
global dim sprites(numsprites) as gamesprites
and this is the main loop
while inkey$()<> "x"
cls
for spritenum = 1 to numsprites
if spritenum = 1
sprites(spritenum).spritexposition = processplayerxposition(sprites(spritenum).spritexposition,sprites(spritenum).spritexspeed)
sprites(spritenum).spriteyposition = processplayeryposition(sprites(spritenum).spriteyposition,sprites(spritenum).spriteyspeed)
sprites(spritenum).spritexspeed = processplayerxspeed(sprites(spritenum).spritexposition,sprites(spritenum).spritexspeed)
sprites(spritenum).spriteyspeed = processplayeryspeed(sprites(spritenum).spriteyposition,sprites(spritenum).spriteyspeed)
endif
if spritenum <> 1 and sprites(spritenum).spritexposition <> -255
sprites(spritenum).spritexposition = processcomxposition(sprites(spritenum).spritexposition,sprites(spritenum).spritexspeed)
sprites(spritenum).spriteyposition = processcomyposition(sprites(spritenum).spriteyposition,sprites(spritenum).spriteyspeed)
sprites(spritenum).spritexspeed = processcomxspeed(sprites(spritenum).spritexposition,sprites(spritenum).spritexspeed)
sprites(spritenum).spriteyspeed = processcomyspeed(sprites(spritenum).spriteyposition,sprites(spritenum).spriteyspeed)
endif
sprite spritenum,sprites(spritenum).spritexposition,sprites(spritenum).spriteyposition,1
next spritenum
sync
endwhile
and this is the function that calculates the speed of the sprite
function processplayerxspeed(playerxposition,playerxspeed)
if leftkey() = 1
xspeed = xspeed - 1
endif
if leftkey() = 0 and rightkey = 0 and xspeed > 0
xspeed = xspeed - 1
endif
if leftkey() = 0 and rightkey = 0 and xspeed < 0
xspeed = xspeed + 1
endif
if rightkey() = 1
xspeed = xspeed + 1
endif
endfunction xspeed
I made it accept a position parameter in case in the future I might want the sprite's speed to be affected by what position it is, such as stopping at the edge of the screen.
The behavior I would've been predicting, is if the variables acted like global ones, is that the sprite would've accelerated to a faster, and faster speed, based on how long the arrow key was pressed, and would've decelerated based on either the arrow key being pressed in the opposite direction, or just no arrow keys being pressed at all. Also I would've predicted that the other sprite would've just traveled at a constant speed diagonally until it was off the screen.
So please let me know what you guys think. Thanks for the assistance.