
-----------------------------------
upthescale
Wed Jun 07, 2006 4:06 pm

Bricks
-----------------------------------
Im making a paddle (Brick ) game, and i hav a problem. I am using an array for my bircks,

but i want them not to go at random so i do this:
[code
    for i : 1 .. 6
        Draw.Box (Brick (i).Brickx - 30 + i * 61, Brick (i).Bricky + 20, Brick (i).Brickx + 30 + i * 60, Brick (i).Bricky, 2)

  end for
[/code]

when the ball hits them it bounces the right weay, my problem is when it hits it, i want only one of the block to disapear (Brick(i).Bricky:=1000, jsut to get otu of the screen) but the problem is that the whole row will go or even all 3 rows. thanks

-----------------------------------
upthescale
Wed Jun 07, 2006 4:17 pm


-----------------------------------
Sorry i am using whatdtcolor, that is why they all move!

-----------------------------------
Clayton
Wed Jun 07, 2006 4:25 pm


-----------------------------------
i am assuming that you are using records, so just have a flag for each block and when that block is hit change it to false, refresh the blocks with their flag set to true and voila !

-----------------------------------
upthescale
Wed Jun 07, 2006 4:40 pm


-----------------------------------
flag? wut u meen?

-----------------------------------
Delos
Wed Jun 07, 2006 4:47 pm


-----------------------------------
Add another field to your record to determine whether or not to draw the object.  For instance:

type brick :
  record
    xPos, yPos : int
    xSize, ySize : int
    visible : boolean
  end record


The last field will allow you to determine whether or not to draw the object - and may also be incorporated in your collision detection.  Alternately you could use:


type brick :
  record
    xPos, yPos : int
    xSize, ySize : int
    drawState : int
  end record


By having the flag more than a binary variable, you can have various states - for instance, 0 == invisible, 1 == visible, 2 == visible and unbreakable, etc.

Now, upthescale, I must ask.  Is  your keyboard broken?  No, really, does it have missing letters or something else otherworldly?  The extent to which your posts are obfuscated is quite irritating.  Perhaps use the 'Preview' button a little more frequently eh?

-----------------------------------
_justin_
Thu Jun 08, 2006 7:02 am


-----------------------------------
what you can do is have a boolean var 

var showing : array 1 .. 3, 1 .. 10 of boolean 

what the 1..3 does is says their will be 3 rows of bricks and then the 1..10 mean that their will be ten bricks across

then i drew all the bricks in a for loop 
for row : 1 .. 3                                                                                      
    boxY := maxy - 20 * row - 10                                                                      
    for i : 1 .. 10                                                                                   
        ColorB (row, i) := Rand.Int (1, 10)                                                           
        showing (row, i) := true                                                                      
        Draw.FillBox (307 + (i - 1) * 70, boxY, 362 + (i - 1) * 70, boxY + 15, ColorB (row, i))        
    end for                                                                                          
end for

and then i used this for my collision dection

for i : 1 .. 10                                                                                         
    if 307 + (i - 1) * 70 