• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
allocating stuff
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Prev by Date: Re: Jag Screen Savers not 10.1.x Compatible?
  • Next by Date: Re: Jag Screen Savers not 10.1.x Compatible?
  • Previous by thread: Re: Accessing NSTextStorage of an NSText object ?
  • Next by thread: Qs on printing from non-document apps
  • Index(es):
    • Date
    • Thread