ID:270516
 
I am starting my survival game and I have come across a problem. I want my harpoons to have a variable length handle. Now this could be done by making about 1000 different icons, though that would be utterly ridiculous. So I decided to come up with some code which would achieve the same thing.

Here is the code I am using at the moment:

obj
Items
Tools
Fishing
Harpoon
New()
..()
harpoonhead=new('ToolHeads.dmi',"sharp")
changeLength(15)
var
icon/harpoonhead
proc
changeLength(length)
var/icon/handle
for(var/i=1,i<=length,i++)
handle=new('ToolHeads.dmi',"handle[i]")
handle.Shift(i,SOUTH)
icon+=handle
icon+=harpoonhead

In therory this should work. Though I have found out some problems. According to the help file, it says this:

Addition and Subtraction
The result of adding two icons is an arithmetic combination of the color components of each individual pixel. At positions where either icon is transparent, the result is also transparent. Subtraction, instead of increasing the intensity, decreases it by the amount in each pixel of the icon being subtracted.

Suppose you wanted to add together different bodies and heads. You could do that by making a few of each type with black backgrounds. When these add together, the black contributes nothing but prevents pixels in the other icon from getting clipped.


So I make the icons backgrounds black, as that is the effect I want to achieve. Though when I create it, the whole black background is visible. So then I made it transparent. It was excelling, it didn't show... :(. The harpoon was completely invisible.

The second problem I have is with Shift(). When I use it, it never actually shifts the handle part. By the way, the handle is actually 4 pixels in a horizontal line. The harpoon head is just one small icon. I know shift doesn't work because when I run it all the handle pieces are on the same place.

So, would anyone know an answer to this problem? Any help would be greatly appriciated.

ADT_CLONE
Bump.
Bump, again...
Your arguements are reversed. Shift()'s format is Shift(dir,offset,wrap), not Shift(offset,dir,wrap).
In response to Exophus
Ahh, thanks for that. Now it is actually creating the handle. Though there is still a problem. The background of the icon is black, even though the help file says it shouldn't be.
In response to ADT_CLONE
I missed the point on why you'd have to make the backround black.. Either that or just forgot and am too lazy to check the post again ^_^. Anyways, try making the backround transparent and make sure the handle is an object and not a turf.
Your problem of the black background is because the += operator blends the two icons with the ICON_ADD method. You should use icon.Blend(othericon,ICON_OVERLAY) for what you're wanting to do.


As a note, take it easy on the bumping. You'll likely get your thread axed.