Object position when collision problem
by Aun Taraseina · in Torque Game Builder · 04/05/2006 (8:04 pm) · 9 replies
I am trying to make a bobble-puzzle game and the method I am using to calculate the bubble position
1. is when 2 bubbles have a collision and send a onCollision message
2. I get the moving bubble position and calculate the correct position for it
3. then i put the moving bubble in the correct position that i got from my calculations and stop it from moving
--> most of the time everything was fine but whenever I open a new programe on my computer or do
something else while running the game the calculation just went wrong the moving bubble is placed
somewhere before the collision position
--> so what I could think of is TGB checks it's collisions from the velocity of the object not from the
object position(which TGB is using to paint the object on the scene)
so here is my question
1. is there anyway i can check the image collision by using object position not its velocity ?
2. is there any functions to pause the game when the current game window has lost it's focus ?
Thank you in advance ,for any help.
Aun (p.s. my english sucks)
1. is when 2 bubbles have a collision and send a onCollision message
2. I get the moving bubble position and calculate the correct position for it
3. then i put the moving bubble in the correct position that i got from my calculations and stop it from moving
--> most of the time everything was fine but whenever I open a new programe on my computer or do
something else while running the game the calculation just went wrong the moving bubble is placed
somewhere before the collision position
--> so what I could think of is TGB checks it's collisions from the velocity of the object not from the
object position(which TGB is using to paint the object on the scene)
so here is my question
1. is there anyway i can check the image collision by using object position not its velocity ?
2. is there any functions to pause the game when the current game window has lost it's focus ?
Thank you in advance ,for any help.
Aun (p.s. my english sucks)
About the author
COO for Kiragames, developer of Unblock Me. With over 60 million downloads and named #17 most download Application of all time. My work is to extend our IP to higher ground and find ways we can work with other awesome companies.
Recent Threads
#2
i have notice the $timescale function from the forum search
but i still can't find a way to tell when the window has losen focus
04/05/2006 (8:30 pm)
Thanks @Chris for the quick reply i have notice the $timescale function from the forum search
but i still can't find a way to tell when the window has losen focus
#3
for someone who will cross the same problem as I will try to explain my solution to the problem i explain above
to get the window message when it has losen focus just look up at this thread
www.garagegames.com/mg/forums/result.thread.php?qt=33529
and for the collision problem,I am not sure if it is a bug or not but I been testing on 3 machine and they all have the same problem my co-workers think it is a bug too ,,, but now i haven't reported as a bug
---> the problem with collision I have is if I release an object with velocity and i rapidly make the window be active and inactive ---say by pressing on the game screen and then press on the desktop rapidly
the collision call back is called before it should be which I think if it is called faster more than 0.005sec then we will have some problem with our game so here how I got around the problem.
04/20/2006 (9:46 pm)
Ok...for someone who will cross the same problem as I will try to explain my solution to the problem i explain above
to get the window message when it has losen focus just look up at this thread
www.garagegames.com/mg/forums/result.thread.php?qt=33529
and for the collision problem,I am not sure if it is a bug or not but I been testing on 3 machine and they all have the same problem my co-workers think it is a bug too ,,, but now i haven't reported as a bug
---> the problem with collision I have is if I release an object with velocity and i rapidly make the window be active and inactive ---say by pressing on the game screen and then press on the desktop rapidly
the collision call back is called before it should be which I think if it is called faster more than 0.005sec then we will have some problem with our game so here how I got around the problem.
function t2dSceneObject::onCollision(%srcObj, %dstObj, %srcRef, %dstRef, %time,
%normal, %contactCount, %contacts)
{
switch$(%srcObj.tag)
{
case "objectMovable":
switch$(%dstObj.tag )
{
case "ObjectNonMovable":
if(%time < 0.005)
doSomeThingAfterCollision();
else{
%vecX = %srcObj.getPositionX() + %srcObj.getLinearVelocityX() * (%time - 0.005);
%vecY = %srcObj.getPositionY() + %srcObj.getLinearVelocityY() * (%time - 0.005);
%srcObj.setPosition(%vecX,%vecY);
doSomeThingAfterCollision();
}
}
}
}
#4
But I have a problem when the too ball collision.
the onCollision callBack will call when they are overlap rather then they are touch.
Do you have the same problem????
04/26/2006 (10:14 pm)
I am doing a game like bubble shooter too.But I have a problem when the too ball collision.
the onCollision callBack will call when they are overlap rather then they are touch.
Do you have the same problem????
#5
***i think to make the game fun you will be needing more than a square or circle collision poly
which i think u are using the default collision poly which is square
04/26/2006 (10:23 pm)
Change the collision poly***i think to make the game fun you will be needing more than a square or circle collision poly
which i think u are using the default collision poly which is square
#6
I use setdebugOn(1) to veiw the actual size of image.
And I saw that the two square overlap..............
It will overlap whatever ploy i set." square or circle or custom"
04/27/2006 (12:49 am)
I have set it .I use setdebugOn(1) to veiw the actual size of image.
And I saw that the two square overlap..............
It will overlap whatever ploy i set." square or circle or custom"
#7
maybe if you want it to just touch perfectly
try to slower down the velocity of the object
04/27/2006 (8:11 am)
Well I think that's correctmaybe if you want it to just touch perfectly
try to slower down the velocity of the object
#8
here's the concept in this type of game you can't expect that the player will fire the ball and the ball will perfectly stop and be in the position you want it to be
what you have to do is when the object collision call back is called, you have to put the object in the correct position you want it to be placed.
such as you might create a datagrid of where the object will be placed in your game and when one object collide you'll have to calculate where the object will have to be placed in the datagrid of your game.
hope you get the idea
Aun
05/10/2006 (9:37 pm)
Oh sorry i just came back and read what you are trying to say...here's the concept in this type of game you can't expect that the player will fire the ball and the ball will perfectly stop and be in the position you want it to be
what you have to do is when the object collision call back is called, you have to put the object in the correct position you want it to be placed.
such as you might create a datagrid of where the object will be placed in your game and when one object collide you'll have to calculate where the object will have to be placed in the datagrid of your game.
hope you get the idea
Aun
#9
It's a lot more complicated then that, but that's the right idea.
05/11/2006 (6:45 am)
That is what I did Aun... and the game is feature complete ;)It's a lot more complicated then that, but that's the right idea.
Torque Owner Chris Labombard
Premium Preferred
and this to resume play: