Click here to Skip to main content
15,883,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I've been working through tutorials and samples on tile engines and procedural map generation(dungeon / roguelike) maps/mazes, and am about to embark on a project of my own, using C#4.0 and MonoGame.

I'm wondering whether there is any information on whether it's better to use the classes provided by System.Drawing (Rectangle, Point, PointF etc) for describing my maps (2d arrays, tilesets, passable/impassable maps for feeding an A* algorithm) or if better performance can be gained by writing your own basic geometry model (custom rectangle, vector, point classes etc). I'm thinking methods like Point.GetNeighbours, or Rectangle.Inflate, .Offset etc here, e.g.basic geometric operations on points and regions.

What's the general opinion on this - Use System.Drawing or "roll my own"?

Apologies for the rather open-ended question!
Glen205...
Posted

1 solution

I'd use the built in classes, cause I see no benefit in creating boilerplate "low level" geometry objects. But you may add some extension methods (GetNeigbours or what you want) to ease your coding. If you don't now about Extension methods see: http://msdn.microsoft.com/en-us/library/bb383977.aspx[^]
 
Share this answer
 
Comments
glen205 17-Jun-14 4:20am    
Thanks for this - apologies it's gone so long before I've rated your answer... and I can't find any "accept answer" button on-page. I only see "reject solution", which I don't want to click! :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900