andzero
8th October 2011, 18:20
Hello! I'm glad i found this forum.
I just started learning Qt a few days ago, and currently i am trying to make a simple game.
I have read the docs, but maybe i am a bit slow in understanding things :( so i had to ask a few "newb" questions..
( I already run a forum search and checked through all of them that may seem related. )
So I wanted to make a side-scrolling, with rectangles for the road and the character running on top of them. I made 2 classes, lets say:
class Block: public QGraphicsItem
{
...
}
class Character: public QGraphicsItem
{
...
}
if the Character instance is not standing on top of a Block instance, then it would freefall down.
My question is, how and where do I define the collision? I've read about
virtual bool collidesWithItem ( const QGraphicsItem * other, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape ) const
I was thinking about implementing this in Character class as method but it needs QGraphicsItem *other as parameter.. :S
Thank you for your help! :)
I just started learning Qt a few days ago, and currently i am trying to make a simple game.
I have read the docs, but maybe i am a bit slow in understanding things :( so i had to ask a few "newb" questions..
( I already run a forum search and checked through all of them that may seem related. )
So I wanted to make a side-scrolling, with rectangles for the road and the character running on top of them. I made 2 classes, lets say:
class Block: public QGraphicsItem
{
...
}
class Character: public QGraphicsItem
{
...
}
if the Character instance is not standing on top of a Block instance, then it would freefall down.
My question is, how and where do I define the collision? I've read about
virtual bool collidesWithItem ( const QGraphicsItem * other, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape ) const
I was thinking about implementing this in Character class as method but it needs QGraphicsItem *other as parameter.. :S
Thank you for your help! :)