Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Sprites - Is There Another Way?
Index -> Programming, Turing -> Turing Tutorials
Goto page Previous  1, 2
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Cervantes




PostPosted: Sat Oct 21, 2006 6:02 pm   Post subject: Re: Huh?

maiku wrote:
I've tried re-writing my code about 4 different ways and it still doesnt want to work.

Did one of those attempts involve writing the code without using processes? That'd be my guess.

If that turns out to be the problem, I'd like to raise a big "told you so" to all those people who use processes when they should know better.
Sponsor
Sponsor
Sponsor
sponsor
maiku




PostPosted: Sun Oct 22, 2006 9:35 am   Post subject: !

Eh!?

I never thought about not using processes... I shall try it and post my results
Cervantes




PostPosted: Sun Oct 22, 2006 9:55 am   Post subject: (No subject)

Never thought about not using processes? You should avoid them at all costs. Read why.
bruized




PostPosted: Wed Nov 01, 2006 8:48 pm   Post subject: (No subject)

Sorry for the lateness, but I was just wondering (and having a little problem). I tried using BSprites and it works but for some reason the white in the picture is not transparent. As an example take the example (oh so confusing Laughing ) and change the background colour to black(or anything other than white). You can see all the (or at least a lot) white pixels. Anyway to get rid of this?
maiku




PostPosted: Wed Nov 01, 2006 8:52 pm   Post subject: yes!

yes, there is!!!

its a problem with the picture format. when ur editting the picture in paint save it as a 24 colour bit map and when ur editing, fill the entire background with bright pink first, then change it all to white.
bruized




PostPosted: Wed Nov 01, 2006 8:58 pm   Post subject: (No subject)

Yeah, I get that it has to do with the pixels not being all pure white. But when I actually tried to do this with a few of my pictures it would show the picture just fine with transparency but as soon as I stuck it in a loop with BSprite.Change to change the picture for a blinking effect it just showed the whole entire white background.

I'll see if I can fix this some how in my program.
CodeMonkey2000




PostPosted: Thu Nov 30, 2006 8:51 pm   Post subject: (No subject)

two procedures that feel are useful, newpic and save.
you can use these to create sprites from a sprite tree, and then save them

code:
fcn NewPic (x, y : int, px1, py1, px2, py2 : int) : int
        var spriteNum : int
        if upper (unused) > 0 then
            spriteNum := unused (1)
            for removeElement : 1 .. upper (unused) - 1
                unused (removeElement) := unused (removeElement + 1)
            end for
            new unused, upper (unused) - 1
        else
            new sprite, upper (sprite) + 1
            spriteNum := upper (sprite)
            assert spriteNum <= MaxSprite %If error then over Max amount of Sprites
        end if
        sprite (spriteNum).pic := Pic.New (px1, py1, px2, py2)
        assert sprite (spriteNum).pic > 0 %if error, could not find pic
        sprite (spriteNum).x := x
        sprite (spriteNum).y := y
        sprite (spriteNum).transClr := 0 %default color of transparent color
        sprite (spriteNum).mode := picMerge %Default Merge
        sprite (spriteNum).background := Pic.New (0, 0, 0, 0)
        Pic.SetTransparentColor (sprite (spriteNum).pic, sprite (spriteNum).transClr)
        Pic.Draw (sprite (spriteNum).pic, sprite (spriteNum).x, sprite (spriteNum).y, picMerge)
        result spriteNum
    end NewPic

    proc save (picID : int, name : string)
        assert sprite (picID).pic > 0 %if error, could not find pic
        Pic.Save (sprite (picID).pic, name)
    end save
Nigrev




PostPosted: Fri Dec 01, 2006 9:39 pm   Post subject: (No subject)

How do you return the value of the filename for thew sprite?
Sponsor
Sponsor
Sponsor
sponsor
CodeMonkey2000




PostPosted: Mon Jan 29, 2007 9:00 pm   Post subject: Re: Sprites - Is There Another Way?

I found an error. This:
Turing:
for test_back : 1 .. upper (sprite)
            if test_back ~= picID then
                if sprite (test_back).pic ~= 0 then
                    if (x >= sprite (test_back).x & x <= sprite (test_back).x + Width (test_back))|
                            (x1 >= sprite (test_back).x & x1 <= sprite (test_back).x + Width (test_back)) then
                        if (y >= sprite (test_back).y & y <= sprite (test_back).y + Height (test_back))|
                                (y1 >= sprite (test_back).y & y1 <= sprite (test_back).y + Height (test_back)) then
                            drawBack (test_back)
                            new redraw, upper (redraw) + 1
                            redraw (upper (redraw)) := test_back
                        end if
                    elsif (sprite (test_back).x >= x & sprite (test_back).x <= x1)|
                            (sprite (test_back).x + Width (test_back) >= x &
                            sprite (test_back).x + Width (test_back) <= x1) then
                        if (sprite (test_back).y >= y & sprite (test_back).y <= y1)|
                                (sprite (test_back).y + Height (test_back) >= y &
                                sprite (test_back).y + Height (test_back) <= y1) then
                            drawBack (test_back)
                            new redraw, upper (redraw) + 1
                            redraw (upper (redraw)) := test_back
                        end if
                    end if
                end if
            end if
        end for

should be:
Turing:
for test_back : 1 .. upper (sprite)
            if test_back ~= picID then
                if sprite (test_back).pic ~= 0 then
                    if (x >= sprite (test_back).x & x <= sprite (test_back).x + Width (test_back))|
                            (x1 >= sprite (test_back).x & x1 <= sprite (test_back).x + Width (test_back)) then
                        if (y >= sprite (test_back).y & y <= sprite (test_back).y + Height (test_back))|
                                (y1 >= sprite (test_back).y & y1 <= sprite (test_back).y + Height (test_back)) then
                            drawBack (test_back)
                            new redraw, upper (redraw) + 1
                            redraw (upper (redraw)) := test_back
                        end if
                    end if
                    if (sprite (test_back).x >= x & sprite (test_back).x <= x1)|
                            (sprite (test_back).x + Width (test_back) >= x &
                            sprite (test_back).x + Width (test_back) <= x1) then
                        if (sprite (test_back).y >= y & sprite (test_back).y <= y1)|
                                (sprite (test_back).y + Height (test_back) >= y &
                                sprite (test_back).y + Height (test_back) <= y1) then
                            drawBack (test_back)
                            new redraw, upper (redraw) + 1
                            redraw (upper (redraw)) := test_back
                        end if
                    end if
                end if
            end if
        end for

I don't use BSprites myself, but my friend does and he had some layering problems, a part of his picture merged into the background and this change solved all of his problems. Also if you are using 2d mapping, wouldn't it be more efficient to just update the tiles you are about to walk into/ are in?
Saveron




PostPosted: Sun Feb 18, 2007 5:43 pm   Post subject: Re: Sprites - Is There Another Way?

I used photoshop to save the pictures and I did a bit of testing. I managed to make more of the pixels transparent but some are still not pure white, but they are off by just 1 or two on the RGB scale, one could be 254,255,254. I tink a way you can fix this is instead of making only one RGB colour transparent, make several of them transparent.

For example make everything from 250,250,250 to 255,255,255 transparent. This should fix the transparancy problem, but it would require the creator to have photoshop or similar to save the jpg at the maximum quality, paint will not work.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Tutorials
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 2  [ 25 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: