Results 1 to 3 of 3
  1. #1
    Java26 is offline Member
    Join Date
    Dec 2010
    Posts
    11
    Rep Power
    0

    Exclamation have searched everywhere with no luck...

    I have searched for hours online and cannot find an answer to, what i hope, is a simple question. I have taken on Java programming as a hobby and am hoping to complete a simple 2d pacman game for a friend in the next few weeks. I have got the program going well until i hit a road block... I am trying to use a 2d array to use as a guide for my map. In other words, to make a grid so i can decide where to program the "walls", "dots", etc. I cannot find anywhere that talks about how to implement an array like this. I will be more than happy to share my code thus far and am open to any and all help! thanks.

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    You mean just declare a 2 d array? What do you plan on storing the array?

    Creating a 2d array is as simple as
    Java Code:
    Type[][] arrayName = new Type[size][size];
    You should be able to fill the array with flags letting you know which side the wall should be on, or perhaps even images.

  3. #3
    Java26 is offline Member
    Join Date
    Dec 2010
    Posts
    11
    Rep Power
    0

    Default

    I understand how to declare it. What i dont understand is how many rows or colums i should have, or how i can use those points as a "matrix" to build the game. In other words how can i use the coordinates as references to place dots or walls?

Similar Threads

  1. Number of searched term in Documents
    By MrUni in forum Lucene
    Replies: 0
    Last Post: 12-14-2010, 03:00 PM
  2. [SOLVED] Array troubles, yes I searched...
    By Reiyn in forum New To Java
    Replies: 11
    Last Post: 04-16-2009, 11:28 PM

Tags for this Thread

Posting Permissions

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