プレイ日記
Josiah Spike4
I have a question that needs an answer. I believe i could make some games that are better than my games now, if I knew how to make it detect background collisions. So just to clearify, i need to know how to make it detect a collision between a sprite and background layers. Please help me -Josiah
4そうだね
プレイ済み
返信[1]
親投稿
Zee Storybookten9
The difficulty is that there is no BGCOL or similar command. However, you can detect if a sprite's home is in a BG tile with BGGET(LAYER,SPX/16,SPY/16)==0, though this changes if you use BGOFS.
0そうだね
プレイ済み
返信[2]
親投稿
Josiah Spike4
so how would I use that in the code? like-- if bgget(0,x/16,y/16)==0 then beep?
0そうだね
プレイ済み
返信[3]
親投稿
Zee Storybookten9
Pretty much. Depending on the size of the sprite, I would recommend setting the SPHOME to (8,8), though if you use 32x32, you'd want something more like (16,16). You may want to scan a larger sprite all the way, so instead of IF BGGET(0,X/16,Y/16)==0 you'd do something like FOR I=0 TO (SPRITE SIZE)/16-1 FOR J=0 TO (SPRITE SIZE)/16-1 IF BGGET(0,X/16+I,Y/16+J)==0 THEN BEEP NEXT NEXT
0そうだね
プレイ済み
返信[4]
親投稿
Josiah Spike4
Here, I wrote this code but it isn't working, I don't think. Can you tell me what to fix?
0そうだね
プレイ済み
返信[5]
親投稿
Zee Storybookten9
You're sprite's size is not 1x1, is it? Because that code block wouldn't work for anything smaller than 16x16. If your sprite really is 1x1, just do a single BGGET for it's location, multiple would not be necessary.
0そうだね
プレイ済み
返信[6]
親投稿
Josiah Spike4
ok, Yah I don't believe it is, I just didn't uunderstand. thank you for explaining it. and it is working now. Now all I have to do is tinker with it. Thanks Zee, by the way, Keep on programming. I remember seeing you on here when I first bought this and you and others have inspired me to try harder at programming and not give up. Thanks again :)
1そうだね
プレイ済み