A good way to manage this kind of approach would be
[EDIT]
this will cause the monster to move left to right
Function MonsterMove() If Mdir=0 then if Monsterx=>1 then Monsterx=Monsterx-1 elseif Monsterx=0 then Monsterx=Monsterx+1 Mdir=1 Return endif esleif Mdir=1 then if Monsterx=<760 then Monsterx=Monsterx+1 elseif Monsterx=760 then Monsterx=Monsterx-1 Mdir=0 Return endif endif End Function
[EDIT]
this will cause the monster to move left to right