As for the direction the sprite is facing, what you could do is use a variable to keep track of which way he is facing, and if he is facing the wrong way then use 'flip sprite.' For example:
spriteDirection = 1
do
if leftkey()
rem move the sprite left
x = x-1
rem check if sprite is facing right
if spriteDirection = 1
rem if it is, switch it to left and flip the sprite
spriteDirection = 2
flip sprite 1
endif
endif
if rightkey()
rem move the sprite right
x = x+1
rem check if sprite is facing left
if spriteDirection = 2
rem if it is, switch it to left and flip the sprite
spriteDirection = 1
flip sprite 1
endif
endif
loop
To slow down the player, change the varibles by a smaller amount. So instead of "x = x-1", you would have "x = x-.2" for example. Make sure, however, that the variable is a float, because integers can only be whole numbers, no decimals. To declare a float, use
And so on at the beginning of your program. That way you can use decimals.
Finally for your last question - your code should work, you're just missing one thing - it sounds like the coordinates of your sprite are from the top-left corner of the sprite. So if you place the sprite at 0,0, then the top-left corner would be at 0,0. The problem is that the sprite has width and height. So when you check if the x is greater than 640, that's from the top-left corner. The corner might still be less that 640, but most of your sprite could be off the screen! So to make up for this, subtract the width and the height of the sprite from the coordinates you are checking. So for example, if the sprite was 30 pixels by 50 pixels, your code would look like this:
if x<0 then x=1
if x>610 then x=609
if y<0 then y=1
if y>430 then y=429
Because 640-30=610 and 480-50=430.
Hope that made sense. Good luck with your game!
-H4ck1d