So I'm experimenting with sprites right now and I've noticed an odd problem... The sprite flickers occasionally. This seems to happen when I have the thing moving diagonally. Any way to take care of this? I've attached the executable for it, and here's the code.
REM Set Display Mode
Set Display Mode 800, 600, 16
REM sets screen update speed
Sync On
Sync Rate 60
Backdrop Off
REM Set transparent color
Set Image Colorkey 255, 0, 255
REM --LOAD ALL IMAGES--
Load Image "butterfly.bmp", 1
Load Image "bullet.bmp", 2
REM --DEFINE AND SET ALL VARIABLES--
Global xpos = 400
Global ypos = 300
Global speed = 5
Global bspeed = 10
Global bexist = 0
Global bposx
Global bposy
REM --MAIN PROGRAM LOOP--
Repeat
CLS
MoveSprite()
FireBullet()
PasteGFX()
Sync
Until Spacekey() = 1
REM --PROGRAM END--
End
REM --Sets the position of the image on the next loop--
Function MoveSprite()
If keystate(17) = 1 AND keystate(31) = 0 AND ypos > 0
ypos = ypos - speed
endif
if keystate(31) = 1 AND keystate(17) = 0 AND ypos < (600 - 32)
ypos = ypos + speed
endif
if keystate(30) = 1 AND keystate(32) = 0 AND xpos > 0
xpos = xpos - speed
endif
if keystate(32) = 1 AND keystate(30) = 0 AND xpos < (800 - 32)
xpos = xpos + speed
endif
endfunction
REM --Creates and positions a bullet if the fire button is pressed
REM If there is no bullet onscreen--
Function FireBullet()
If keystate(157) = 1 AND bexist = 0
bexist = 1
bposx = xpos + 16
bposy = ypos + 16
endif
if bexist = 1 AND bposx <= 800
bposx = bposx + bspeed
else
bexist = 0
endif
Endfunction
REM --Pastes all graphics depending on the positions set by the
REM previous functions--
Function PasteGFX()
print "Press Right CTRL to fire"
print "Press Spacebar or ESC to exit"
print "X Position: ", xpos
print "Y Position: ", ypos
print "bexist: ", bexist
Paste Image 1, xpos, ypos, 1
If bexist = 1
paste image 2, bposx, bposy, 1
endif
Endfunction
Also, I know that arrays are global. If I create an array of UDTs, can I pass just one varialbe of that UDT within the array element? Let's say I create a UDT array each with a name, date, and age. Can I pass just the name, date, or age to a function?