need some design help

Started by
5 comments, last by soreno 22 years, 4 months ago
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
Advertisement
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.
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;
-eldee;another space monkey;[ Forced Evolution Studios ]
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..
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!
Geordi
George D. Filiotis
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."
william bubel
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

This topic is closed to new replies.

Advertisement