Another TOP build!
Hey all, been a few days since I’ve posted, just wanted to let you all know I’m still working hard!
TOP is coming along great, the newest feature is:
Map linking!
The game can now move between maps, it’s a very simple event system that allows events to be
fired and causes things to happen =)
with the help of Seth, I got the system to work with enter/exit so now things can happen depending on
if you’re entering the event or exiting =)
here’s some code I was using, it gave me problems for a few hours:
- (void)checkEvents
{
OPRoom *currentRoom = [currentMap currentRoom];
NSArray *roomEvents = [currentRoom events];
NSEnumerator *eventEnumerator = [roomEvents objectEnumerator];
OPEvent *anEvent = nil;
while((anEvent = [eventEnumerator nextObject]) != nil) {
if(NSIntersectsRect([player collisionRect], [anEvent collisionRect])) {
if(![anEvent isDone]) {
BOOL intersectedBefore = ([eventStateDictionary objectForKey:[anEvent identifier]] != nil);
BOOL intersectsNow = NSIntersectsRect([player collisionRect], [anEvent collisionRect]);
if(intersectedBefore && !intersectsNow) { //exited event
[self runEvent:anEvent];
[eventStateDictionary removeObjectForKey:[anEvent identifier]];
} else if(!intersectedBefore && intersectsNow) { //entered event
[self runEvent:anEvent];
[eventStateDictionary setObject:@"" forKey:[anEvent identifier]];
}
}
}
}
roomEvents = nil;
currentRoom = nil;
}
I finally found the issue randomly when looking over the code for about the millionth time…
There are still some small issues with it, like some events could cause a circular “reference” for example
the world map links to level 1 at position 1,1. Then level 1 links to the world map at position 1,1 so the events
just go back and forth.. It works but is a little buggy =)
Note: please ignore the white square that initially shows up, i forgot to fix that before the upload
Without further ado, here is the link to the post!
TOP 12/21/2008 build 02
Next feature:
Add Items [which would lead into weapon support]