lets see if this helps... and please note this is not supposed to be runable code :D
playerx:int
playery:int
objectx:int
objecty:int
size1:int
size2:int
while
cls
gosub move
gosub checkcollision
gosub draw
flip
wend
function move:
if keydown(key_left) then playerx=playerx-1
etc...
etc...
etc...
endfunction
function checkcollision:
if playerx+size1 > objectx then playerx+size1 = objectx
if playerx < objectx+size2 then playerx = objectx+size2
if playery+size1 > objecty then playery+size1 = objecty
if playery < objecty+size2 then playery = objecty+size2
endfunction
function draw:
setcolor 255,0,0
drawrect playerx,playery,size1,size1
setcolor 0,0,255
drawrect objectx,objecty,size2,size2
endfunction
turn that code into usable code and run it. You should be able to run into the object and be repelled.
playerx:int
playery:int
objectx:int
objecty:int
size1:int
size2:int
while
cls
gosub move
gosub checkcollision
gosub draw
flip
wend
function move:
if keydown(key_left) then playerx=playerx-1
etc...
etc...
etc...
endfunction
function checkcollision:
if playerx+size1 > objectx then playerx+size1 = objectx
if playerx < objectx+size2 then playerx = objectx+size2
if playery+size1 > objecty then playery+size1 = objecty
if playery < objecty+size2 then playery = objecty+size2
endfunction
function draw:
setcolor 255,0,0
drawrect playerx,playery,size1,size1
setcolor 0,0,255
drawrect objectx,objecty,size2,size2
endfunction
turn that code into usable code and run it. You should be able to run into the object and be repelled.