Page 2 of 2 FirstFirst 12
Results 21 to 27 of 27

Thread: Help with game

  1. #21
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,354
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by TGH View Post
    I actually gave my pacman already the coordinates where to start...

    Java Code:
    pacman = new Pacman(450, 100, 50, hap, doolhof)
    The reason I /50 is because the blocks are 50 big, each one, also the pacman self...
    That's a sensibe decision; in your 'isToegankelijk' method print the coordinates divided by 50 and print the value of the raster at those coordinates, i.e. raster[x/50][y/50] so you can see why a cell is considered accessible.

    kind regards,

    Jos

  2. #22
    TGH
    TGH is offline Member
    Join Date
    Nov 2009
    Posts
    32
    Rep Power
    0

    Default

    I get an unreachable code:

    Java Code:
    System.out.println(raster[x/50][y/50]);
    This is in the isToegankelijk method...

  3. #23
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,354
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by TGH View Post
    I get an unreachable code:

    Java Code:
    System.out.println(raster[x/50][y/50]);
    This is in the isToegankelijk method...
    You do have to supply more details than that, we are not psychic and the compiler doesn't lie: you probably have put that statement after a return statement so the code can never be executed; read what the compiler is whining about, it makes sense.

    kind regards,

    Jos

  4. #24
    TGH
    TGH is offline Member
    Join Date
    Nov 2009
    Posts
    32
    Rep Power
    0

    Default

    Alright, it's working,

    I get the whole time '0' in the console.
    That isn't good...

    EDIT:

    IF i go to the upper left corner (pixel 0) my program freezes, and I get an outofBoundsEcxeption. (:16)
    The 'killer' of my program is the isToegankelijk method...
    Last edited by TGH; 01-12-2010 at 11:20 AM.

  5. #25
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,354
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by TGH View Post
    Alright, it's working,

    I get the whole time '0' in the console.
    That isn't good...

    EDIT:

    IF i go to the upper left corner (pixel 0) my program freezes, and I get an outofBoundsEcxeption. (:16)
    The 'killer' of my program is the isToegankelijk method...
    Please do try to think a bit: your raster has 16 rows so a valid rowindex has the value 0, 1, 2 ... 15; the error message complains about a row index value of 16; does that ring a bell? Since you divide the x coordinate by 50 you have passed in a value of 800 ... 849

    kind regards,

    Jos

  6. #26
    TGH
    TGH is offline Member
    Join Date
    Nov 2009
    Posts
    32
    Rep Power
    0

    Default

    I did fixed the problem, but that doesn't solve the problem that my Pacman can still walk through wall's.:confused:
    I just made the frame a little bit smaller...

  7. #27
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,354
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by TGH View Post
    I did fixed the problem, but that doesn't solve the problem that my Pacman can still walk through wall's.:confused:
    I just made the frame a little bit smaller...
    Did you read my previous replies? (e.g.reply #19) if you print out the x and y coordinates as well as the value in the raster you can figure out why you seem to be able to walk through walls.

    kind regards,

    Jos

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 2
    Last Post: 08-05-2010, 04:49 AM
  2. Help! Game.
    By MIA6 in forum New To Java
    Replies: 4
    Last Post: 11-08-2009, 12:22 AM
  3. Help with my game!
    By Manikyr in forum New To Java
    Replies: 6
    Last Post: 06-06-2009, 11:09 AM
  4. 2D strategy game or 2D war game
    By led1433 in forum Java 2D
    Replies: 5
    Last Post: 02-10-2009, 06:00 AM
  5. game
    By amith in forum AWT / Swing
    Replies: 0
    Last Post: 05-19-2008, 05:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •