If you've seen some of my other posts, you may know that I'm working on a Tanks game. While working on the collision with the walls (which are made up of individual "blocks" that are clones of one sprite with dimensions of 30x30 pixels), I encountered a strange issue. While working with the collision of the player tank on the walls, I found that on the left and right walls, the tank would be prevented from moving any farther just fine, including when you attempt to approach diagonally. But, when the tank collides with the top and bottom walls, it works fine when approached head on, but if approached diagonally the tank will clip through the wall. I spent some time trying to figure out the issue, but nothing helped. Eventually, I minimized the stage so that I could see more of the scripting area and work more easily. I tried again in the minimized stage, and the issue had reversed. Now, the top and bottom walls were functioning just fine, but the left and right ones were clipping. Why??? I didn't change any of the script, yet for some reason the mere size of the stage itself changes the problem I'm having. Any ideas as to why this might be happening and if it's possible to fix it?
My initial thought was that maybe the quality of the sprites changing affected it, but I see no reason as to why it would.
TL;DR: For some reason, minimizing and maximizing the stage changes the way my sprites interact with one another.
Hmmmm interesting. How are the sprites (i.e. tanks and walls) interacting with each other? Are you using the sensing block or detecting collision based on x,y coordinates? Feel free to share a link to your project, and I can take a closer look.
collision detection in Snap is pixel-perfect, but depending on what you actually see, i.e. what is actually being displayed at which scale onstage. Making a target smaller often also reduces its rendered pixels which may affect its appearance onstage. Also, keep in mind that collision detection only looks at a certain moment in time when you actually ask for it. Usually in games you repeatedly check for collision detection, but in between checking you also move the sprites. Therefore you have to make sure that the steps of your sprites' movements are small enough so they don't accidentally skip over any target they're interested in colliding with. Does that make sense?
Here's my project. I made custom blocks for movement and collision so that it takes up less space in the scripting stage.
Snap! Build Your Own Blocks!
You can actually store the current position, then move, then test for collision between the previous position and the current position. If it detects a wall, it moves the sprite (or object) back to the place where it would've collided with the wall. This is what a lot of games do, especially (I'm guessing) sonic games.
The project does not exist.
Odd, the project is shared and works in my folder. I refigured it a bit, see if it works now.
Snap! Build Your Own Blocks!
Maybe it isn't shared.
It would work only for you because it is your project.
Odd, I get the same thing when I click the link. Let me save it as a different project and see if that works
I posted a new link that should work.
There's a new link I posted, try it out
Did you figure anything out?
Sadly no. I think something people should learn from me is that I'm not a very good coder. Or good at anything, unless you count "waking up at 6:00 AM in the morning even though I slept at like 11:00 PM last night", playing piano, and eating.
Heh, I go to sleep at 1 AM, and wake up at 7 AM, so I guess I'm worse than you.
Worse than I usually am, (I usually fall asleep anywhere from 10PM to 1AM and wake up anywhere from 10AM to 1PM) but not as bad as when I stay up until morning, upon which I'm so tired I have to struggle to stay awake while playing Plague Inc., except when the idle noises wake me up.
pretty sure less sleep is worse...