Game field


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Game field

  1. #1
    Join Date
    Mar 2006
    Posts
    2

    Question Game field

    Hey!

    I'm trying to make a game but it's not really working

    If I have a field in a 2x2 matrix, let's say:
    Code:
    XXXXXXXXXX
    X              X
    X              X
    X              X
    X              X
    X              X
    X              X
    X              X
    X              X
    XXXXXXXXXX
    I want to randomly add a serie of X-characters (they are walls in the game). So I can create new "maps" at random. SO for instance I could get something like:
    Code:
    XXXXXXXXXX
    X     X       X
    X       X     X
    X         X   X
    X       X   X X
    X     X        X
    X    X         X
    X   X          X
    X  X           X
    XXXXXXXXXX
    The difficult part is that there shouldn't be any 'double walls' for instance
    Code:
    XXX
    XXX
    XXX
    the X in the middle would be doubled (there are other doubled positions too).

    I can't seem to figure out an algorythm to check wheter or not a wall is 'doubled'. Any help?

  2. #2
    Join Date
    Feb 2006
    Location
    Cologne - Germany
    Posts
    271
    did i get it right, that a wall is "doubled", when all neighbours are walls too?
    if so, then that's your algorithm. before setting a wall, check if all surrounding fields have walls too. if so, you don't need to set a wall.
    otherwise show me some more examples of what a doubled wall is.

  3. #3
    Join Date
    Mar 2006
    Posts
    2
    No, there are other possibilities too, for instance:

    Code:
    1. XXXXXXXXXX
    2. X              X
    3. XX            X
    4. X XX         X
    5. X   X         X 
    6. XXXXXXXXXX
    The last X on line 4 that is part of the wall is a "doubled" one here too...

    Let me refine the definition of doubled. A player can only move up/down and left/right in the world (not diagonally), so here that "doubled" wall is just unnessecary ...
    Last edited by julie_tatoue; 03-28-2006 at 10:48 AM.

  4. #4
    Join Date
    Feb 2006
    Location
    Cologne - Germany
    Posts
    271
    so there are the following possibilities:

    XX
    X
    and
    XX
    X
    and all rotations of that as well as full filled blocks like
    XX
    XX

    it seems to me, that a wall is doubled, if it has a wall at the left/right and a wall at top/bottom.
    assuming that you test this on the following block by starting at the field left top, the first wall to be identified as doubled would be 1/1.
    1:XX
    2:XX
    after removing that wall you would have the following block:
    1: X
    2:XX
    the wall at x=2/y=1 has only one neighbour, at bottom, so it's not doubled.
    the next wall to be recognized as doubled would be 2/2. then the algorithm would lead to the following block
    1: X
    2:X
    i think that's it. or isn't?

Similar Threads

  1. Re: Adding Data to a Database Field in VB6 - Larry
    By Brian Higgins in forum VB Classic
    Replies: 0
    Last Post: 11-27-2001, 07:33 AM
  2. Advice for breaking into the field (repost)
    By David K. in forum Careers
    Replies: 0
    Last Post: 01-15-2001, 09:21 PM
  3. Ted, you're a prince!
    By Georgiana Trigg in forum VB Classic
    Replies: 0
    Last Post: 10-29-2000, 11:21 AM
  4. Advice for breaking into the field
    By David K. in forum Careers
    Replies: 0
    Last Post: 10-06-2000, 05:29 PM
  5. Framework of a complex game...
    By AGuy in forum Java
    Replies: 0
    Last Post: 07-31-2000, 07:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center