Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 21 in printed book and digital formats -- plus a one-year subscription (beginning with 22.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview

Buy Now

Issue 2.6


Art and Letters

Drawing Hexes (and Other Things) with Text

Issue: 2.6 (July/August 2004)
Author: Lars Jensen
Author Bio: Lars Jensen is so old-school he edits programs by taping the little paper rectangles back into punch cards.
Article Description: No description available.
Article Length (in bytes): 17,394
Starting Page Number: 24
Article Number: 2611
Resource File(s):

Download Icon 2611.zip Updated: 2013-03-11 19:07:58

Related Link(s): None

Excerpt of article text...

In all but the simplest projects, it's usually a good idea to develop the user interface separately from the "engine" -- that is, the program's internal operations. If this separation is complete, debugging and testing the engine can be simpler and more exhaustive. You can even create different user interfaces for different kinds of environments, from desktop applications to cell phones to Internet services.

However, you need a way to know what's happening inside your engine. I usually just dump my engine status as ASCII text to a log file or a window as needed. Text is workable, but often cumbersome -- without careful formatting, the very patterns of behavior I'd like to reveal might be hidden by the sheer bulk of it all.

This became particularly irksome for me in a hexagonal board game engine; trying to visualize the action from lists of hex coordinates was just too mind-boggling. I needed a way to "draw" the board in two dimensions using text characters instead of pixels. In this article, I'll review the design and implementation of a class and subclass that made this easy.

The Essential API

I like to start a new class by first thinking about its API ("application programming interface" -- the set of methods and properties that it presents to the world), and leaving the implementation for a bit later. To design an API, you need to know what you want to get out of it, so I used a text editor to mock up my desired output:

...End of Excerpt. Please purchase the magazine to read the full article.