Problems with the physics functions
Posted: Thu Jun 23, 2011 9:44 pm
Hello LÖVEers,
I'm new in development with this awesome engine, but I've already have a lot of experience in Lua. (I'm coding Lua for GMod for almost three years.)
Well.. until now I really had not any problems in what I was doing, but then I wanted to do something with the physic functions. It worked pretty good so far, but now I have some really big problems with the collision.
To cut a long story short: I wanted to spawn bouncy balls on left click (which worked so far) and boxes with collision (which doesn't work at all).
The bouncy balls bounce when they are told to do so (when they hit the window rim), but the boxes are just.. weird.
In the picture below, the black boxes are drawn at the position where the bodies associated with the rectangular shapes should be, and the balls stuck where the "boxes" actually are.
In the next picture you'll see red and black boxes. The red boxes should mark where the shapes actually are (using "love.graphics.polygon( "line", v.shape:getPoints()" ) ), and the black boxes should mark where the bodies are. Curiously the shapes and bodies should have exact the same position, but they're always drawn in two different vectors.
Also, the game crashes if I'm trying to spawn a ball in the upper rim of the window.
I attached the game so you can try it yourself and maybe see what I did wrong in the code. Hopefully you can help me as soon as possible.
Thanks in advance.
PS: I aligned the window size and everything related to it to a 800x600 resolution, so everyone can try it out.
I'm new in development with this awesome engine, but I've already have a lot of experience in Lua. (I'm coding Lua for GMod for almost three years.)
Well.. until now I really had not any problems in what I was doing, but then I wanted to do something with the physic functions. It worked pretty good so far, but now I have some really big problems with the collision.
To cut a long story short: I wanted to spawn bouncy balls on left click (which worked so far) and boxes with collision (which doesn't work at all).
The bouncy balls bounce when they are told to do so (when they hit the window rim), but the boxes are just.. weird.
In the picture below, the black boxes are drawn at the position where the bodies associated with the rectangular shapes should be, and the balls stuck where the "boxes" actually are.
In the next picture you'll see red and black boxes. The red boxes should mark where the shapes actually are (using "love.graphics.polygon( "line", v.shape:getPoints()" ) ), and the black boxes should mark where the bodies are. Curiously the shapes and bodies should have exact the same position, but they're always drawn in two different vectors.
Also, the game crashes if I'm trying to spawn a ball in the upper rim of the window.
I attached the game so you can try it yourself and maybe see what I did wrong in the code. Hopefully you can help me as soon as possible.
Thanks in advance.
PS: I aligned the window size and everything related to it to a 800x600 resolution, so everyone can try it out.