Of course that could be compacted to be more effecient, and in my opinion readable.
For instance this section:
Could be:
And even better would probably be to replace it with a RectsOverlap (or similar) function, if you use it several times.
For instance this section:
If x < 0-w2 Then Return 1 ElseIf x > screenwidth + w2 Then Return 1 If y < 0-h2 Then Return 1 ElseIf y > screenheight + h2 Then Return 1 Return 0 'OK
Could be:
Return (x<-w2) Or (x>screenwidth+w2) Or (y<-h2) Or (y>screenheight+h2)
And even better would probably be to replace it with a RectsOverlap (or similar) function, if you use it several times.