Codevault questions and contributions!
Displaying 1-20 of 51 total.
12 3
next
mcgrue
|
Please feel free to discuss Zip's Code Vault documentation, and provide new functions to add to it here!
Posted on 2004-12-19 13:42:31
|
gannon
|
cool a central place to put those is cool
[Zip: quicksort done]
Posted on 2004-12-19 14:37:21 (last edited on 2004-12-19 17:08:34)
|
Omni
|
It's kind of inconvenient that we can't post our own code...
Just post the entry here?
Posted on 2004-12-19 16:15:49
|
mcgrue
|
Here or in the talkback of the document.
Posted on 2004-12-19 16:33:15
|
Omni
|
Right, okay. This one's pretty simple...
XScaleBlit
ScaleBlits a certain area of the source image to the destination. Srcx1, y1, x2, and y2 are the area of the image to be blitted.
This allows areas of an image to be displayed without using ImageShell and additional sub images.
[Zip: See XScaleBlit()]
I couldn't really think of a good name for this function so I just call it XScaleBlit.
Posted on 2004-12-19 16:54:21 (last edited on 2004-12-23 18:34:03)
|
Zip
|
Dude, has anyone told you that function has 10 parameters? Unless I'm majorly missing something, I don't see how this is better than: int section = ImageShell(srcx1, srcy1, srcx2-srcx1, srcy2-srcy1, source);
ScaleBlit(x, y, scalew, scaleh, section, dest);
FreeImage(section); You know ImageShell is just a pointer, not a duplication of data, right?
Zip
Posted on 2004-12-19 17:52:20
|
Omni
|
...I had figured that just setting clipping would be faster than creating and freeing pointers.
But...oh, fiddlesticks, nevermind.
Posted on 2004-12-19 18:29:50
|
Zip
|
The parasing overhead if the vc code (even in 'compiled' form) is much larger than any code vec is running his end, unless it involves shifting large amounts of data around. This is why doing 320 little blits is so much slower than doing one big blit (as in your question earlier). It's also why andy laughs at me using the bitshift operators - there's really no difference in an interpreted language like this.
Zip
Posted on 2004-12-19 18:49:13
|
Ness
|
A function I wrote that will blit text to an xy coord with any color. It replaces RGB(255, 255, 255) with whatever color you pass.
It also scales the text based on 100. So if you pass it 50 it will be half size, 200 will be double size.
[Zip: added, see PrintStringAdvanced()]
Posted on 2004-12-19 21:17:37 (last edited on 2004-12-23 20:50:41)
|
Omni
|
The parasing overhead if the vc code (even in 'compiled' form) is much larger than any code vec is running his end, unless it involves shifting large amounts of data around. This is why doing 320 little blits is so much slower than doing one big blit (as in your question earlier). It's also why andy laughs at me using the bitshift operators - there's really no difference in an interpreted language like this.
Noted.
Posted on 2004-12-19 21:21:39
|
Technetium
|
I have absolutely nothing of use to contribute, after scanning my system.vc. All my functions are either too long, require too much interaction with multiple other functions, or are just too specific to my game to be of any use to anyone else.
Posted on 2004-12-19 21:31:05
|
blues_zodiakos
|
I really like that function, Ness (I'm happpppppy). This code vault thing is a great idea.
Could that SuperPrintText be sped up if instead of doing a color replace, it worked in two stages: Printstring the text into a blank image, do a Silhouette on it to change it to the color you want, change the transcolor to 0, then blit it onto another image that you filled with magic pink, change the transcolor back to magic pink and then blit it? Would the three operations possibly be faster than doing a color search/replace?
Posted on 2004-12-20 15:45:48 (last edited on 2004-12-20 15:48:16)
|
Ness
|
It might be faster, but this function also only changes the white pixels, which means you can have a font with a border, which in the other method won't work, unless I completly misunderstood how your method works :p in which case you can probably ignore me.
Posted on 2004-12-20 20:04:29
|
RageCage
|
It seems like it would be a good addition if you put in a absolute value function. Also, there's a couple more functions that aren't so much simple as they may be essential.
Geronimo's bmp function.
and
Aen's extra big ellipse function for those crazy people using an abnormally large ellipses.
and lastly, the line function which can be used for so much more than just drawing a line.
[Zip: added, see LineAgain()]
---
and that's my contribution! Hope they're actually what you are looking for.
Posted on 2004-12-21 10:22:57 (last edited on 2004-12-23 21:18:26)
|
Zip
|
Geronimo's bmp function is deprecated, see FileWriteBitmap24() instead. It writes good bitmaps even when the width is not a multiple of 4, and like your modifications, you pass the filename, and unlike your modifications, won't bomb if it can't open the file.
I'll add everything else over the xmas period, though I wish a few of you would use comments... even just for what the function actually *does*. Like... what is 't' about your line rage? By the way, f anyone wants to poke Ness' code, feel free. I'll add the current version, and update as needed.
Zip
Posted on 2004-12-21 12:25:03
|
zonker6666
|
Print strings in color - a bit slimmer than Ness' implementation.
[Zip: added, see PrintStringCol()]
Posted on 2004-12-21 12:46:22 (last edited on 2004-12-23 20:52:33)
|
RageCage
|
well well, I guess I didnt look very hard at what you had. cool, I was afraid that the bmp function got lost in history
as for the t in line, it stands for tristan, my name. I just had to put something since theres already a line() function. The point of the function is to see how you can draw a line and apply it to other hings like shooting a gun and checking along the line for collisions or many other things.
Posted on 2004-12-21 13:14:27 (last edited on 2004-12-21 13:16:57)
|
zonker6666
|
Been looking around for some functions I find particularly useful ... so here come a couple more.
// returns a random number between n1 and n2..
// either of those numbers can be a negative
// RandomRange(0-10,10);
// RandomRange(10,0-10);
// RandomRange(1,100);
// would all work.
int RandomRange(int n1, int n2)
{
if(n1>n2)
return random(0, n1-n2)+n2;
else
return random(0, n2-n1)+n1;
}
/// a die roll ... D(3,6) = 3d6
int D(int rolls, int numsides)
{
int retval=0;
int i;
int temprollval;
for(i=0;i<rolls;i++)
{
temprollval=RR(1, numsides);
retval+=temprollval;
}
return retval;
}
// A nicer way to roll a die ...
// examples of use ...
// RollD('1d4');
// RollD('5d6+10');
int RollD(string droll)
{
int retval;
retval=D(val(GetToken(droll, 'd', 0)),val(GetToken(droll, 'd', 1)))+val(GetToken(droll, '+', 1));
return retval;
}
Posted on 2004-12-21 14:33:41
|
RageCage
|
uhh... random() does exactly what your function does.
Posted on 2004-12-21 17:40:46
|
zonker6666
|
Rage if you ran the following line ..
PrintString(0,0,screen,0,str(random(100,0-100)));
you would see that it does not ;)
Posted on 2004-12-21 21:58:23
|