Archived

This topic is now archived and is closed to further replies.

soreno

need some design help

Recommended Posts

soreno    122
I'm trying to think of a solution to at problem. I'm making a 2d game, and have come up with the following conseptual model: Game @ | Map @ | Piece Where @ is an an aggregation. The idea is that the map consists of pieces in the following way: _____ _____ _____ |--1--|--2--|--3--| |____|____|____| |--4--|--5--|--6--| |____|____|____| |--7--|--8--|--9--| |____|____|____| the problem is that i need to know who owns the wall between 1 and 2 (and 1 and 4 and so on), because only one owner is allowed. How can I model that? Mvh Søren Olesen Edited by - soreno on December 14, 2001 7:37:18 AM

Share this post


Link to post
Share on other sites
Sandman    2210
The obvious solution would be to make each room ''own'' its top and left walls. You then have to figure out how to deal with the walls right at the bottom and right of the map: one solution would be to make ''degenerate'' rooms along the bottom and right hand edges which own one wall each.

Share this post


Link to post
Share on other sites
eldee    122
typedef Piece {
int nN_Owner;
int nE_Owner;
int nS_Owner;
int nW_Owner;
}

initialize your "map" with a for loop.
after that, when a player "aquires" a wall or whatever,
you can set the variable to the player numbe.r. ie)
player 1 aquires piece 6, you can use something to this effect:

PieceNum[5].nN_Owner = 1

signifying that player 1 now owns piece 6''s north wall..

sorry if the syntax isn''t exact, its early in the morning, and i
pop between programming languages (c++ and vb).

-eldee
;another space monkey;

Share this post


Link to post
Share on other sites
soreno    122
eldee> i was thinking of something like that.
but i hoped to get something where i don''t have to worrie too much about ownership. my game will actually consist of hexagonal pieces, which only adds more to the struct and i''m afraid i''ll loose the general view (not sure if it''s a legal expression..

Share this post


Link to post
Share on other sites
Symphonic    313
Are you dependent on piece ownership or wall ownership? or both?

If you want to simulate just wall ownership then you might do best to (for hex-maps) record ownership of three of the six walls for every cell.

For example

struct Cell
{
int nUR_Owner; // upper right
int nLR_Owner; // lower right
int nB_Owner; // bottom
}

This arrangement will require that you have ghost cells padding the top and left edges so that those outer edges can also be owned.

Obviously to add cell ownership you may just have to add in another ownership value for the cell itself.

George D. Filiotis
Are you in support of the ban of Dihydrogen Monoxide? You should be!

Share this post


Link to post
Share on other sites
Inmate2993    222
Hexagonal... Okay, some abstract thinking may be neccessary. Obviously, for there to be a room, there needs to be 6 walls, but instead of keeping structs with six walls as a room, keep a wall struct with rooms on either side of it and what other walls it connects too. I''m not sure of the purpose of this whole discussion, but sometimes it helps to look at the problem from an inversed perspective.

:: Inmate2993
:: William C. Bubel
"Please refrain from bothering Booster."

Share this post


Link to post
Share on other sites
soreno    122
i need to control both wall and piece ownership.

I think that Inmate2993 suggestion is something to work with.

Thanks for all your replies.

Mvh
Søren Olesen

Share this post


Link to post
Share on other sites