Recently I started to learn Qt' graphics view and I decided to put my learning in to some action and as output I created this game called crazy chickens. Its classic egg catcher game.
Goal of game is to catch eggs before they touch the ground. You get four chances if you let egg fall on ground. Speed of game increase as you catch more eggs. To make Motu(the fat boy) catch egg in to basket you need to touch hen which produced the egg. Game dose not take gravity into account so speed of egg remain constant till it fall to ground.
I already uploaded this game to maemo's extra-devel repository, so if you want to try the game enable extra-devel repository. I am also planning to promote this game to extra-testing repository soon so this game should be available in extra-testing repository as well.
Some snaps of this game from my N900.
Sharing information related to Qt, Maemo development and some other information
Showing posts with label QGraphicsView. Show all posts
Showing posts with label QGraphicsView. Show all posts
Tuesday, August 24, 2010
Friday, July 23, 2010
Rotation and mirroring QGraphicsItem in Qt
Recently I started to learn Qt Graphics View to convert one of my existing game to use Qt graphics view framework.
During this I learned some new things that I would like to share here.
Rotating QGraphicsItem,
Generally when you rotate QGraphicsItem, it will rotate in reference to item's origin (0,0). To apply rotation in reference to center of item use following line of code.
graphicsItem->setTransform(QTransform().translate(centerX, centerY).rotate(angle).translate(-centerX, -centerY));
Mirroring or flipping QGraphicsItem,
To mirror item, you can use scale operation on QGraphicsItem. To flip item on y axis you following code,
graphicsItem->scale(-1,1)
here 1 scale factor will keep size to its original size and negative value will flip item on axis. Similarly to flip item on x axis use following code.
graphicsItem->scale(1,-1)
During this I learned some new things that I would like to share here.
Rotating QGraphicsItem,
Generally when you rotate QGraphicsItem, it will rotate in reference to item's origin (0,0). To apply rotation in reference to center of item use following line of code.
graphicsItem->setTransform(QTransform().translate(centerX, centerY).rotate(angle).translate(-centerX, -centerY));
Mirroring or flipping QGraphicsItem,
To mirror item, you can use scale operation on QGraphicsItem. To flip item on y axis you following code,
graphicsItem->scale(-1,1)
here 1 scale factor will keep size to its original size and negative value will flip item on axis. Similarly to flip item on x axis use following code.
graphicsItem->scale(1,-1)
Subscribe to:
Posts (Atom)