Computer Science Canada quicker way to make bricks for brick breaker... |
Author: | Velocity [ Mon Dec 12, 2011 10:10 pm ] |
Post subject: | quicker way to make bricks for brick breaker... |
so anyways this whole time i was working on a brick breaker game vs AI, well now i need to make the actual bricks, how would i go about donig this? I dont want to actually drawfillbox for all of them, is there a quicker way? Please help me, i want to know how i would go about doing this! |
Author: | Insectoid [ Mon Dec 12, 2011 10:34 pm ] |
Post subject: | RE:quicker way to make bricks for brick breaker... |
Arrays and for loops. |
Author: | RandomLetters [ Mon Dec 12, 2011 11:04 pm ] |
Post subject: | RE:quicker way to make bricks for brick breaker... |
A 2D array of integers representing a grid of bricks also lets you "draw" levels. You will need to use some math to convert the row column coordinates in the array into x y coordinates on the screen |
Author: | Aange10 [ Tue Dec 13, 2011 12:48 pm ] |
Post subject: | RE:quicker way to make bricks for brick breaker... |
If you look at the Turing submissions under the brick breaker I posted about a week ago, you could see how to do them like RandomLetters said; to use a 2d array as a grid. |
Author: | programmer1337 [ Tue Dec 13, 2011 3:23 pm ] |
Post subject: | RE:quicker way to make bricks for brick breaker... |
Insectoid would be the best suggestion ![]() |
Author: | Velocity [ Wed Dec 14, 2011 8:47 pm ] |
Post subject: | RE:quicker way to make bricks for brick breaker... |
i love all your posts but i just chose to draw them, because i dont want to confuse my meeble mind. |
Author: | Linkxgl [ Wed Dec 14, 2011 10:47 pm ] | ||||||||||||
Post subject: | Re: RE:quicker way to make bricks for brick breaker... | ||||||||||||
Velocity @ Wed Dec 14, 2011 8:47 pm wrote: i love all your posts but i just chose to draw them, because i dont want to confuse my meeble mind.
Not really the best way to go about it... What if you want to change the size of the bricks, or colours? It also gets confusing looking at that all the time... Here, I made a simple script you can understand...
The code basically demonstrates how useful it actually is... What if you want to try 200 bricks? It's going to take a while to do that! The script took me 10 min to make, it's super simple and I took some extra time to add notes to almost every line! Oh, and you can change any lower attribute like the in the for loop I do:
You can change it to
It's just that I get confused now when I start with 1 because I'm so used to starting with 0... I feel more comferatable like that... If you do change it though change this line:
to
That's it! Basically, to use the procedure all you do is the following... 1) 1st and 2nd parameters: Length and Width of the brick in integers 2) 3rd parameter: Colour of the brick in Turing numbers... 3) 4th and 5th parameter: How far you want the bricks to go to the right of the screen, and how far you want the bricks to go to the bottom of the screen 4) 6th and 7th parameter: The space between the bricks on the x-axis, and the space in between the bricks on the y-axis... Hopefully you will learn something from this, but if not, I was entertained for a good 10 minutes haha EDIT Here's a shorter version of the code... I just took out all the comments and the unneeded variables in the procedure, I don't re-defined the variables so it would be easier to understand. Again, there may be better ways to do it, but this is probably the best way you get can understand!
|
Author: | Velocity [ Mon Dec 19, 2011 5:46 pm ] |
Post subject: | RE:quicker way to make bricks for brick breaker... |
wow link thank you so much for that! i was going to give bits on sight, tysm! RE: And Karma, thanks. |