Computer Science Canada Breakout-styled game problems |
Author: | ziddy [ Wed Jun 01, 2005 8:29 am ] | ||
Post subject: | Breakout-styled game problems | ||
So I decided to make a Breakout style game and I got most of the things going until this happened: [EDIT] Here's the original code
That was the code I placed in the program to cover the and existing black rectangle with a white rectangle so the next the ball passes on the space where the rectangle was, it would pass through instead of just bouncing on the rectangle again. Advanced thank yous for any help I get ._. |
Author: | Delos [ Wed Jun 01, 2005 1:01 pm ] |
Post subject: | |
Let me see if I understand you: - You draw a black box that acts as your 'bumper' - Keyboard input (or something else) moves this bumper - To clear the previously drawn bumper, you draw a white box over it If this is the case, as I think it is, there's an easier way: - do this in a loop, your 'main' loop that controls everything - draw your box - do other necassary stuff like checking for collision, input etc - Update the Screen - pause (delay) for a bit - clear the screen This requries you to use setscreen("offscreenonly") and View.Update. It's a lot easier than dynamically locating and clearing only portions of the screen. However, that being said, if you really want to clear only portions, you can use View.UpdateArea() but please be aware that if you have other objects on the screen (the bricks to be brocken for example), you'll have to set up sepearte Updates for them as well! |
Author: | ziddy [ Wed Jun 01, 2005 1:38 pm ] |
Post subject: | |
Sorry, I'll update my post with the whole program's code in it, instead of just the part I was having trouble with. And I'm sorry for not making myself clear enough :S Okay, here's the deal. The black box is actually the brick in which the ball has to hit to score and move onto the next level. The bumper is a blue box(please check updated code). And yeah I have done most of the things you have said, the only other thing that confuses me is where exactly should I put my View.Updates? I got help with the ones in my code from a friend and neglected to ask him where I should put my next View.Updates |
Author: | Neo [ Wed Jun 01, 2005 2:12 pm ] |
Post subject: | |
For this type of program you really only need 1 view.update, 1 delay and one cls. These usually go at the end of the program because you only need to update the screen after you have drawn everything, clear it, then redraw it again, clear it again and so on... |