AGS Pointers for Dummies - Update 17 October 2006

Started by monkey0506, Tue 03/01/2006 02:19:18

Previous topic - Next topic

monkey0506

It's been a while since I wrote the first version of this "tutorial-kind-of-thing," and I felt it was time for an update. Some revisions, some new content, and a cover image!


Feel free to comment or ask any questions!

Gilbert

Actually this fits either of the Tech forums I think, and due to the usefulness of this, it may go to the Tech. Archive as well.

SSH

Not to mention the wiki
12

Ubel

Wow, monkey_05_06. Before this I had never really understood what pointers are or what you can use them for! Thank you very much for sharing this tutorial-kind-of-thing! It really helped me. :)

Babar

I hate pointers. With all their "special status" asterisk markers, that confuzzle and their "relieve the burden" attitude, that leaves you wondering what their doing.

:= Thanks for the tutorial. It helped a bit. Now if only I could remember why I needed them...
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

monkey0506

In AGS you need pointers to find out what InventoryItem, GUI, GUIControl, Character, Hotspot, Region, or Object is at coordinates (X, Y) on the screen (with the function *.GetAtScreenXY(X, Y)).  Also if you want to have any background speech you might want a pointer to the Overlay that is created by that function so you can prematurely remove the text from the screen.  Furthermore you will need pointers if you plan to work with files (File), dynamic sprites (DynamicSprite), and the date and/or time (DateTime).

And, like I said, what pointers really do is "point" to a variable stored in the memory.  Basically they just store the address of the variable, and then when you use them it finds that point in the memory and accesses that variable (which is why if you try to work with a pointer improperly, such as if it is null, you will get dastardous results).  So in essence you are just creating a new alias for an existing variable...if that helps explain it.

Ashen

I agree with SSH, this should be Wiki'd. I'd do it myself, if I could figure out how.
I know what you're thinking ... Don't think that.

monkey0506

#7
Yay!!!

Wiki

I did it!  It took me a while to get used to the Wiki code, but I got the page up.  Also, I added some stuff...In fact, I forgot the most important use of pointers!!!  Well, one of the most important ones anyway.  Just scroll down to "*** NEW AS OF 3 JANUARY 2006 ***" and continue reading from there. :=

I'm so excited about everyone's responses!  I just can't help but smile!!! ;D ;D ;D

[EDIT:]

I changed the link from a direct address to a hyperlink (because it was stretching the page out).

Also, I have been unleashed upon the AGS Wiki!!!  No article is safe from my editing!  Actually I've just been editing some of the scripting articles with relevant information.

[EDIT:]

It only took me 16 edits to get the Wiki entry for this correct!  w00tage!!! :P  Stupid history...:D

Elliott Hird

Mmm, I'm gonna make a full “AGS for Dummies” and I think I'll link to this.

monkey0506

Well...a "full 'AGS for Dummies'" would take quite some time to write.  I mean, to define it as "AGS for Dummies" would imply that it will teach you...at the very least...all of the basics of AGS.  Don't take this to mean that I think you can't/won't do it...I'm just saying it would be a large project.  Good luck with it! ;)

monkey0506

I've been incredibly bored lately. And I decided that this could use some work. I've even gone so far as to make a mock-up cover image.

I've revamped the organization, added some new content, and actually rewritten most of the article.

~Cheers everyone!

Pumaman

Looks good!

The only suggestion I'd make is to remove the bit about null being equivalent to 0, since it isn't. You can't compare a pointer to 0 and mentioning it in the tutorial is probably just going to confuse people.

Good work :)

monkey0506

#12
The reason I say that is because...er...well...that's the only way to make an optional pointer parameter ATM... :o.....and....er...okay. :'(

I actually added disclaimers when I put that to the effect that in most cases null should be used, not 0...but...you can't initialize a pointer to null in a function prototype. Import. Whichever. So...uh...can you make it so we can initialize our pointer parameters then? Please?

[EDIT:]

Okay, I removed the bit professing that they're equal...because obviously they aren't and I'm just a n00b...but regarding optional parameters, how does this sound?:

QuoteThough it is not normally recommended (and in most cases won't work), we can substitute the value 0 for null in this case.

I just think people should know you can make pointer parameters optional...though the means are a bit different to normal pointer usage.

And, no complaints about the section on Strings then? To be honest that's the section I was most worried about. Talking about char*s...

Also I never said thanks. So, thanks Chris. :)

SMF spam blocked by CleanTalk