Zero Sum Game

Games, Lies and Videotape

Subscribe to RSS feed

Flowchart for logic of implementing Levels

Differences between Java and Obj-C

If you're used to Java, you should keep in mind that while Objective-C on Mac OS X has exception handling support, it's an optional language feature that can be turned on/off with a compiler flag.
Morever, it is possible to pass nil as an argument to a method in Objective-C without generating a NullPointerException like in Java.
More differences to come with time.....

Program Design for Levels in a game

, ,

How does one go about writing code for different levels in a game?
Obviously, writing a different file/class for each level is absurd. Each level in a game is generally similar, at least in the basic game dynamics. The idea is to try and reuse as much of the code as possible for each level. A general purpose level class can be created, that can be instantiated for each level.
But what about the differences that each level has? Different levels have different properties, and some levels may have properties/entities unique to that one level, not found in any other level. It doesn't make sense to write general purpose code in this case, since it is used only once in one level. How do we design code for level-unique properties?
For now, I am using a brute-force method. One class file that contains the common denominator code for each level, that is called each time a level loads. And also in the same class file, I define all possible methods for all possible levels. So some methods may be called only once for properties unique to one level, some methods may be called more than once for properties that may be common to more than one level, and some methods may be called everytime for basic level functions.
I feel that there may a better way of doing this. Like I mentioned before, it seems like a brute-force method to define all possible methods all in one place. Perhaps there is some way to make it more elegant using Polymorphism or Object Overloading.....

Finding Memory Leaks

If you fix a memory leak and your program starts crashing, your code is probably trying to use an already-freed object or memory buffer.
You can use the NSZombieEnabled facility to find the code that accesses freed objects. When you turn on NSZombieEnabled, your application logs accesses to deallocated memory, as shown here:
2008-10-03 18:10:39.933 HelloWorld[1026:20b] *** -[GSFont ascender]: message sent to deallocated instance 0x126550 To activate the NSZombieEnabled facility in your application:
Choose Project > Edit Active Executable to open the executable Info window.
Click Arguments.
Click the add (+) button in the “Variables to be set in the environment” section.
Enter NSZombieEnabled in the Name column and YES in the Value column.
Make sure that the checkmark for the NSZombieEnabled entry is selected.

Taken from the Apple Development Guide

useful info about diff between device and simulator

"The problem you're facing is your locations. In the first example, you are trying to write outside of your application's sandbox. In the second example, you're trying to write inside your application bundle. The former is not allowed, so writeToFile:atomically: will return NO. The second one shouldn't be allowed, but it if it is will screw up your application because it will change the code signing checksum and cause your application not to launch in the future. Not a problem on the simulator where that is re-generated every time, but definitely a problem."

from http://www.iphonedevsdk.com/forum/iphone-sdk-development/5823-save-plist-properity-list.html#post26571

using properties in -viewDidLoad

Whenever you are initialising and calling the view of a UIViewController class from another class, and you need to set properties on the UIViewController you are calling - make sure you do it before you set any properties on the view itself. Otherwise, the properties will not be available in -viewDidLoad()
Eg:
newViewController.view.background = newBackground;
newViewController.property = newProperty;


means that newViewController.property will not be available in newViewController's -viewDidLoad()
make sure to set the class property before you manipulate the view.

i can only surmise that setting a property on the view controller's view calls viewDidLoad.

edit:
i have figured out that a way around this is to read the properties in -viewWillAppear() as opposed to -viewDidLoad().

UIImageView animatedImages

When we use animatedImages array in UIImageView, make sure to set the imageRect, or the image does not show up. Spent 2 hours coz of this bug.

How to develop for iPhone without access to a Mac with admin rights

So here is my situation.....

I am working on an iPhone game, but do not have a Mac. I do however do have access to Macs in my university's library. But they do not have admin accounts enabled. This presents a problem - since we need admin rights to install the iPhone SDK on a Mac. After being frustrated and threatened, i had to do something if i wanted to get any work done. What i did was the following:

  • Install the iPhone SDK on my roommate's Macbook. I was able to do this since he had admin rights. The installer installs Xcode with all the iPhone plugins in it.
  • Now copy the Xcode folder onto an external disk drive. Just drag-and-drop the Xcode folder onto the external drive.
  • When on the public Mac's start the Xcode from the Xcode folder on your hard drive, and you should be good to go. If the Mac already has Xcode installed on it, be careful to run the Xcode on the external drive and not the native Xcode executable on the Mac.


Is working like a charm for me right now........

MS word tab scroll trick

Working on a Game design document and stumbled across an interesting feature in MS Word 2007....
the tabs on top of the document are different from previous versions of word and take little getting used to......i wouldn't know which tab to click on to find some buttons i need.....

an easy way to browse through the tabs is to hover your mouse over the tab area, and use your mouse scroll wheel to go through all the tabs quickly........it is a fast and easy way to find what you are looking for without clicking on each tab......

Entering the blogosphere

OK.....so i am going to start using this thing a lot more from now on....
Mostly i will be using it as a personal journal, while i work on my final thesis project....to help me keep a chronological record of my thoughts....and as a archive for resources......which means a lot of the time it will be gibberish.....and me talking to myself.......

here goes.....
February 2012
M T W T F S S
January 2012March 2012
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29