PDA

View Full Version : Carbon base structure - Mac 10.2 compliant.


FCCovett
2003.10.12, 10:33 PM
I've uploaded the most recent version of a base structure that is starting point to set up basic stuff as:

1. a window,
2. a timer,
3. Carbon-events handlers,
4. a QuickDraw port,
5. a Quartz2D context,
6. or an Open GL context (with CGL or AGL, fullscreen or windowed; it also shows how to create textures from a TGA file with or without an alpha channel),
7. a linear-PCM audio player that loads an AIFF file (44 kHz, 16 bit, stereo) from a bundle resource, converts and stores it into a Float32/LPCM source, and plays it through the computer's default audio device.

This is a work-in-progress but it should help beginners (like me) get started with their games in C or C++. THe 1.2 Mb .dmg file can found at:

http://home.earthlink.net/~yexirocks/MyGameSource.dmg

Your comments and suggestions are more than welcome. Thanks!

codemattic
2003.10.14, 01:01 AM
Thankyou for uploading this. Im doing a lot of Cocoa programming - but have been putting off figuring out how to make stuff run in Carbon if I want to be compatible with OS9. MyGameSource should be very helpful.

thanks,
Codemattic

FCCovett
2003.10.14, 05:45 PM
That's great. I am not sure whether all of the source code will run on OS 9 though, as some stuff there is not supported on CarbonLib. I am focusing on OS X only.

Update:

I've just uploaded a new version that converts and plays 44 kHz or 22kHz, stereo or mono, 16 bits AIFF files. You can mute and/or loop an audio channel now.

It should be fairly easy to extended that code to support full play/pause/stop/loop/rewind/forward capabilities, and to create playlists for each channel.

Press '1' to '8' play the test files.

FCCovett
2003.10.20, 10:10 PM
I've just uploaded a new version which comes with a basic but effective way to load up all AIFF files from the bundle and convert them into LPCM.

The same approach can be used to load up all the game graphics, to create textures or bitmap resources for your sprites.

A new sprite section is barely there, but it already shows how to perform a test to check if the mouse pointer has entered or left the area of the frontmost sprite. Check it out.

There was a small "bug" in the AudioIOProc that was cancelling the audio output of one channel if the next channel volume was set to 1.0 (max). Now, all channels are mixed out properly.

FCCovett
2003.10.27, 03:33 PM
The most recent version of MyGameSource checks the mouse movement against all sprites (including rotated sprite areas) and shows how to make sprites react to mouse clicks and drags.

The pages (game screens) and page-sprites concept is still a work-in-progress, but you should be able to easily assign keys or mouse clicks to jump from one "page" or game screen to another (what automatically loads up the sprites corresponding to that page and puts them on the screen).

Next, I will try to implement a way to load all textures and assign them to their respective sprites. Stay tuned.

FCCovett
2003.11.21, 01:04 AM
I've got a new web-site going on. The source code can be found at this new location:

http://webpages.charter.net/fccovett/MyGameSource.dmg

aarku
2003.11.28, 03:16 AM
This looks really cool so far. One thing though, I didn't see any readme files or license information in your download. Is it public domain or what?

-Jon

FCCovett
2003.11.28, 04:01 PM
Yeah, I've been a little busy to write a read.me. Also, this is a work-in-progress and I've been uploading new versions several times a week, as I backup my work.

Well, part of the code I got from the Apple web-site, but there's no restrictions of which I am aware. As for my code, it's public domain. I didn't copy any piece of code from any other sources (other than a couple of resources you may find there, which I used as placeholders, so use your own to avoid trouble).

FCCovett
2003.12.07, 05:56 AM
The sprites are linked to each other according to these two criteria:

1. Sprite number (assigned upon initialization of the sprites - shall remain immutable);

2. Sprite locZ (dynamically assigned by the user/program), which tells the order that the sprites shall be blitted to screen.

Sprites with higher locZ are now displayed on top of others with lower locZ. If two sprites have the same locZ, they are sorted by their sprite number.

This is particularly useful when you want to display a custom mouse pointer on top of all other graphics.

Many thanks to Philip J. Erdelsky for his excelent MergeSort() function found at:
http://www.alumni.caltech.edu/~pje/mergesor.html

FCCovett
2004.01.12, 02:25 PM
I've just fixed a "bug" with the CoreAudio IOProc that was creating an audible "blank" or skip when looping a sound. If you based your CoreAudio code on mine, I strongly recommend you check this new version out:


//----------------------------------------------------------------------
// Read the LPCM sample frames pointed by this channel:

frameCount = LPCMReadFromChannel( channel_ref, frames_ref, SAMPLES_PER_BUFFER );

//----------------------------------------------------------------------
// Check if reached the end of the sound (or the frameCount set for this sound):

if ( !frameCount || !channel_ref->framesRemain ) // Loop sound. --CHANGED!
{
if ( channel_ref->isLoop )
{
channel_ref->isBusy = TRUE;
channel_ref->ptrFramesCurrPos = channel_ref->currLPCM_ref->frames;
channel_ref->framesRemain = channel_ref->currLPCM_ref->frameCount;

//----------------------------------------------------------------------
// Fill in the frame_ref buffer on loop to prevent a "blank" between IOProc cycles:

frameCount += LPCMReadFromChannel( channel_ref, (frames_ref + frameCount), (SAMPLES_PER_BUFFER - frameCount) ); //--NEW!
}
else // Stop sound.
{
channel_ref->isBusy = FALSE;
}
}

FCCovett
2004.01.27, 01:11 AM
The game is almost ready so I am pulling off the source code for a while as there's too much copyright protection stuff in it at this point. I shall be posting a stripped version of the source code a few months after the official release date. I'll keep you all posted.

aarku
2004.01.27, 01:19 AM
The game is almost ready so I am pulling off the source code for a while as there's too much copyright protection stuff in it at this point. I shall be posting a stripped version of the source code a few months after the official release date. I'll keep you all posted.

What good is pulling it off now? It was already made public, so it is very hard maybe impossible to make it unpublic. Or are you referring to updates to what is public?

-Jon

FCCovett
2004.01.27, 03:49 AM
What good is pulling it off now? It was already made public, so it is very hard maybe impossible to make it unpublic. Or are you referring to updates to what is public?
-Jon

Well, the version that was online had a few bugs that were fixed in the past few weeks. I am really busy finishing the game off so it's been difficult to maintain two versions at the same time; the public version started lagging off behind the game version.

I really need to edit the code to pull out the registration code as it's third party stuff I can't make public. That doesn't mean that you guys cannot use my code; you can, of course. It's just that I don't want to knowingly keep a buggy version online. I'll post a new functional version when I have some time.

If you have any question about that source, please post them here or catch me online via iChat and I'll be glad to post a response as time permits.