realbasic-nug
[Top] [All Lists]

Array of Canvases vs Subdivided Canvas

To: "RB NUG List" <realbasic-nug@lists.realsoftware.com>
Subject: Array of Canvases vs Subdivided Canvas
From: <timm@lisauskas.net>
Date: Thu, 30 Jul 2009 01:11:00 -0400
Authentication-results: mx.google.com; spf=neutral (google.com: 74.124.194.228 is neither permitted nor denied by best guess record for domain of realbasic-nug-bounces@lists.realsoftware.com) smtp.mail=realbasic-nug-bounces@lists.realsoftware.com
Delivered-to: listarchive@realsoftware.com
Reply-to: REALbasic NUG <realbasic-nug@lists.realsoftware.com>
Sender: realbasic-nug-bounces@lists.realsoftware.com
Hi all,

I have a question about the advantages/disadvantages of using an array
of Canvases (Canvii?) as opposed to a single Canvas that's
programmatically subdivided.  Consider this:

A grid- based game board that can be of a player- determined size.  Each
cell will have a background color, possibly a graphic image, and be
clickable so as to change state (active, not active, etc.).  When the
player saves their game the state of each cell will have to be stored to
file, and saved games will have to be read from a file as well.

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?

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.  Game rules (like what does a given cell do when the neighbor cell
is affected) could be added to the Canvas subclass easily.

I think a single Canvas would avoid the possible memory- related issues
an array of 1,000,000 Canvases would have, but would that outweigh
whatever disadvantages the single- Canvas approach has?  A single Canvas
seems slightly less OOPish to me, too.

Thanks for any advice!

Timm



_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>