Changes are coming…
I just wanted to let you all know that when I cover Tutorial 10 I will also be covering a number of changes to the overall project.
As I’ve been writing these tutorials and working on my own code I’ve found better ways of doing things as well as I’ve started to find my own style in how I like to set things out. It certainly seems that some patterns are useful when creating games such as the Singletons etc but in general you do what is necessary to get the game working :o)
I’ve moved away from having all the game logic and rendering in the EAGLView into seperate files. One is a GameController which handles the high level functions of the game and then I have individual scene classes for each scene i.e. menu, game, highscore. I’ve also been fixing any memory leaks which have been highlighted in the blogs, so thanks to everyone who has spotted these things and passed them on :O) and I’ve also tried to improve performance where I can.
I’ve also been renaming things as well to make better sense to me and also making more changes that I can remember to things like the Image class and others. I’m going to try and cover as many of the changes I can remember in Tutorial 10.
I apologize that the Tutorial 10 project will look a little different and contain a number of changes from the previous tutorials. The problem I have had is keeping the projects in line with my sandbox. The easiest way to solve this is to move to my sandbox project so that the tutorials are all in line with what I am doing. I think the changes are good changes and you should be able to merge anything you like the look of with your current projects.
I just wanted to let you know this was going to happen with Tutorial 10 and I’m hoping its going to make things easier for future tutorials.
Mike
13 Comments
Austin on June 13th, 2009
Thank you Mike for all these tutorials. Can’t wait for number 10!
Greg on June 15th, 2009
Sounds good to me! I’ve already been using a modified version of some of your code in my game (such as spritesheet and image classes) so it’ll be interesting to see how you’ve decided to reorganize. Trying to figure out the “best” way to split stuff out into views, viewControllers, an over-all gameController, and a singleton was quite the challenge. And I’m still not sure I’m 100% happy with how I did it.
Mr Speaker on June 15th, 2009
Wooo! I’m interested in the scene class – sounds like a cool idea.
Hey Greg, perhaps you could post a small write-up somewhere on how you did your views/viewControllers – I’m sure there are a zillion ways to structure a game, so it would be good to see how everyone does it!
A Person on June 16th, 2009
Hey Mike sorry to bother you again but I’m no that familiar with errors yet so here’s what happens.
When i Build and Go on my project once it loads it points a red arrow to lines of code that use the tiles array and the gdb says Program received signal EXC_BAD_ACCES don’t have a clue what that means, so here is my code.
- (BOOL)detectCollisionForLayer:(int)number TiledMap:(TiledMap*)tiledMap rectObject:(Image*)objectOne offsetX:(float)offsetx offsetY:(float)offsety {
Layer *layer = [[tiledMap layers] objectAtIndex:number];
float spriteTileX = objectOne.origin.x / tiledMap.tileWidth;
float spriteTileY = objectOne.origin.y / tiledMap.tileHeight;
int tileX = 0 + tiledMap.mapLocation.x;
int tileY = 0 + tiledMap.mapLocation.y;
BOOL tiles[(int)320 / tiledMap.tileWidth][(int)480 / tiledMap.tileHeight];
while(tileY < layer.layerHeight – 1) {
while(tileX < layer.layerWidth – 1) {
int globalID = [layer getGlobalTileIDAtX:tileX + tiledMap.mapLocation.x y:tileY + tiledMap.mapLocation.y];
if(globalID != 0) {
int tileOnGridY =(int) (tileY + 1) * tiledMap.tileHeight – tiledMap.tileHeight – tiledMap.origin.y;
int tileOnGridX =(int) tiledMap.origin.x + (tileX + 1) * tiledMap.tileWidth – tiledMap.tileWidth;
tiles[(int)tileOnGridX / tiledMap.tileWidth][(int)tileOnGridY / tiledMap.tileHeight] = YES;
}
tileX++;
}
tileY++;
}
if(tiles[(int)spriteTileX + 1][(int)spriteTileY] == YES | tiles[(int)spriteTileX - 1][(int)spriteTileY] == YES | tiles[(int)spriteTileX][(int)spriteTileY - 1] == YES | tiles[(int)spriteTileX][(int)spriteTileY + 1] == YES) {
return YES;
} else {
return NO;
}
}
Thanks Mike can't wait to see tutorial 10
Peter on June 16th, 2009
I can’t wait for this tutorial Mike. Thanks for all the awesome work!
mike on June 16th, 2009
Thanks Peter. I’m hoping to get the Tutorial finished asap, but things are hectic at the moment :o)
Mike
A Person on June 20th, 2009
Hey mike are you going to be covering rotated collision detections in your upcoming tutorial?
mike on June 20th, 2009
@A Person, I’m not planning on covering that at the moment. The detection is really around AABB (Axis Aligned Bounding Boxes). If I have something which rotates then I normally use bounding circles as rotation does not change it :o)
I may look into more complex collision detection later.
Mike
Garfeild on June 25th, 2009
Hello Mike!
Your tutorials is greate!
But I found strange error in you tutorials when I tried to run them on iPhone OS 3.0. I see only black screen. This error begins at tutorial 3.
mike on June 25th, 2009
Hi Garfield. This is something myself and others from the blog have come across. In the appdelegate you need to use the code below rather than just [glView startAnimation] or whatever method you are calling :o)
[glView performSelectorOnMainThread:@selector(mainGameLoop) withObject:nil waitUntilDone:NO];
Hope that helps.
Mike
Garfeild on June 25th, 2009
Thank you! I knew you can help ;)
mike on June 25th, 2009
No problem :o)




bob on June 13th, 2009
@Mike
That’s great Mike, it makes more sense then trying to keep track of the different project views. I know from just trying to keep track of the different iterations of my game that it can be a handful.
Thanks A Lot.
I can’t wait to see this one.