#### Archived

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

# Small Mapping systems.

This topic is 6053 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Ok I''m trying an experiment in Java. I''m working on a simple game, a 2D space shooter. What I''m going to try to do is to actually simulate internal systems within the ships. So I want to have a ship contain various components that represent power generators, weapons, ect. This is going to be based on a game clock but I''m still trying to figure out a way to do two things. 1) I''m looking into a good way to represent internal coordinates of a ship. Lets say a ships floorplan exists in a 32x32 matrix. each cell of the matrix will either be part of the ship or not. if its a really small ship lets say it occupies (0,0), (0,1), (1,0),(1,1) (assuming a 0,0 coordinate as the upperleft with only positive values existing as coordinates). Now lets assume that we have a component that exists in a 2x2 matrix like the ship but only occupies (1,1) in the matrix. So the ship in its frame occupies 1 1 0 0 0 0 ... 1 1 0 0 0 0 .. 0 0 0 0 0 0 ... . .......... and in its frame the component occupies 0 0 0 1 now heres what I''m wandering. If I use actual matricies to represent the locations of the components do you guys think this would give me a fast way of identifiying components and in general doing colision detection. for instance let say that the component is in the ship above. (Just incase the spacing is off lets say the component exists at 1,1 in the ship.. so basically it would look like this in ship coords 1 1 0 0... 1 c 0 0 ... Now in ships coords the component exists at (1,1) with the components frame top left coor at (0,0) in the ships coords. ok just so I known what I just said Ships coord origin (0,0) in a 32x32 matrix. Components origin in component coords (0,0) coords occupied by component (1,1) in a 2x2 matrix. In the ships coordinate system the components origin is at (0,0) as well and the ships coords for the component square is (1,1) as well. I''m wandering if this type of overlapping matricies to describe component position sounds good or if maybe just a list of coordinate pairs describing the areas occupied by each might be faster. I''ll need to track damage as it moves throught the ship so I''ll need to know what initial square the damage occurs in the component and what the exiting square is for the damage as well so I can tell which component it should go to next. Hehe I think that its a lot more involved than I thought at first I was just wanting something that operated at O(1) if possible to convert component coords to ship coords and O(1) to find the exiting square (which would basically be line intersecting a polygon I guess, with one known point of intersection, the other point of intersection should be the exiting component square. Would just doing a simple translation matrix operation on the component matrix be sufficient? Hmm if I translated the component matrix from the ship origin to the ships coords for the component origin then saerched that matrix for the components coords that exist that might work. That would tell me how many of the components squarea exist in the ship and where they are in the ship. heck if I''m not that worried about the space it takes up I could just have two matrices for each component, basically component coords and ship coords. umm I may have just figured out but if any one sees problems doing this (mainly scalabily to multiple ships doing this type of simulation all at once or posiibly generalization to 3d coorinates) I''d love to hear alternate suggestions. All this is just for the ship itself so I don''t see needing to generalize this to the entire play area (I''ll probably use some other form of collision detection and this will only kick in if something collisdes with the ship). Thanks. Josh.

1. 1
Rutin
26
2. 2
3. 3
4. 4
5. 5

• 9
• 13
• 19
• 14
• 9
• ### Forum Statistics

• Total Topics
632940
• Total Posts
3009328
• ### Who's Online (See full list)

There are no registered users currently online

×