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

Sign In

Register
*Usernames are case-sensitive
Forgot my password

Touch Screen Collision?

  • #1 ✎ 292 ProKuku QSP Contest 1 Contest Participant I participated in the first SmileBASIC Source QSP Contest! Night Person I like the quiet night and sleep late. Express Yourself Pokemon Is Awesome! I love Pokemon! Express Yourself 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 ✎ 376 Chemicalex Drawing I like to draw! Hobbies Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength osu! Is Awesome! I love osu! Express Yourself Touch screen collision is no different than top screen collision lol Posted
  • #3 ✎ 274 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 ✎ 292 ProKuku QSP Contest 1 Contest Participant I participated in the first SmileBASIC Source QSP Contest! Night Person I like the quiet night and sleep late. Express Yourself Pokemon Is Awesome! I love Pokemon! Express Yourself
    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 ✎ 274 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 ✎ 292 ProKuku QSP Contest 1 Contest Participant I participated in the first SmileBASIC Source QSP Contest! Night Person I like the quiet night and sleep late. Express Yourself Pokemon Is Awesome! I love Pokemon! Express Yourself 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