• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

my own classes, get var from other class

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!!!
 
reply
    Bookmark Topic Watch Topic
  • New Topic