Forums Register Login

my own classes, get var from other class

+Pie Number of slices to send: Send
Hey everyone,

this is my first post, as a background, im learning java with Stanford programming methodology (about 1/2 way through)

Okay so im making this Breakout game (ball bounce on paddle, ball kill bricks)
I'm trying to wrap my head around making my own classes.
so i decided I want to split this class into many (just to learn and get familiar with creating my own classes.)
My main program is the breakout class
i want to have the createBrickWall class, a detectCollision class etc...


So i created the createBrickWall class to test this out.
(I removed the constants variable for clarity)


Problem is, I couldn't figure out how to do this outside of making a GCompound.

in my main class, i used to have a private GRect brick object to keep track of the bricks to break.
Here's the simplified collision code:

The problem with this, is that now as soon as the ball hit any of the brick, the whole GCompound (the whole wall) disappear.

I though that if I could somehow have access to the
Public GRect brick
That is in the brickwall class, then I could do something like

But I don't know how to do it.
So even if a declare the
public GRect brick
in the brickwall class, the breakout class doesn't seem to have access to it.

And even if it worked, i don't really understand how to get every objects created in the brickwall class to be tracked in the main breakout class...

Help?


Tank you!!!
How do they get the deer to cross at the signs? Or to read this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 872 times.
Similar Threads
trouble with mouseEvents
The pyramid attacks!
For Loops making me loopy
BreakOut Java Bug
Java Intersects
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 05:30:11.