Previous topic - Next topic

Yodaman Jer

Hi all,

I can't seem to get the SETTRANSPARENCY command to work properly in a FOR-NEXT loop with "GRABSPRITE".

Break-down of my code:

First I'm using SETTRANSPARENCY to set black not to be drawn, then I'm loading my "landsprite.bmp" tileset.

Then I'm using a FOR-NEXT loop to break the tile into three separate sprites using GRABSPRITE. Before this, I use SETTRANSPARENCY again to set the black pixels not to be drawn.

Then I'm drawing a series of these freshly made sprites to "stretch" out my tileset and check for seamlessness. The problem? The black outline is clearly visible...

...but when I draw the original sprite, it's not there!

Full code...
Code (glbasic) Select
// --------------------------------- //
// Project: 2DGame
// Start: Tuesday, September 27, 2011
// IDE Version: 10.118

//Load our font
LOADFONT "Media/newFont.png",0

//Load our sprite
LOADSPRITE "Media/Sprites/landSprite.bmp",0

FOR A=1 TO 3
    DRAWSPRITE 0,0,0
    GRABSPRITE A,X,0,40,40

//Set current font

//Main loop
    //Draw sky-blue background
    DRAWRECT 0,0,800,600,RGB(0,150,255)

    //Draw a series of tiles
    DRAWSPRITE 1,0,600-40
    DRAWSPRITE 2,40,600-40
    DRAWSPRITE 2,80,600-40
    DRAWSPRITE 2,120,600-40
    DRAWSPRITE 2,160,600-40
    DRAWSPRITE 2,200,600-40
    DRAWSPRITE 3,240,600-40

    PRINT "A*Little*Epic",800/2-110,0
    PRINT "A Game By Jeremy Gardner",800/2-200,25

I've tried putting the command in different places within the FOR-NEXT loop but nothing works. Can anyone tell me what's going on please?  :)

EDIT: It definitely seems to be with just the GRABSPRITE command, as I moved my code out of the FOR-NEXT loop and tried it that way, and it still gave me the black out line. :\
Click the pic to go to my development blog!


I found that as well the other day, the solution was to keep the whole spritesheet as the drawing material and draw the separate sprites by using polygons, since POLYVECTOR will allow you to draw an offset of the sprite in memory.

As for an explanation, who knows, maybe the transparency only works for LOADSPRITE sprites and not for GRABSPRITE ones.


Would be worth trying SMOOTHSHADING FALSE

Yodaman Jer


Could you show me an example of what you mean, please? I don't quite follow...
Click the pic to go to my development blog!


Yep, grab the attachment. I am quite new though so there might be a better way to do this, but this is the best I know for now.

[attachment deleted by admin]

Yodaman Jer

Thanks! That helps me a lot! I'm going to have to look into those commands more, they look incredibly useful!
Click the pic to go to my development blog!