Thought this might be helpful to someone eventually, but most of all I was bored so I made it lol. It simply makes a character walk left or right and face the correct direction. Code is short but heavily commented making it look big. Also pushes a second character when you walk into it. One image file(sprite) is required to use the code.
This is my own way I came up with, might not be the best, but it works!
So no making fun of me when someone comes in and shows me how to do it in 3 lines lol. Anyway, Enjoy
sync on
sync rate 30
`Transparent Color of Sprite. Change
` This To The BackGround Color of Your Sprite
set image colorkey 0,255,0
`Our Image For Our Sprite
`Change This To Your Own Image
Load Image "Sprites\drybones.bmp",1
`Our Players Position
x=200
y=200
`Our Second Characters Position
x2=400
y2=200
`Determines Which Way We Are Facing
faceleft=0
`At Start We Are Facing Right So This Is Set To One
faceright=1
`Main Loop
do
`Will Store Our Old Position In Case of Collision
oldx=x-1
oldy=y
`Paste our Sprites to the Screen Using Our X and Y
`Variable We Set Earlier
sprite 1,x,y,1
sprite 2,x2,y2,1
`If Right Key Is Pressed FaceLeft is Set to FALSE
`If Facing Right is False Set it To True and Flip
`Our Sprite To Make it Face The Correct Way
`Then Set Face Right To TRUE
if rightkey()=1
faceleft=0
if faceright=0 then Mirror sprite 1
faceright=1
`Move Our Characters X Position by 3 to the Right
x=x+3
endif
`If Left Key Is Pressed FaceRight is Set to FALSE
`If Facing Left is False Set it To True and Flip
`Our Sprite To Make it Face The Correct Way
`Then Set Face Left To TRUE
if leftkey()=1
faceright=0
if faceleft=0 then Mirror sprite 1
faceleft=1
`Move Our Characters X Position by 3 to the Left
x=x-3
endif
`If We Collide With Sprite 2 Move Our Character BACK
`To The oldx Position Which is Where We Were BEFORE
`We Hit It
if sprite collision(1,2)=1
x=oldx
`Move Sprite 2 To The Right by 2 If We Are Colliding
`With It. This Makes Us Push Sprite 2 To The Right
x2=x2+2
endif
sync
loop