Wednesday 11 June 2014

Break out game in C++ using QT 5.2.1 - Stage 1 - Header files

In his stage we were required to implement a bouncing ball inside a box. ball needs to bounce of the box edges at constant speed. singleton design pattern used here. this is done in QT. we have header and implementation files for coordinate, ball, and dialog classes, in addition to main method.
here is the coordinate header file...coordinate.h...

ball.h
dialog.h

sample config file looks like this

now some explanation. coordinate class is for translating coordinate in Qt in a way that we are comfortable of. it means Qt consider top left corner (0,0), and while you're moving to right or down it increases the x and y coordinate. personally, I think we don't need this..well...here it is... ball class has some functions needs proper implementation beside normal getter/setter methods. render and isCollision functions. isCollision function checks if the ball hit any edges of the box, and render function handle the ball movements. dialog class is the core of this to put them all together. we used Singleton Design Pattern here to make sure only one instance of dialog exists at any time. I hope I explained it good enough, as I'm still learning. I'll post the implementation files and main method in near future, meanwhile stay hungry, keep coding

Some other information:

  • this is not my code. mine was similar but it didn't changed colour when ball hits the box
  • again this is implemented in Qt
  • the actual website that have the tutorial on basic set up to start on this assignment can be found Here

2 comments:

  1. Hi may I ask that you still keep OO quiz last year?

    Thanks

    ReplyDelete
  2. Hi, unfortunately not. we couldn't take the quiz paper out. quiz is easy, just normal stuff. you should be worried about assignments and final exam.and since the lecturer is changed this semester...last year lecturer was real good..., good luck

    ReplyDelete