I'll fix a few things and upload a new version 
you can do
if <x of <self>> is lower than 0
set x of <self> to 0
if x of <self> is higher than screenwidth - width of self
set x of <self> to screenwidth - width of self
you figure the rest out for Y axis.