timm@lisauskas.net wrote:
I thought an array of Canvases might work better, but what kind of
issues might I run into? For example, while I imagine a 20 x 20 grid
(400 Canvas objects) would be no problem for any modern computer to
handle, what about something on the order of 100 x 100? 1000 x 1000?
Sounds unpleasant to me. If you just have one of those in the IDE and
then create the rest via cloning, it would be slightly less unpleasant.
But in my experience, a single canvas for a game like this is far easier.
An array of Canvases would also more easily allow for oddly- shaped grid
maps, I believe. Instead of a simple square 20 x 20 I could have
designs such as a plus sign, square with a hole in the middle, and so
on.
Yes, but what if you decide that instead of square cells, you want
hexagonal ones? Or some other odd shape (like countries in Risk)?
Canvases do not get along well when they have to overlap, and then
you're going to be in a world of grief.
So I approach these apps with a single big canvas in which I do all my
drawing, and then elements can overlap however they need to, and I have
complete control over what gets drawn and when.
This doesn't mean it's any less OOPy -- you can still have a "BoardCell"
class that represents each place a player can move or interact with or
whatever, but now you get to define that however you want; it doesn't
have to be rectangular and non-overlapping.
Best,
- Joe
--
Joe Strout
Inspiring Applications, Inc.
http://www.InspiringApps.com
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
|