Hi.
I'm writing a game, and now is the time for discovering when armies bumps into each other.
So with a lot of Army objects (subclass of QGraphicsItems) moving around, I thought about doing like this (psudocodish)
void Army::move()
{
while ( movement path not empty)
{
setPos( next position in path);
list = collidingItems();
foreach (item,list)
{
if (item == enemy) do stuff etc.
else if ....
}
}
}
void Army::move()
{
while ( movement path not empty)
{
setPos( next position in path);
list = collidingItems();
foreach (item,list)
{
if (item == enemy) do stuff etc.
else if ....
}
}
}
To copy to clipboard, switch view to plain text mode
Any other way of doing this that I haven't thought about?
I should add that there will always be atleast one item that I collide with, and that is the background map that is inserted as an QGraphicsPixmap, and that might slow things down? What do you think?
Is there any betterway of putting a pixmap as background in a scene?
Bookmarks