Ni ImagesRectCollide() ?
BlitzMax Forums/BlitzMax Beginners Area/Ni ImagesRectCollide() ?
| ||
In my puzzle game a tile is selected according to what image the arrow has collided with. The problem is the arrow collides with 2 tiles and causes an eroor. In blitz3d or BlitzPlus I would use ImagesRect Collide to test for the collision using a 1*1 pixel rect. Is there anything like this in blitzMax or is anything planned for it to be added. Also, Just in case its my code I'll post it here for you to see. The function Below changes the current tile. I've commented out the problem code. Function change_curtile() ' For Local t:tile = EachIn tilelist ' If ImagesCollide(curser2,mx2,my2,0,tiles,t.xpos,t.xpos,t.id) And MouseHit(KEY_MOUSELEFT) ' curtile = t.id ' EndIf ' Next If KeyHit(KEY_OPENBRACKET) curtile:-1 ElseIf KeyHit(KEY_CLOSEBRACKET) curtile:+1 EndIf If curtile > 20 Then curtile = 0 If curtile < 0 Then curtile = 20 End Function The Function below places all the tiles on screen and assigns a number to curtile. ex: t.id = curtiletype Function settileset() If ty < 640 tx = 896 ty = 128 curtiletype = 0 For Local x:Int = 0 To 7 Local t:tile = New tile t.xpos = tx t.ypos = ty t.id = curtiletype ListAddLast tilelist,(t) curtiletype:+1 ty:+64 Next EndIf If ty >= 640 tx = 192 ty = 673 curtiletype = 8 For Local x2:Int = 0 To 11 Local t:tile = New tile t.xpos = tx t.ypos = ty t.id = curtiletype ListAddLast tilelist,(t) curtiletype:+1 tx:+64 Next EndIf End Function Below is the code for the whole game: |
| ||
We meet again, Amon! You could do it by using the actual mouse co-ordinates to check for collisions. There would always only be one tile (or no tile) such that the following holds: (MouseX() - tileX >= 0 ) And (MouseY() - tileY >= 0 ) And (MouseX() - tileX < tileWidth) And (MouseY() - tileY < tileHeight) Hope this helps, Ryan |
| ||
Woah!. That actually worked and made sense and doesnt even use the collision commands. If I knew your address Ryan I would send you 4 cans of fosters and a packet of fags. ;) |
| ||
Haha, thanks, though I don't smoke and I rarely drink. You could send me a couple of packets of Digestives this way though! Ryan |