+Karl G Posted February 26, 2020 Share Posted February 26, 2020 Are there any sample programs using boxcollision? I'm not having luck with it despite the fact that I think I have the parameters right, and I'm not dealing with anything offscreen. Edit: Nevermind; found in samples. I was spelling collision wrong in my search. ? 1 Quote Link to comment Share on other sites More sharing options...
+Karl G Posted February 26, 2020 Author Share Posted February 26, 2020 if boxcollision(TaxiX, TaxiY, 8, 5, 0, 64, 72, 1) then gosub StartCrash Here's my boxcollision line. I am checking if my taxi sprite with a width of 8 and height of 5 collides with a strip of the background starting at x=0 and y=64 which is 72 in width and 1 pixel tall. I guess I was assuming here that I could use boxcollision to detect collisions with the background, and not just with other actual sprites. Is this the case, or do I need to write my own function for these kinds of collisions? Quote Link to comment Share on other sites More sharing options...
RevEng Posted February 26, 2020 Share Posted February 26, 2020 You could use box collision with anything, but checking if two boxes overlap is a bit expensive on the 6502. If you do a few of them it's not too bad, but it quickly adds up. For anything tile-based, it's more efficient to check points on the sprite to see if they've moved over top of a particular tile index (or range of tile indexes). If you organize your tiles, you can easily have a set on non-harmful tiles, harmful tiles, goal or trigger tiles, etc. Quote Link to comment Share on other sites More sharing options...
RevEng Posted February 26, 2020 Share Posted February 26, 2020 Ok, let me walk one point back a little bit. Collision with very large widths will cause byte overflows, which will mess up the collision. Mostly unrelated to the above, I also see a bug when the first object x coordinate is less than it's width, if you're not using collisionwrap. For the next release I believe I'm going to make collisionwrap on by default. In the meantime I'd recommend using collisionwrap in your code. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.