imSimReal

The imSimReal framework and projects built from it

imSimReal: A Cocoa Framework for Mac Games

imGravityGame for Mac progress

June 16th, 2009 · imGravityGame

I’m needing to build a test example for the Mac using imSimReal 0.1 capabilities. To do that, I created an imSimReal framework project and pulled the source code into that project as a subdirectory of imSimReal. Then I created the imGravityGame as another subdirectory to create the game. At this point, I’ve gotten the initialization code working with a screen as follows:

imGravityGame window in startup condition.

Obvoiusly, there’s still stuff to do to make it look good, like label the window, but it has the stuff to start.

I am now back to working on the project that’s paying some bills, so I’ll be laying this aside for a bit again. As usual, it’s all available on Github.

Technorati Tags:
, , ,

→ No CommentsTags:

imSimReal Working as 0.1RC4

June 11th, 2009 · imSimReal

I tagged the latest release 0.1RC4, as the latest release candidate, although I don’t believe it’s really ready to release yet.

I need to create a sample application that puts it to use as is to show how to use it.

I have the Acceptance Test framework working for all tests, and they all pass. First image is the top level menu:

Top level view of the Acceptance Test application for imSimReal with Gravity and PointObject test suites

This image displays the success of the PointObject tests:

The successful PointObject tests

Much of the activity involved refactoring to simplify the code yet still work correctly.

Two remaining activities:

  • Create a Framework to work with MacOS X projects
  • Create a test application, either iPhone or Mac, to demonstrate use of the framework

Technorati Tags:
, , ,

→ No CommentsTags:

Updates to imSimReal

June 7th, 2009 · imSimReal

After spending the past several months working on other things, I’ve been doing some stuff with imSimReal again. I revised the unit tests to test in the iPhone environment. And I’ve added an Acceptance Test layer. At this point it works pretty well, but I do have another level of display to add to the tests.

The test framework is built on a UITableView in a NavigationView. The top table contains a list of the sets of tests available, like so:

The top level of the test framework in the iPhone simulator

Each cell is a test suite. Touching the cell causes the suite to run. If it passes, it turns green. If it fails, it turns red. And if it is mixed results, it turns yellow. A gray cell is one that has not been run.

If you select the detail view button on the right side of the cell, the detailed table view opens:

UITableView showing the Gravity test suite

This display shows the Gravity test suite, with all the tests having passed. I need another layer, to provide details of the test when you touch the detailed button on the cells at this level, but I haven’t added that part yet. The code for all this is available in the imSimReal package in gitHub.

I am reworking the IMSRPointObject class, removing the NSDictionary that contained all the data, and instead putting the data at the top level. So far it hasn’t been completed, but should be soon. I also plan to add a new Xcode project that builds a Framework for OS X. This framework will support garbage collection.

After that, I’m thinking I need to make an example application using the IMSRGravity and IMSRPointObject classes before moving on to the next piece of functionality.

Technorati Tags:
, , ,

→ No CommentsTags:

imGravityGame Flipside mostly Done

February 8th, 2009 · imGravityGame

At least for now. I need some more text for the instructions, and I am having trouble when switching from the landscape orientation in the main window and the portrait orientation in the flipside view, but that will be fixed soon. Here are some images of the flipside:

Flipside view with Instructions alert box open

As you can see, the instructions are not helpful. Here is the About box:

Flipside view with the about alert box open.

This box contains enough text to require a scrolling box.

//
// FlipsideViewController.h
// imGravityGame
//
// Created by John Ahrens on 1/9/09.
// Copyright John Ahrens, LLC 2009. All rights reserved.
//

#import

@class AppController;

@interface FlipsideViewController : UIViewController

{
IBOutlet UIPickerView *planetView;
IBOutlet UISlider *slider;
IBOutlet UILabel *sliderLabel;
IBOutlet UIButton *instructionsButton;
IBOutlet UIButton *aboutButton;

AppController *controller;
NSArray *planets;
}

@property (nonatomic, retain)UIPickerView *planetView;
@property (nonatomic, retain)UISlider *slider;
@property (nonatomic, retain)UILabel *sliderLabel;
@property (nonatomic, retain)UIButton *instructionsButton;
@property (nonatomic, retain)UIButton *aboutButton;

@property (nonatomic, retain)AppController *controller;
@property (nonatomic, retain)NSArray *planets;

- (IBAction)sliderChanged: (id)sender;
- (IBAction)buttonPressed: (id)sender;

@end

Also of interest at this time is the -(IBAction)buttonPressed: (id)sender method:

- (IBAction)buttonPressed: (id)sender
{
NSString *title = [sender currentTitle];
NSBundle *bundle = [NSBundle mainBundle];
NSString *file;

if ([title hasPrefix: @"About"])
{
// This is the About button
file = [bundle pathForResource: @"about" ofType: @"txt"];
}
else
{
// This is the Instructions button
file = [bundle pathForResource: @"instructions" ofType: @"txt"];
}

NSString *text = [NSString stringWithContentsOfFile: file
encoding: NSUTF8StringEncoding
error:nil];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle: title
message: text
delegate: nil
cancelButtonTitle: @"Close"
otherButtonTitles: nil];
[alert show];

[alert release];
}

Note that it determines which button was pressed, then gets the appropriate file and opens the alert box. The message in the alert box is the contents of the file.

Technorati Tags:
, ,

→ No CommentsTags:

FlipSide of imGravityGame complete

February 1st, 2009 · imGravityGame

I’ve completed the layout of the flipside of imGravityGame. Here’s an image:

Flipside of imGravityGame with planet picker, velocity sliding box, instructions and about buttons.

The two buttons turn blue when touched, but they don’t actually do anything yet. That’s the part I have to figure out next. How to best bring up a window that shows the instructions for how to play, and an About box with the credits.

Technorati Tags:
, ,

→ No CommentsTags:

Planet Picker now works

January 31st, 2009 · imGravityGame

I got the planet picker to populate with an array that’s in alphanumeric order. Now I need to move the Gravity code from the FlipSideViewController, to a controller class. an AppController, rather than a view controller to maintain the MVC pattern.

Update 3:49 MST: Here’s an image of the working picker:

Flipside of imGravityGame in simulator with picker and Earth selected.

Update 5:00 MST: Added the slider to set the velocity of the sliding box moving across the base to catch the falling ball. Here’s an image:

Flipside of imGravityGame in simulator with picker showing Earth selected and slider showing 25 m/sec velocity

Technorati Tags:
, ,

→ No CommentsTags:

Another update

January 25th, 2009 · imSimReal

I updated imSimReal again. This time I only added a new test case, so I didn’t roll to a new Release Candidate. If you’re interested, you’ll have to get the latest from github.

In short, I added the test case - (void)testGetGravityForSelectedBodyWithBadBodyName:. The primary plan here was to make sure that we can deal with the case where the selectedBody in IMSRGravity is not a member of the bodyGravity NSDictionary.

A look at the test:

- (void)testGetGravityForSelectedBodyWithBadBodyName
{
NSString *body = @"test";
IMSRGravity *gravity = [[IMSRGravity alloc] init];
STAssertNotNil(gravity, @"IMSRGravity not created with default initializer");

[gravity setSelectedBody: body];
double expectedResult = 0.0; // value if selectedBody is not valid (i.e., null, etc.)
double result = [gravity gravityForSelectedBody];
STAssertEquals(result, expectedResult, @"Expected %f, got %f", expectedResult, result);

[body release];
[gravity release];
}

Technorati Tags:
,

→ No CommentsTags:

imSimReal 0.1 RC3 available

January 24th, 2009 · imSimReal

IMSRGravity now has a new data member and a new method. It stores the selected body. The new method provides the means of getting the gravity value of the selectedBody.

There is also a new initializer -initWithBody:

- (id)initWithBody: (NSString *)body
{
if (![super init])
{
return nil;
}

bodyGravity = [[NSDictionary alloc] initWithContentsOfFile: @"Gravity.plist"];
selectedBody = body;

return self;
}

Note that the initializer takes an NSString object that provides the key into the bodyGravity NSDictionary. With this change, the default -init: method changes to call -initWithBody: with Earth as the default selectedBody:

- (id)init
{
return [self initWithBody: @"Earth"]; // Use Earth in the absence of other values
}

The new -gravityForSelectedBody: method returns 0.0 if the selectedBody is nil, otherwise it gets accesses the bodyGravity NSDictionary to get the gravity value for the selectedBody key.

At this point there is some error handling missing for the case where the selectedBody does not match any element in the NSDictionary.

- (double)gravityForSelectedBody
{
if (selectedBody == nil)
{
return 0.0;
}

NSNumber *gravity = [bodyGravity valueForKey: selectedBody];
return [gravity doubleValue];
}

The current class declaration looks like:

@interface IMSRGravity : NSObject
{
NSDictionary *bodyGravity;
NSString *selectedBody;
}

@property (nonatomic, retain)NSDictionary *bodyGravity;
@property (nonatomic, retain)NSString *selectedBody;

/**
* An initializer for selecting the body to use when initializing. If no body is
* selected, the default init: method sets body to Earth
*
* @param body The body to set selectedBody to
*
* @return a newly initialized IMSRGravity object
*/
- (id)initWithBody: (NSString *)body;

/**
* Get the gravity value for the selectedBody.
*
* @return gravity for the selectedBody variable, in meters/second.
*/
- (double)gravityForSelectedBody;

@end

This is available from GitHub as tag 0.1RC3, and as a disk image at the downloads page.

Technorati Tags:
,

→ No CommentsTags:

imGravityGame and more updates to imSimReal

January 18th, 2009 · imSimReal

Started working on imGravityGame, a demonstration of the use of IMSRGravity in the imSimReal framework. I’m working on the flipSide where I start with a Picker to pick the body providing the gravitational attraction, such as a planet. In -initWithNibName:Bundle:, I load the IMSRGravity object.

gravity = [IMSRGravity alloc] init];

In -viewDidLoad:, I construct an NSArray using the keys from gravity:

planets = [gravity allKeys];

The FlipSide implements two data source methods:

-numberOfComponentsInPickerView:

which returns 1, and

-pickerView:numberOfRowsInComponent:

which returns the number of planets in the gravity:

return [planets count];

It also implements one UIPickerViewDelegateMethod

:

-pickerView:titleForRow:forComponent:

which returns the name of the planet indicated by the NSInteger row

return [planets objectAtIndex: row];

At this point I realized that IMSRGravity needs a place to store the currently selected planet, so I will be going back to imSimReal and preparing 0.1RC3 soon (like tomorrow, hopefully).

Here is the current status of FlipSideViewController class:

@interface FlipsideViewController : UIViewController

{
IBOutlet UIPickerView *planetView;
IMSRGravity *gravity;
NSArray *planets;
}

@property (nonatomic, retain) UIPickerView *planetView;
@property (nonatomic, retain) IMSRGravity *gravity;
@property (nonatomic, retain) NSArray *planets;

@end

Technorati Tags:
, ,

→ 1 CommentTags:

imSimReal update

January 11th, 2009 · imSimReal

Besides getting the latest from GitHub, you can also get the latest disk image. Unfotrunately, for some reason, the disk image is 100 MB. Not sure why, but I think I need to figure out how to shrink it down some.

This code is currently only being used in an iPhone application, so the fact that the project file is an application file is irrelevant. That was the easiest way to get the tests built into the project quickly, so I went with it. I should point out that the project file, if you build the Unit Test target, builds the imSimReal code and the OCUnit test code, then executes the tests, and only reports success if all the tests pass.

Technorati Tags:
,

→ No CommentsTags: