Hi/Question

Deralti
Unregistered
 
Post: #1
Hello, I am deralti. I'm still reading the learning carbon book...but.. I'd like to get into my main reason that i bought the book:

I want to make a basic graphical(aka non-console) game, then improve upon that to someday work for a company.
I use ProjectBuilder to compile and edit all my programs.
A previous post(see fast 2d rendering) said he/she used copybits()...what header file is this from, and how is it used? I need some form of how to animate something so i can start there and eventually make my own engine. Please, if anyone could help it would be much appreciated.
Quote this message in a reply
Member
Posts: 111
Joined: 2002.06
Post: #2
CopyBits() is part of Carbon so when you make a Carbon project in Project Builder, you've included the headers and frameworks you need to use CopyBits() in your game. It's located in the file Quickdraw.h if you want to see the internals of CopyBits().

What CopyBits() does is move pixels from one graphics port to another. Normally you're moving pixels from an offscreen buffer. You move them either to another offscreen buffer or to the screen. You can learn about the parameters CopyBits() takes by looking at the QuickDraw documentation. It's part of the Carbon documentation that comes with Project Builder. When you look at the documentation, you will see that the first two parameters are bitmap pointers. In Carbon, use the call GetPortBitMapForCopyBits() for these two parameters.

Mark Szymczyk
http://www.meandmark.com
Quote this message in a reply
Deralti
Unregistered
 
Post: #3
OK....i'll try to read the quickdraw documentation....again.
Apple's vagueness is a killer :envy:
Quote this message in a reply
Deralti
Unregistered
 
Post: #4
yeah, im lost....again Blush

A short example would help tons.Looking at a ton of questionable(i have no idea what a good amount of them do....do i have to write an entire page of functions just to make one little picture on the screen? I'm so confused Wacko
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #5
Quote:Originally posted by Deralti
do i have to write an entire page of functions just to make one little picture on the screen?

Pretty much, yeah Smile

Do you have Mark's Mac Game Programming book?

Are you interested in learning OpenGL rather than Carbon?
Quote this message in a reply
Deralti
Unregistered
 
Post: #6
well of course im interested in learning OpenGL, but i thought i should learn how to do 2d graphics before i even THINK of doing 3d..... well...it seemed like a good idea at the time. I tried ordering that book from amazon before.......never did come :envy: . I'll try again, got fingers crossed that it will happen this time. Gahhhhhhhh this is hopeless Sad

Edit: I'm also trying to finish up learning carbon so that i can "port"(little to no code to change) a text-based RPG a friend of mine is making.
Quote this message in a reply
Sage
Posts: 1,234
Joined: 2002.10
Post: #7
GL stands for "Graphics Library". Not "3D Graphics Library".

You can do 2D with OpenGL, and the results will be faster than 2D graphics done any other way (on recent hardware.)
Quote this message in a reply
Deralti
Unregistered
 
Post: #8
well i tried openGL, but its even more vague and confusing than quickdraw! Shock

I tried NEhE's tutorial using GLUT but i could never get something to compile....
Quote this message in a reply
Oldtimer
Posts: 834
Joined: 2002.09
Post: #9
Head over to the chat room, and we'll talk you through it. Smile
Quote this message in a reply
Deralti
Unregistered
 
Post: #10
oh? chat room? I didn't know this site had one Shock must...ifnd it!!
Quote this message in a reply
Oldtimer
Posts: 834
Joined: 2002.09
Post: #11
The thread is here

I'm there right now, so just hop in and I'll get you through it. Smile
Quote this message in a reply
Member
Posts: 304
Joined: 2002.04
Post: #12
Deralti -

I have a suggestion for you. Dont write a graphics/animation engine - and definately dont write a 3d engine. Im not saying that its not a worthwhile experience. But there is a very large investment needed before you start to see returns. You will have to do a *lot* of programming and research before you have anything that you can play - and its very easy to be discouraged without getting the positive feedback that comes from playing your own game no matter how small it is. Also - there are plenty of 2d and 3d free and open-source engines available already.

For a 2d game: if you are using Project Builder and OS X - check out CocoaBlitz. If you are using codewarrior and want to remain compatible with pre OS X - get the latest version of SpriteWorld. There is a version of SpriteWorld for X and PB support is coming. There are also a number of Java based game libraries for both 2d and 3d - and then your games can possibly run multiplatform or in a browser.

Ive used SpriteWorld before and found it very well written, easy to understand and powerful for 2d games.

These libraries handle getting input, collision, tiling, sprites, sounds, transformations (rotation and scaling, etc), lighting, alpha, and more. SpriteWorld has some tile/maze editors. This is a lot to write yourself - and it will take much effort before you get your code to a point that you cna start on your actual game. I know SpriteWorld is the result of many years of work by a number of good programmers.

If you have an idea for a game - my suggestion is to find the libraries that get you the closest to that with the least amount of work. There is definitely something badass about the hacker that builds everything from scratch - but besides Carmack and a few others - I think most people who go down that path never finish their projects (myself included). Dont program in ASM when C will do - dont program in c when C++/Obj-C will do. Dont rewrite an engine where a free and opensource one exists unless you can do it better.

The best thing for you IMHO is to get a small game up and running. Asteroids, pacman, tic-tac-toe, or hopefully something that has a unique idea to it like Radical Rebound did.

good luck Deralti!
Codemattic
Quote this message in a reply
Deralti
Unregistered
 
Post: #13
Yeah a while ago i tried making a tetris, almost got there too. but drawing and redrawing the same shapes is really tough using only rects and such(not to mention that i don't know how to delay! Shock ) I'll look at cocoablitz but..... um...... I program in carbon/C++....is there a difference in this case?

edit: I tried opening cocoablitz to see what it looks like.....(assorted cursing)......(more cursing).... (cursing in assorted non-english languages).....JAGUAR! Gah, useless now Sad
Quote this message in a reply
Member
Posts: 164
Joined: 2002.04
Post: #14
I would recommend just writing misc. games and reusing any reusable source, then after the first couple games you'll automatically have an engine Smile

I just realised the benefits of that after making a basic Worms-ish engine in about 10 minutes by reusing tons of Lugaru source.
Quote this message in a reply
Member
Posts: 20
Joined: 2002.12
Post: #15
Quote:Originally posted by Deralti
yeah, im lost....again Blush

A short example would help tons.Looking at a ton of questionable(i have no idea what a good amount of them do....do i have to write an entire page of functions just to make one little picture on the screen? I'm so confused Wacko


Code:
#include <Carbon.h>
void main(void)
{
    WindowRef MyWindow;
    PicHandle Pict;
    Rect Bounds;
    GWorldPtr MyWorld;
    OSErr Err;
    InitCursor();
    MyWindow = GetNewCWindow (128, nil, (WindowRef)-1);
    InstallStandardEventHandler (GetWindowEventTarget(MyWindow));
    SetRect (&Bounds, 0, 0, 32, 32);
    Err = NewGWorld (&MyWorld, 0, &Bounds, nil, nil, 0);
    SetGWorld (MyWorld, nil);
    Pict = GetPicture (128);
    DrawPicture (Pict, &Bounds);
    SetPortWindowPort (MyWindow);
    CopyBits (GetPortBitMapForCopyBits(MyWorld), GetPortBitMapForCopyBits(GetWindowPort(MyWindow)),  &Bounds, &Bounds, srcCopy, nil);
    RunApplicationEventLoop ();
    DisposeGWorld (MyWorld);
}

This creates an offscreen graphics world (GWorld) and draws into it a picture loaded from a resource. Then, it copies the picture from the world to a window which was loaded from a resource.

Pages of code? Not really.

"Programmers are tools for converting caffeine into code."
Quote this message in a reply
Post Reply