Search:

Type: Posts; User: Norm

Search: Search took 0.09 seconds.

  1. Replies
    33
    Views
    3,652

    Re: How to remove a brick (Java)

    You need to learn how to define a class and use it. That will make it easier to have more than one brick and to have the bricks be at unique locations.
    Classes (The Java™ Tutorials > Learning the...
  2. Replies
    33
    Views
    3,652

    Re: How to remove a brick (Java)

    Where is the class definition for the brick?
  3. Replies
    33
    Views
    3,652

    Re: How to remove a brick (Java)

    Can you post the code you have now?
    The normal way is to make a class that represents the brick. The class contains all the info about the brick and has methods for accessing and changing that info.
  4. Replies
    33
    Views
    3,652

    Re: How to remove a brick (Java)

    What happens when the if is executed and beenHit is false?
    What happens when the if is executed and beenHit is true?

    Setting beenHit true when it's true seems redundant.
  5. Replies
    33
    Views
    3,652

    Re: How to remove a brick (Java)

    What do you mean by "link a boolean and method together"?
    boolean is a data type. You can define variables of type boolean.
    A boolean variable can be used as the condition of an if statement....
  6. Replies
    33
    Views
    3,652

    Re: How to remove a brick (Java)

    Yes, all methods and constructors are defined at the class level.
  7. Replies
    33
    Views
    3,652

    Re: How to remove a brick (Java)

    No. Those two variables only exist when the methods are executed. You need to define a variable at the class level. For example the variable: paper is at the class level.

    You also need to remove...
  8. Replies
    33
    Views
    3,652

    Re: How to remove a brick (Java)

    You need to consider how local variables (defined in a method) and variables defined at the class level remember their values. Local variables only hold values when the method is executing. When...
  9. Replies
    33
    Views
    3,652

    Re: How to remove a brick (Java)

    Where are the variables defined that hold the state of a brick? For example its x,y location?
    Add another boolean variable to the group of variables: beenHit and set it initially false.
    When a...
  10. Replies
    33
    Views
    3,652

    Re: How to remove a brick (Java)

    One problem I see in the code is too many hardcoded values. Most of the numbers should be in variables that describe their usage which will make the program more maintainable and easier to read and...
  11. Replies
    33
    Views
    3,652

    Re: How to remove a brick (Java)

    Can you explain what happens when you execute the program and what the problem is?
    When I execute it,I get a fast moving round white shape and a rectangle. Changing how the round shape moves using...
  12. Replies
    33
    Views
    3,652

    Re: How to remove a brick (Java)

    In the object for a brick add a boolean: beenHit that is initially false. Set it true when the brick is hit.
    Use its value to control when to add: add if false, do not add if true.
  13. Replies
    33
    Views
    3,652

    Re: How to remove a brick (Java)

    An idea: Have a flag for the brick that records if it has been been hit. If the flag is set, don't add.
Results 1 to 13 of 13