May 3, 2012

Aubrey12 Aubrey12
Lab Rat
4 posts

Brick Breaker, Need help on moving the panel and the ball

 

Hi there

We’ve received an assignment to create a basic brick breaker game. I am very new to qt and I’m struggling on finding a way how to move the panel over the screen, as well as the bouncing and moving of the ball. The rest I am able to do.

Can anyone help me with this please?

2 replies

May 8, 2012

matti- matti-
Lab Rat
113 posts

Arcanoid clone? You’ll want to capture mouse events (or touch events) for moving the paddle and then you need to apply simple collision detection with the ball against the edges, paddle and the blocks. 2D vector math & reflection vector are your friends there.

 Signature 

Author of MMark13

June 20, 2012

AngelsRaven AngelsRaven
Lab Rat
13 posts

Assuming this is a 2D game, you should look into the Graphics View Framework [qt-project.org]

When you use the QGraphicsItem as base class for your viewable items, you get the collision detection algorithm for free. Allthough not the top of the edge, it will satisfy your needs.

You should check the Colliding Mice example [qt-project.org]

It will show you how to move items etc, also look at Asteroids.

The logic behind the original arcanoid, was very simple towards ball movement. It will change the velocity of the ball depending on the collision location (left, middle, right).

I think you have enough to look at, so get started.

 
  ‹‹ unessesary repaint how to avoid      Generating 9x9 tiles/blocks with random images and create a board ››

You must log in to post a reply. Not a member yet? Register here!