allocating stuff
allocating stuff
- Subject: allocating stuff
- From: Jon <email@hidden>
- Date: Tue, 22 Oct 2002 10:58:47 -0700 (PDT)
Hi,
Right now I'm using this C somewhat objective-C
code to make a Laser fire. How could I change this
into one of those theSomething = [something alloc]
init]; and [theSomething release]; things? Here's the
code:
BOOL laserInUse[10];
/* [self shotLaser]; is what is called every time the
space bar is hit (the fire key)
- (void)shotLaser {
int index;
if (index = [self allocLaser]) >= 0) {
[self initLaser: index];
}
}
- (int)allocLaser {
int i;
for (i = 0; i < 10; i++) {
if (!laserInUse[i]) {
return i;
}
return -1;
}
- (void)initLaser:(int)index {
laserInUse[index] = YES;
/* the other coordinates */
}
Thanks,
Jon
Y! Web Hosting - Let the expert host your web site
http://webhosting.yahoo.com/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.