PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Tutorial 3

The third installment of my Game and Graphics Coding tutorial is now online at http://pizza.hvu.nl/~kouwenhs/tech.htm .
Enjoy.
- Jacco.
Great info Jacco!

Dan East
Jacco, why don't you get a domain of your own?
Shawn Wineholt · 20 Jul 2001, 14:00 UTC
I will give him a domain name to keep for free and hosting for 3 years if he or anyone else can teach me PocketPC programming!!  PS I live in Los Angeles

(btw the name in question is GothamGames.com (I like Batman what can I say))
Moose or Chuck · 20 Jul 2001, 14:09 UTC
Dammit! If only I had spent the last two weeks writing a PocketPC programming tutorial instead of sleeping I could have a free domain name and hosting for 3 years!!!
DAMN YOU, SATAN! MY IDLE HANDS WILL NO LONGER BE A TOOL FOR MY DESTRUCTION!
ShawnWineholt · 20 Jul 2001, 14:11 UTC
You're Hillarious!  Does this mean I need to go read a book instead of trying to get taught this way?  I think that Jonathan Harbour has a good one : Game Programming with Gapi or something like that... any thoughts?
Moose or Chuck · 20 Jul 2001, 14:14 UTC
Image
This is a good one. Pocket PC Game Programming. And it's good for more than just game programming, it goes through the entire process, along with teaching you GAPI and everything else gaming related.
Moose or Chuck · 20 Jul 2001, 14:17 UTC
Does this mean I get a free domain and hosting now? No one would visit my site so it wouldn't take up much bandwidth :)
ShawnWineholt · 20 Jul 2001, 14:20 UTC
Yup!! That's exactly the book I meant.  The thing is I have a few years of PHP/Flash/HTML/Director experience but no WIN stuff (i.e. compiling, etc is a mystery).  That is why I thought sitting down with a knowledgeable PocketPC Programmer might be a good thing.  Do you know of any resources or people in Los Angeles where I could go to do just that?
Moose or Chuck · 20 Jul 2001, 14:22 UTC
Oh, if you have no C++ skills then starting with that book may not be the best idea. Uhm... I don't know anyone in any area that just sits down and teachs you one on one. But I'm sure there are classes at your local college, school, or even library that would be a big help.
ShawnWineholt · 20 Jul 2001, 14:26 UTC
OK here is a stupid newbie question feel free to edit it out later.... I take it then that c++ is the language you use to program a PocketPC yes?

I thought it had its own language really... Told you I was new at this.

Ok then so basically I just look on the web for C++ tutorials then right?

(btw this is very helpful info thanks)
WIN WIN WIN WIN WIN WIN

lets see kazaa add da linkz
Moose or Chuck · 20 Jul 2001, 14:37 UTC
Speaking of which. Paul, did you download the source zip file from my tutorial page and test it out?
Moose or Chuck · 20 Jul 2001, 14:39 UTC
Yep. WindowsCE uses C++ just like any other OS in the world. But you'll need a special compiler to build apps for the various processors.
http://www.microsoft.com/windows/embedded/ce/tools/emvt30order.asp
Here you go, download this for free if you've got a phat pipe, or order it for 8$ s&h. Then you can get started. But the PocketPC doesn't have directX, only GAPI, which is quite different. And be sure to use UNICODE.

(ex:
MessageBox(NULL,"Message","TITLE",MB_CANCEL) is bad, it uses strings. On the PocketPC you'd have to write the code like this:
MessageBox(NULL,TEXT("Message" ),TEXT("TITLE" ),MB_CANCEL)
It's not really a nuissance, but you just have to remember that.)

Those two things, GAPI and UNICODE, are the only real differences, except some stripped down header files and less functions built in.

EDIT: Those miserable smilies!
i might have downloaded it, i definitely havent opened it though.
ShawnWineholt · 20 Jul 2001, 14:41 UTC
Thanks.. I think that explains all the stars next to your name.... well C++ here I come!

(And if there really are any people in L.A. who might sit a person down and teach them this PocketPC thing the offer still stands)

btw I could not access your pocketgamerz site.. is it down or do you have a "No Newbies" policy?
Moose or Chuck · 20 Jul 2001, 14:50 UTC
PocketGamerz isn't open yet. And I'm just going to work there, reviewing things, posting news, etc.
Or you can do like me.

Start porting some DHTML game you've made and learn along the way. Weeboo is originally a game I wrote in DHTML, and I thought it would be cool to have it on my PPC so I downloaded EasyCE and started from there. Now Weeboo runs in a heavily modified version of easyce. In many parts you couldn't even tell it is easyce. Not it is more customized. But back when I started learning C++ (I learned along the way) and WinCE programming it was great to have EasyCE to look at.

Now I'm not saying you can go with no programming skill at all an just learn how to code C++ in a few weeks. I had a solid programming experience behind me, so I just used the previous knowledge and made it into C++ syntax (and learned a lots of new things too). I mean you have to be atleast a bit crazy to write a platform game like weeboo that runs in your browser! Sadly I can't release it yet due to the fact that it uses some stuff I wrote for a company I used to work with, and they own the rights to those thingies. Well it's basically the same as the PPC version but it uses MIDI music instead and doesn't have inertia.

FYI. Argentum does not use EasyCE.
you don't always need to feed amazon.com to learn new things. Sometimes just plain trial and error will get you there. I basically ported the core of weeboo before I even understood what a pointer was :)
Moose or Chuck · 22 Jul 2001, 09:47 UTC
Speaking of pointers...
a pointer is pretty much the same as a variable, but can be used cross function?
A reference is a pointer that points to a memory address like 0x800 or 0xff?
Sort of. Like you said, pointers are often used to pass variables to functions, if the variable is large (a struct, class, array, etc), or if the variable is to be modified in the function. However, it is useful for far more than that. For example, if you had an array of characters, and wanted to search them for a particular letter:
[fixed]
char szMyString[]="This is my test string!";

//Find the first occurance of 'e', 'y' or 'r'.

char *pC=szMyString;
//pC now points to the first char in the string
while (*pC)
 if (*pC=='e'||*pC=='y'||*pC=='r') break;
 else pC++;  //Jump to the next char
[/fixed]
That could be done with the array operator [], but what I have above is the most effecient. Each time you access as an array (pzString[ i ]), math has to be performed to offset by the array index and dereference that value. So above you can see that I only perform math once each iteration (pC++), where if I used an array math would have to be performed 4 times each iteration (once for each comparison, plus you'd have to increment your index).
Also, any program that deals with non-trivial amounts of information has to use the heap (as opposed to the stack). The Stack is a chunk of memory every program is given up front to run in. All variables declared in the program (such as szMyString and pC above) are given a chunk of the heap to store their data. One of the problems with the stack is you have to know up-front when you build the program exactly how large each variable will be (this concerns arrays particularly). So what if we need to get ahold of varying amounts of memory at runtime? You allocate it off the Heap. In C++ you can simply use the new operator:
[fixed]
//I need "i" characters allocated for a string:

char *pszString=new char[ i ];

//See if we got what we wanted
//(otherwise we're out of RAM)
if (!pszString) return;

//Do something with my string
strcpy(pszString, pszSomeOtherString);

//Now's the important part, we have to free
//the memory we allocated, otherwise we created
//a memory leak, and we'll run out eventually.
delete []pszString;
[/fixed]

The new and delete functions are specific to C++. In C you would use malloc / free or similar. Also note that I placed two brackets after delete. That tells delete that it is to delete an array. In this case the brackets aren't actually necessary, because what we are deleting is not an array of C++ Classes. It is good practice to use those brackets any time you delete an array so you don't forget when it does matter.
I didn't mean to say that much, but oh well. :)

Dan East
The point I was trying to make regarding allocating memory off the Heap is that new or malloc returns a pointer to the data. Hence another need for pointers...

Dan East
I'll see if I can find some time to write another tutorial tomorrow, about buffers, pointers and sprites. I get a lot of questions about these topics, so apparently this is keeping a lot of people from coding.
Moose or Chuck · 23 Jul 2001, 14:52 UTC
I like references more than pointers. Pointers are just another type of more variable variable to me...