Search:

Type: Posts; User: aussiemcgr

Search: Search took 0.23 seconds.

  1. Replies
    15
    Views
    1,290

    [SOLVED] Re: Back again with problems in my Snake Game

    Oh, wow, Greg is right. I overlooked that. Instead of the classes inheriting from JComponent, they should probably be inheriting from Rectangle or some other drawable object, since you are trying to...
  2. Replies
    15
    Views
    1,290

    [SOLVED] Re: Back again with problems in my Snake Game

    Debuggers let you "step through the code", one statement at a time. It can be tedious, since it will take you through a bunch of silly java classes you don't care about, but that's the cost you pay...
  3. Replies
    15
    Views
    1,290

    [SOLVED] Re: Back again with problems in my Snake Game

    No, it should be getting called in your constructor where you have the call to: repaint()

    There must be something we are overlooking.
    Ok, so we know:
    1. You are creating a new SnakeFood object,...
  4. Replies
    15
    Views
    1,290

    [SOLVED] Re: Back again with problems in my Snake Game

    Ok. So, your SnakeFood rectangle printout cannot possibly be correct. Look at your width and height variables in the snakeFood class. They are set to 10, yet the printout says 14. Are you 100% sure...
  5. Replies
    15
    Views
    1,290

    [SOLVED] Re: Back again with problems in my Snake Game

    Well the super call for that method is kinda important. You should always do the super.paintComponent(g) when you override the paintComponent() method. Have a look at: A Closer Look at the Paint...
  6. Replies
    15
    Views
    1,290

    [SOLVED] Re: Back again with problems in my Snake Game

    Um, shouldn't this result in infinite recursion?

    public void paintComponent(Graphics g)
    {
    Graphics2D g2 = (Graphics2D) g;
    g2.draw(food);
    g2.setColor(Color.BLUE);
    ...
Results 1 to 6 of 6