Computer Science Canada Collision Problem |
Author: | Panphobia [ Sun Jan 20, 2013 3:08 am ] | ||
Post subject: | Collision Problem | ||
Ok so as some of you might know for my project management summative for ICS 4U I am doing a rush hour game, basically in the original you slide cars either vertically or horizontally to clear the path such that your car can make it to the goal, we are done everything, but there are a few bugs, I fixed most of them but one remains a mystery, whenever I try to force one tree/car into another if i do it 2-3 times they will overlap, here is an example ![]()
|
Author: | Panphobia [ Sun Jan 20, 2013 3:16 pm ] | ||
Post subject: | Re: Collision Problem | ||
Well I do not know the problem because what it does if the current car/tree you are dragging is intersecting with another car/tree and then if it is it will make the tree that you are dragging go back to the original place it was at, here is the code for that, what i Think the problem is, is that the carImage x and y keep changing on how much you move it, and if you move slightly into another tree that is the new x and y, and it pushes it back there, so what I don't know is how to make it change the x and y if the move is valid
|
Author: | Panphobia [ Sun Jan 20, 2013 5:09 pm ] |
Post subject: | RE:Collision Problem |
Problem solved!!! The problem was that I was basing the co-ordinates of the tree from the middle of the tree, and it would jump according to where you pressed it from, so i just changed this fact, and its fixed |
Author: | Panphobia [ Sun Jan 20, 2013 9:44 pm ] |
Post subject: | RE:Collision Problem |
Ok so I fixed every single glitch, it does not glitch with the mouseX and y anymore, now it glitches if you drag a tree really fast into another one, they will overlap, is there anyway to slow down the cursor? i heard you can do it in c or c++, and if you can, is there a way to run c or c++ code with java? |
Author: | DemonWasp [ Sun Jan 20, 2013 10:47 pm ] |
Post subject: | RE:Collision Problem |
No, you can't really slow down the cursor. I'm not even sure you can do that in C++ (you shouldn't be able to, though the mouse operates a bit differently in Direct3D or OpenGL contexts than usual, so maybe). You can technically call C/C++ code from Java, but it's a bit of a mess and not ideal. Maybe you should just make your dragging code work properly in the first place. |
Author: | Panphobia [ Sun Jan 20, 2013 11:06 pm ] |
Post subject: | RE:Collision Problem |
It drags properly, and collides properly, only when you click and drag really fast does it overlap, i do not know why, but it does, strange... |