SRL Archive - Outdated Tutorials

[#34/35] Bitmaps.scar and srl_GetBitmap


Sir R. M8gic1an

2009-06-14 18:50:12

I'll make this short as I am not in the mood to write atm :p

Many people have been using srl_GetBitmap(NumberHere) , which is not advisable and is subject to break in the near future.


const
bmp_Ore_Clay = 0;
bmp_Ore_Iron = 1;
bmp_Ore_Copper = 2;
bmp_Ore_Tin = 3;
bmp_Ore_Coal = 4;
bmp_Ore_Silver = 5;
bmp_Ore_Gold = 6;
bmp_Ore_Mithril = 7;
bmp_Ore_Adamant = 8;
bmp_Ore_Runite = 9;

instead of doing srl_GetBitmap(1) for iron, i'd advise you to use srl_GetBitmap(bmp_Ore_Iron) for several reasons.
It's easier for you to check if you are using the right one, it's easier for others to check, and by calling the constant rather than the number you are sure to always get the right one.

Why do I say this now? Because bitmaps are constantly being added to bitmaps.scar , which means that the numbers change around.

for those of you who usually do

for i:= 0 to 9 do
BMP[i] := srl_GetBitmap(i)

//don't do it. if new bitmaps get added, they get added with the last integer,
// so you may actually end up loading ALL (or nearly all) the bmps

BMP[0] := srl_GetBitmap(bmp_Ore_Clay);
BMP[1] := srl_GetBitmap(bmp_Ore_Copper);
//is it really that hard to copy paste, change the number and the last word?

Also, i am in the proccess of updating srl_GetBitmap to avoid future problems with indexes.


//WriteLn('Loading new bitmap: '+IntToStr(ID));
case ID of
bmp_Ore_Iron :
Result := BitmapFromString(7, 3, 'beNrTUzZTknTUkPPSU/YzUI' + //Iron_Ore [1-02-09]
'UgIBso4qqtABEMMlbHKQgAiK4Mlg==');
bmp_Ore_Copper:
Result := BitmapFromString(7, 3, 'beNorN50frbE1Q+90icn1' + //Copper_Ore [11-03-08]
'avObtSB0oth4bbLOvlyDC+Wm9xos79RZAAWBbKCywwVGQAZQBIiA6' +
'i8AALhDHow=');
bmp_Ore_Tin:
Result := BitmapFromString(7, 3, 'beNqrrEiMiirMzGwoL+uoq+t' + //Tin_Ore [11-03-08]
'sqAeiutKSnNTU8vz8psqK7qZGIAIKtlRVAZVVFhYCBYFcoCBQfRMA' +
'rDwd+Q==');
bmp_Ore_Coal:
Result := BitmapFromString(7, 3, 'beNqzUFNVlTTQVzAxUba0UI' + //Coal_Ore [11-03-08]
'MgIBsuYmujCUQQcWRlUEEAcXUL2Q==');
bmp_Ore_Silver :
Result := BitmapFromString(7, 3, 'beNqbt6qsrKGra+qsWcuW' + //Silver_Ore [11-03-08]
'LNmwdNmm5cs3z5y5tLm5d+LEOXPnrVq1etvKlVuA4vPnr+7pmT512' +
'kIgAygCRED1cwHOSCc3');
bmp_Ore_Gold:
Result := BitmapFromString(7, 3, 'beNpbLDm1Snhdn9jRhZIXVk' + //Gold_Ore [11-03-08]
'ldXgNCh+dLrOgU3TVD/PRSydubpK+ukwYKAtkbJ4rtnSUBZABFgAi' +
'o/gQA2BsfeA==');

Just so you get an idea :)

So yeah… the faster you guys change your scripts around, the faster we can easily add new bitmaps without fear of breaking your scripts ;)

~RM

nielsie95

2009-06-14 19:23:52

From: Rasta Magician

for those of you who usually do

for i:= 0 to 9 do
BMP[i] := srl_GetBitmap(i)

//here is what i'd advise

for i:= bmp_Ore_Clay to bmp_Ore_Runite do
BMP[i] := srl_GetBitmap(i);


I'd advise not to store them in an array at all. There's nothing wrong with FindBitmap(srl_GetBitmap(bmp_Ore_Clay),.. :)

NCDS

2009-06-14 19:31:36

From: nielsie95
I'd advise not to store them in an array at all. There's nothing wrong with FindBitmap(srl_GetBitmap(bmp_Ore_Clay),.. :)


I don't ever really use SRL bitmaps but just out of curiosity..
What is wrong with using an Array like RM show's?

nielsie95

2009-06-14 19:36:49

Nothing really, but it's a bit unnecessary. Plus, not using it will most of the time improve the readability.

Nava2

2009-06-14 22:15:25

Uhm.. I noticed with the SRL bitmaps, many are not freeing them. THAT is a bigger issue.

Sir R. M8gic1an

2009-06-17 18:08:16

moved to srl library. Also, finished changing all the numbers into constants :)

~RM


Re - moved from members to tut island.

~RM