Hi Diegs.
This probably isn't the best solution, but it gets the job done:
// Project: Test_collision
// Created: 2016-02-04
// set window properties
SetWindowTitle( "Test_collision" )
SetWindowSize( 1024, 768, 0 )
// set display properties
SetVirtualResolution( 1024, 768 )
SetOrientationAllowed( 1, 1, 1, 1 )
global mario = 1
global block = 2
mario = loadimage("mario.png")
mario = CreateSprite(mario)
SetSpritePhysicsOn(mario ,0)
block = loadimage("block.png")
block = CreateSprite(block)
SetSpritePhysicsOn(block ,0)
SetPhysicsDebugOn()
global move_x = 100
global move_y = 400
global vel_x
global vel_y
global old_move_x = 100
global old_move_y = 400
do
if getRawKeyState(27) then exit
vel_x = 0
vel_y = 0
if GetRawKeyState( 40 ) then vel_y = 2
if GetRawKeyState( 38 ) then vel_y = -2
if GetRawKeyState( 39 ) then vel_x = 2
if GetRawKeyState( 37 ) then vel_x = -2
move_x = move_x + vel_x
SetSpritePosition(mario, move_x, move_y)
if GetSpriteCollision ( mario, block )
move_x = move_x - vel_x
SetSpritePosition(mario, move_x, move_y)
endif
move_y = move_y + vel_y
SetSpritePosition(mario, move_x, move_y)
if GetSpriteCollision ( mario, block )
move_y = move_y - vel_y
SetSpritePosition(mario, move_x, move_y)
endif
SetSpritePosition(block,400,400)
Print( ScreenFPS() )
Sync()
loop