Nathan C:
Programming can be a very rewarding and enjoyable experience. However, there are times when frustration sets in. Try to look at problems as a challenge to learn new things.
I have modified your code so that there is collision between Link and the house. It prints "Collision = 1" on the screen when they are colliding. Hopefully, this will help you.
SYNC ON : SYNC RATE 90
GLOBAL X AS INTEGER = 0 : GLOBAL Xspeed as integer : Xspeed = 1
GLOBAL Y AS INTEGER = 0 : GLOBAL Yspeed as integer : Yspeed = 1
GLOBAL oldx as integer : GLOBAL oldy as integer
GLOBAL direction as integer = 2
CImage1 = 5
CImage2 = 6
CImage3 = 7
CImage4 = 8
CImage5 = 32
CImage6 = 33
TIM = timer()
ImageTim = timer()
OldDirection = 1
CurrentImage = 25
set image colorkey 255,255,255
color backdrop rgb(72,152,72)
`****************Animation Of Link walking Right*******************
load bitmap "Media/spr_Link_Right_strip6.png",1
get image 5,0,0,19,26,5
get image 6,20,0,38,26,5
get image 7,39,0,58,26,5
get image 8,58,0,78,26,5
get image 9,78,0,98,26,5
get image 10,98,0,118,26,5
`******************************************************************
`************Animation of Link walking Left********************
load bitmap "Media/spr_Link_Left_Strip6.png",2
get image 11,0,0,19,26,6
get image 12,19,0,39,26,6
get image 13,40,0,59,26,6
get image 14,60,0,79,26,6
get image 15,80,0,99,26,6
get image 16,100,0,119,26,6
`******************************************************************
`*************Animation of Link Walking Down***********************
load bitmap "Media/spr_Link_Front_strip8.png",3
get image 17,0,0,17,26,7
get image 18,17,0,37,26,7
get image 19,37,0,57,26,7
get image 20,57,0,77,26,7
get image 21,77,0,97,26,7
get image 22,97,0,117,26,7
get image 23,117,0,137,26,7
get image 24,137,0,157,26,7
`******************************************************************
`************Animation of Link Walking Up*************************
load bitmap "Media/spr_Link_Back_strip7.png",4
get image 25,0,0,20,26,8
get image 26,20,0,40,26,8
get image 27,40,0,60,26,8
get image 28,60,0,80,26,8
get image 29,80,0,100,26,8
get image 30,100,0,120,26,8
get image 31,120,0,140,26,8
`*****************************************************************
`**********Loading Tiles*******************************************
load bitmap "Media/house.bmp",5
get image 32,0,0,106,102,32
`****************************************************************
`**********Road One Sprite*****************************************
load bitmap "Media/ground.bmp",6
get image 33,0,0,28,131,33
`******************************************************************
set current bitmap 0
`***Main loop***
`***************sprites*********************************
sprite 5,x,y,CurrentImage :`
set sprite priority 5,100
`sprite 6,x,y,CImage2 `Ani Left
`sprite 7,x,y,CImage3 `Ani Down
`sprite 8,x,y,CImage4 `Ani Up
sprite 32,120,180,CImage5 `House
sprite 33,156,283,CImage6 `Ground One
`*******************************************************
DO
`************** Link Walking right *************************
if rightkey() and timer() > tim
oldx = x
inc x,Xspeed
sprite 5,x,y,CurrentImage
collision = CheckCollision(5,32)
if collision = 1
text 100,100,"Collision = 1" : sync : wait 500
x = oldx
sprite 5,x,y,CurrentImage
else
if direction <> 4 then direction = 4 : CurrentImage = 5
tim = timer() + 10
endif
endif
`********************************************************
`**************Link Walking Left*************************
if leftkey() and timer() > tim
oldx = x
dec x,Xspeed
sprite 5,x,y,CurrentImage
collision = CheckCollision(5,32)
if collision = 1
text 100,100,"Collision = 1" : sync : wait 500
x = oldx
sprite 5,x,y,CurrentImage
else
if direction <> 8 then direction = 8 : CurrentImage = 11
tim = timer() + 10
endif
endif
`*********************************************************
`**********Link Walking Down******************************
if downkey() and timer() > tim
oldy = y
inc y,Yspeed
sprite 5,x,y,CurrentImage
collision = CheckCollision(5,32)
if collision = 1
text 100,100,"Collision = 1" : sync : wait 500
y = oldy
sprite 5,x,y,CurrentImage
else
if direction <> 2 then direction = 2 : CurrentImage = 17
tim = timer() + 10
endif
endif
`*************************************************************
`***************Link Walking Up*******************************
if upkey() and timer() > tim
oldy = y
dec y,Yspeed
sprite 5,x,y,CurrentImage
collision = CheckCollision(5,32)
if collision = 1
text 100,100,"Collision = 1" : sync : wait 500
y = oldy
sprite 5,x,y,CurrentImage
else
if direction <> 1 then direction = 1 : CurrentImage = 25
tim = timer() + 10
endif
endif
`*************************************************************
`********************* Animate Link ************************
if timer() > ImageTim
inc CurrentImage,1
select direction
case 1 : ` up
if CurrentImage > 31 then CurrentImage = 25
endcase
case 2 : ` down
if CurrentImage > 24 then CurrentImage = 17
endcase
case 4 : ` right
if CurrentImage > 10 then CurrentImage = 5
endcase
case 8: ` left
if CurrentImage > 16 then CurrentImage = 11
endcase
endselect
Imagetim = timer() + 30
endif
remstart
`*************Sprites/Tiles**********************************
set sprite priority 5,100
set sprite priority 6,100
set sprite priority 7,100
set sprite priority 8,100
show sprite 32
`**************************************************************
`*********************sprite collisions*************************
if sprite collision(8,32)<=0
oldx = x : oldy = y
else
x = oldx : y = oldy
endif
`**************************************************************
remend
SYNC
LOOP
end
function CheckCollision(s1 as integer,s2 as integer)
collision = sprite collision(s1,s2)
endfunction collision