# Quick i need help with putting objects in ARRAYS

I am making an arkanoid games

I am putting the blocks in arrays

I can't get the code just to effect one block

Then when I finally get a block to .visible = false so it goes away

It acts like my object is still there

• : I am making an arkanoid games
:
: I am putting the blocks in arrays
:
: I can't get the code just to effect one block
:
: Then when I finally get a block to .visible = false so it goes away
:
: It acts like my object is still there
:

You'll have to be much more specific about your problem and/or post the code you're having trouble with before anyone will be able to help you.

• I don't have the code here but this is what i remember

This is just for 4 blox and a top hit of the ball to the buttom of the blocks

when it hits I want the current block to go away (visible = false)

It is currently treating all objects in the array as one in a box shape extending as far as the objects go

This makes inpossible to design a level because it treats all the objects as one in the array if a array doesn't have a block in it and it is in the box it still bounces off

dim I as integer
'directions U = up R = rite D = down L = left
dim UR as boolean
dim ul as boolean
dim dr as boolean
dim dl as boolean

I = 0

Private sub(Timer)
'changes the value of i constantly so it will switch from each block (I'd rather have a full range for I but I can't figure it out)
If I <> 3 then
I +=1
else
I=0
end if
Blox()
'for simplicity the rest of the ball movement code is like this one below so i won't repeat
if Ur = true then
ball.left +=1
ball.top -=1
end sub

Private sub Blox()
Dim Blox(3) as object
Blox(0) = block1
Blox(1) = block2
Blox(2) = block3
Blox(3) = block4
if pnlball.top <= blox(I).top + blox(I).height then
if UR = true then
DR = true
UR = false
end if
if UL = true then
DL = true
UL = false
end if
Blox(i).visible = false

'the visible doesn't work so im going to just have it change to the active background color and if it senses it to be that color skip the object........ sigh

end sub

• I noticed that u didn't see my reply to ur first post regarding this arkanoid game (Or ignored it?)... here is the URL: http://www.programmersheaven.com/c/MsgBoard/read.asp?Board=39&MsgID=259192

Read on, referencing to my other reply - all this code works together

In the place where I added the "CheckHit" code, just add block(i,j).visible = false.

You don't need to use buttons as block (I'm guessing that you did form "Blox(0) = block1", block1 is a button). This is what you should do:

on the onpaint of your playing area (form or whatever), after the mybase.paint (It says something like that), add a for loop like this:
[Code]
'Since we only really want to redraw the bricks when one was hit, but want to draw the ball every timer_tick,
'we will use a boolean to tell us if a brick has been hit.
dim i, j as integer
'Draw the bricks
If BrickHit Then
for i = 0 to 4 'Or however many blocks you have
for j = 0 to 4 'Same as above
Dim pen As New Drawing.Pen(Drawing.Color.Black)
if TheBlocks(i,j).visible = true then _
'I wrote this in short hand - append TheBlocks(i,j) before each "." like I did for ".x"
e.Graphics.DrawRectangle(pen,TheBlocks(i,j).x,.y,.width,.hieght)
Next j
Next i
BrickHit = False
End If
'Now draw the ball
'This time, append ball
e.Graphics.DrawEllipse(pen, ball.x,.y,.width,.hieght)
[/Code]

Make sure to make BrickHit = true when a brick gets hit and then write form.refresh to redraw (And call up your drawing routine). There is only one thing I didn't add, I didn't make it clean up before drawing. Just draw a rectangle over the cleared brick, and a elipse over the cleared ball.

All that is left for you to is is to initiate the loacation and sizes of the bricks.

What else do you need to know?

Relman

: I don't have the code here but this is what i remember
:
: This is just for 4 blox and a top hit of the ball to the buttom of the blocks
:
: when it hits I want the current block to go away (visible = false)
:
: It is currently treating all objects in the array as one in a box shape extending as far as the objects go
:
: This makes inpossible to design a level because it treats all the objects as one in the array if a array doesn't have a block in it and it is in the box it still bounces off
:
: dim I as integer
: 'directions U = up R = rite D = down L = left
: dim UR as boolean
: dim ul as boolean
: dim dr as boolean
: dim dl as boolean
:
: I = 0
:
: Private sub(Timer)
: 'changes the value of i constantly so it will switch from each block (I'd rather have a full range for I but I can't figure it out)
: If I <> 3 then
: I +=1
: else
: I=0
: end if
: Blox()
: 'for simplicity the rest of the ball movement code is like this one below so i won't repeat
: if Ur = true then
: ball.left +=1
: ball.top -=1
: end sub
:
: Private sub Blox()
: Dim Blox(3) as object
: Blox(0) = block1
: Blox(1) = block2
: Blox(2) = block3
: Blox(3) = block4
: if pnlball.top <= blox(I).top + blox(I).height then
: if UR = true then
: DR = true
: UR = false
: end if
: if UL = true then
: DL = true
: UL = false
: end if
: Blox(i).visible = false
:
: 'the visible doesn't work so im going to just have it change to the active background color and if it senses it to be that color skip the object........ sigh
:
: end sub
:
: