Article Preview
Buy Now
| Print: | |
| PDF: |
From Scratch
From Scratch: More TanGram UI
Issue: 2.6 (July/August 2004)
Author: William Leshner
Author Bio: William Leshner has been programming for twenty-five years and programming Macs for fifteen. He has spent a good deal of the last several years building REALbasic applications, utilities, and plugins, including KidzMail and SQLitePluginPro.
Article Description: No description available.
Article Length (in bytes): 9,635
Starting Page Number: 40
RBD Number: 2620
Resource File(s):
2620.sit Updated: Thursday, July 15, 2004 at 12:00 PM
Related Link(s): None
Known Limitations: None
Excerpt of article text...
Introduction
This is the third of six articles in which we are building a puzzle game called TanGram. As you may recall from the previous articles, Tangram is a game where players drag around polygonal shapes and arrange them to make pictures. As a challenge, players are presented with pre-created pictures that they must recreate, and players can also save their own pictures to challenge their friends.
In this article we will finish the UI for manipulating puzzle pieces. We will also see how to save a picture to a file and how to read it back in. Using our file saving technology, we will create a starting position for our game pieces so that they are arranged in a particular pattern every time a player starts a new game.
Flipping And Rotating
In the previous article we used Object2D objects to implement our Tangram game pieces. Object2D objects handle most of the gory details of drawing themselves in a particular position and rotation, with particular background and border colors. We did have to add the ability to perform hit testing to the stock Object2D objects that REALbasic provides, but that turned out to be simple once we tracked down an algorithm that determined whether or not a polygon contained a particular point. Once we could perform hit tests on our Object2D objects, it was a simple matter to implement the ability to drag pieces around in the playing area, but we missed two important manipulations: flip and rotate.
...End of Excerpt. Please purchase the magazine to read the full article.
Article copyrighted by REALbasic Developer magazine. All rights reserved.
|










