Monday, February 13, 2012

First Program

Yes that's right, it's high time we get our hands dirty with this programming business, like I know all of you have been itching to do.
I'm going to do the typical Hello World starting program just cuz I can :P. So here's the code, just copy it, and save it with file extension .c.


After you have this in Crimson Editor (or whatever editor you're using), compile this and run it in the GB emulator. The result should look something like this:

Pretty simple right? Let's have some more fun with this. Let's draw stuff on the screen. GBDK comes complete with a series of functions to draw with. These functions can be found in the drawing.h. drawing.h itself can be found by going to C:\gbdk\include\gb. Click it and open it up. inside will be a list of functions to, well, draw. Let's play with some of these yes?

We're first going to use plot_point. This is pretty straight forward. Here's the function's signature:
void plot_point(UNIT8 x, UINT8 y)
Now we just include the file in our code


and then we just simply add the function plot point, along with 2 different numbers for parameters (one for x and the other for y). Compile and run, and you will have a point on the screen (whatever coordinates you gave it). Mess around with the other drawing functions while you're at it. They're pretty straightforward.


0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home