? Touch Screen Collision? (Page 1) ● SmileBASIC Source Forums

Sign In

Register
*Usernames are case-sensitive
Forgot my password

Touch Screen Collision?

  • #1 ✎ 226 ProKuku Avatar Taboo I didn't change my avatar for 180 days Website Final(?) Contest Runner Up I placed 2nd in the (possibly) final SmileBASIC Source Contest! October 2018 Programming Contest First Year My account is over 1 year old Website In my program I’m controlling a sprite using the touch screen, and I’m trying to implement collision with map tiles and that sprite. I use BGGET to tell when the sprite is actually colliding with the tiles, but I don’t know how I could make it so that the sprite doesn’t go through those tiles. When I say “implement collision” I mean the sprite bumping into a tile and stopping at a certain point instead of going through the tile. Posted
  • #2 ✎ 370 Chemicalex Drawing I like to draw! Hobbies RNG Hidden Easter Eggs Third Year My account is over 3 years old Website Touch screen collision is no different than top screen collision lol Posted
  • #3 ✎ 199 MZ952 Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Drawing I like to draw! Hobbies Reading I like to read books! Hobbies You may want to store the sprite coordinates when the program first detects a collision and not allow the sprite to move past those coordinates. Perhaps you could check the touch coordinates themselves. If the touch falls into a region of "on or inside something solid," then don't move the sprite there. If they're not inside something, then move the sprite to the touch coordinates. Posted
  • #4 ✎ 226 ProKuku Avatar Taboo I didn't change my avatar for 180 days Website Final(?) Contest Runner Up I placed 2nd in the (possibly) final SmileBASIC Source Contest! October 2018 Programming Contest First Year My account is over 1 year old Website
    Touch screen collision is no different than top screen collision lol
    It's a lot different when moving a sprite with the stylus instead of a predictable d-pad or circle pad.
    You may want to store the sprite coordinates when the program first detects a collision and not allow the sprite to move past those coordinates. Perhaps you could check the touch coordinates themselves. If the touch falls into a region of "on or inside something solid," then don't move the sprite there. If they're not inside something, then move the sprite to the touch coordinates.
    I did have a similar idea of saving the position of the sprite when it collided with a wall, and not letting it move past that point, but it got very buggy when I tried adding more than one side of collision detection. The second idea definitely wouldn't work, because I have a lot of tiles to collide with.
    Posted
  • #5 ✎ 199 MZ952 Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Drawing I like to draw! Hobbies Reading I like to read books! Hobbies @ProKuku Do these tiles fall into a fixed position grid (are they all aligned)? Do these tiles on the lower screen move or are they fixed? If the first is true, my second suggestion may be the best for either case, movement or not, really. There are ways of determining what tile a certain X-Y coordinate is on without having to run through every single tile. Posted Edited by MZ952
  • #6 ✎ 226 ProKuku Avatar Taboo I didn't change my avatar for 180 days Website Final(?) Contest Runner Up I placed 2nd in the (possibly) final SmileBASIC Source Contest! October 2018 Programming Contest First Year My account is over 1 year old Website These tiles are not parallel, if that’s what you mean. They also move down the screen, so I don’t know if your second suggestion would work. Posted