-
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
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?
-
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.
-
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.
-
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
-
By Brian Higgins in forum VB Classic
Replies: 0
Last Post: 11-27-2001, 07:33 AM
-
By David K. in forum Careers
Replies: 0
Last Post: 01-15-2001, 09:21 PM
-
By Georgiana Trigg in forum VB Classic
Replies: 0
Last Post: 10-29-2000, 11:21 AM
-
By David K. in forum Careers
Replies: 0
Last Post: 10-06-2000, 05:29 PM
-
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks