Most pointless piece of code... ever!
Displaying 1-5 of 5 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
Zip

Just want to share my suckyness with you all. This morning I wanted a way to dynamicly assign images runtime, and along the way completely forgot everything I learnt about pointers. I blame it on everything being called int in verge. Anyway how about this for a way of doing exactly what is already being done by verge?
(Oh and vec - I understand why you can't automatically set the handle to 0 on FreeImage() now. Looked at this bit of code and it made some kinda sense. Took me a while, but I got there in the end. FreeImage(3) - third image assigned, is just as valid as freeing a specific one - therefore me need to manual 0 stuff...)

#define MAX_IMAGES 16


int extraimages[MAX_IMAGES];

int GetImageHandle()
// Gets an empty image handle
{
for (x = 0; x < MAX_IMAGES; x++)
{
if (!extraimages[x])
{
return x;
}
}
exit("No free images to assign")
}

void FreeAllImageHandles()
// Frees all images
{
for (x = 0; x < MAX_IMAGES; x++)
{
if (extraimages[x])
{
FreeImage(extraimages[x]);
extraimages[x] = 0;
}
}
}

void FreeImageHandle(int fih_num)
// Frees image at specified index
{
if (extraimages[fih_num])
{
FreeImage(extraimages[fih_num]);
extraimages[fih_num] = 0;
}
else MessageBox("No image to free #: "+str(fih_num));
}


[Edit: Slight reduction of idiocy]

Posted on 2004-06-12 04:52:33 (last edited on 2004-06-12 05:12:52)

vecna

Yes..... That is pointless! :D

Posted on 2004-06-12 05:47:16

Gayo

You could make a more pointless piece of code by putting everything in an "if (0)" clause, if you're going for the record.

Posted on 2004-06-12 22:48:23

Ness

And it has the added effect of limiting you to 16 images. Think I'm going to put that into my next project

Posted on 2004-06-13 00:34:47

Zip

Well, the one bonus of this bit of stupidity was that it clarified how verge was actually handling images. And I did realise before it was to late that I could just chuck the image pointers around however I wanted. Glad I didn't show this code to the world and make a fool of myself.

Wait a minute...

Zip

Posted on 2004-06-13 00:53:53


Displaying 1-5 of 5 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.