This site is no longer active and is available for archival purposes only. Registration and login is disabled.

Tutorial 3


Re: Tutorial 3

Postby ShawnWineholt » Jul 20, 2001 @ 3:41pm

Thanks.. I think that explains all the stars next to your name.... well C++ here I come!<br><br>(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)<br><br>btw I could not access your pocketgamerz site.. is it down or do you have a "No Newbies" policy?
ShawnWineholt
pm Member
 
Posts: 6
Joined: Jul 20, 2001 @ 3:11pm


Re: Tutorial 3

Postby Moose or Chuck » Jul 20, 2001 @ 3:50pm

PocketGamerz isn't open yet. And I'm just going to work there, reviewing things, posting news, etc.
Moose or Chuck
 


Re: Tutorial 3

Postby Malmer » Jul 21, 2001 @ 10:38pm

Or you can do like me. <br><br>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. <br><br>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.<br><br>FYI. Argentum does not use EasyCE.<br>
All your base are belong to us
User avatar
Malmer
pm Member
 
Posts: 768
Joined: Apr 26, 2001 @ 5:15pm
Location: Sweden


Re: Tutorial 3

Postby Malmer » Jul 21, 2001 @ 10:42pm

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 :)
All your base are belong to us
User avatar
Malmer
pm Member
 
Posts: 768
Joined: Apr 26, 2001 @ 5:15pm
Location: Sweden


Re: Tutorial 3

Postby Moose or Chuck » Jul 22, 2001 @ 10:47am

Speaking of pointers...<br>a pointer is pretty much the same as a variable, but can be used cross function?<br>A reference is a pointer that points to a memory address like 0x800 or 0xff?
Moose or Chuck
 


Re: Tutorial 3

Postby Dan East » Jul 23, 2001 @ 10:32am

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:<br>[fixed]<br>char szMyString[]="This is my test string!";<br><br>//Find the first occurance of 'e', 'y' or 'r'.<br><br>char *pC=szMyString;<br>//pC now points to the first char in the string<br>while (*pC)<br>  if (*pC=='e'||*pC=='y'||*pC=='r') break;<br>  else pC++;  //Jump to the next char<br>[/fixed]<br>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).<br>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:<br>[fixed]<br>//I need "i" characters allocated for a string:<br><br>char *pszString=new char[ i ];<br><br>//See if we got what we wanted<br>//(otherwise we're out of RAM)<br>if (!pszString) return;<br><br>//Do something with my string<br>strcpy(pszString, pszSomeOtherString);<br><br>//Now's the important part, we have to free<br>//the memory we allocated, otherwise we created<br>//a memory leak, and we'll run out eventually.<br>delete []pszString;<br>[/fixed]<br><br>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.<br>I didn't mean to say that much, but oh well. :)<br><br>Dan East
User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Re: Tutorial 3

Postby Dan East » Jul 23, 2001 @ 10:35am

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...<br><br>Dan East
User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Re: Tutorial 3

Postby Phantom » Jul 23, 2001 @ 1:30pm

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.
Phantom
 


Re: Tutorial 3

Postby Moose or Chuck » Jul 23, 2001 @ 3:52pm

I like references more than pointers. Pointers are just another type of more variable variable to me...
Moose or Chuck
 


Previous

Return to Windows Mobile


Sort


Forum Description

General Windows Mobile discussion for end-users. Hardware, software, etc. This is also the forum to post your product announcements and other news.

Moderators:

Dan East, sponge, Kevin Gelso, RICoder, Chris Edwards

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum