
-----------------------------------
DKNiGHTX
Tue Nov 21, 2006 8:09 pm

Massive GIF Troubles
-----------------------------------
I'm working on my end-of-the-year project for Grade 10, a game where you hunt birds.  I'm to use sprites, seeing as they would work best in this situation, but the problem I am running into is that the animation works on only 1 bird GIF I've found (which happens to be very ugly;go figure).  All the other GIF animations I try to use, Turing decides to fail and output static and noisy images.  The first frame displays OK, but the others do not.  This is the code that I'm using to play them:

process menuEffects ()

    loop

        var delayTime : int
        var randY := Rand.Int (0, maxy)
        var randX := Rand.Int (-maxx, 0)
        var Frames := Pic.Frames (MENU_BIRD)
        var Pics : array 1 .. Frames of int
        Pic.FileNewFrames (MENU_BIRD, Pics, delayTime)
        var ID := Sprite.New (Pics (1))
        Sprite.SetPosition (ID, randX, randY, true)
        Sprite.Show (ID)

        for i : 8 .. maxx - randX + Pic.Width (Pic.FileNew (MENU_BIRD)) by 8

            if (menuProcess) then
                Sprite.Hide (ID)
                exit when (menuProcess)
            else
                Sprite.Animate (ID, Pics ((i div 8) mod Frames + 1), randX + i, randY, true)
                delay (50)
            end if

        end for

        for i : 1 .. Frames

            Pic.Free (Pics (i))

        end for

        Sprite.Free (ID)

        exit when (menuProcess)

    end loop

end menuEffects

Called by:

proc menu_Start ()

    for i : 1 .. 5

        fork menuEffects ()

    end for
    menuProcess := false

    var leaveMenu := false

    loop

        var x, y, b := 0
        Mouse.Where (x, y, b)

        %Mouse over button effects
        box_MouseOverEffect (PLAY_BOX, 29, white)
        box_MouseOverEffect (SCORE_BOX, 29, white)

        %Click event handlers
        if (b = 1) then
            if (box_MouseOver (PLAY_BOX)) then %Clicked Play!
                %Yeah, yeah, yeah.  I'll get to it ;)
            elsif (box_MouseOver (SCORE_BOX)) then     %Clicked High Scores
                highscore_DrawForm ()
                menu_Draw ()
            end if
        end if


        %Leave menu
        if (leaveMenu) then
            Input.Flush ()
        end if
        exit when (leaveMenu)

        Time.DelaySinceLast (20)

    end loop

end menu_Start

The problem:

http://img245.imageshack.us/img245/9813/asdasdascx0.jpg

-----------------------------------
Clayton
Tue Nov 21, 2006 11:26 pm


-----------------------------------
Well seeing as 4.0.5 doesn't support GIFs, I'm going to have to assume that the problem lies within your use of processes. Really, get rid of them, find some other way to incorporate your "menuBird" code into your menu procedure.

-----------------------------------
DKNiGHTX
Wed Nov 22, 2006 3:05 pm


-----------------------------------
I'm using 4.1 and the process seems to work fine with my other bird (Which is a flamingo, so I can't use it :P)

-----------------------------------
Clayton
Wed Nov 22, 2006 5:22 pm


-----------------------------------
well then, there must be something wrong with the pictures when they get read into your animation.

On the note of processes, WHY? You don't need them in this case, and will only serve to screw you up in some other point in time. Think about using procedures integrated into your mainline to avoid trouble with processes.

-----------------------------------
DKNiGHTX
Wed Nov 22, 2006 9:41 pm


-----------------------------------
Ok, barely any GIFs work (Encoding parameter?) so I've decided not to use them.  Oh well.  As for the process, I prefer it; it allows me to update two things at the same time ;).

-----------------------------------
Clayton
Wed Nov 22, 2006 9:49 pm


-----------------------------------
Actually, it doesn't, unless you have more than one CPU, which i doubt. Processes, or "threading" in Turing is horribly implemented, and you are better off just spacing your actions throughout a mainline than running multiple things "concurrently".

NOTE: [url=http://compsci.ca/v2/viewtopic.php?t=7842]This will explain better than I can.

-----------------------------------
ericfourfour
Wed Nov 22, 2006 10:48 pm


-----------------------------------
Here is an example of how it would look.
main loop
    think (update variables)
    render (draw)

-----------------------------------
DKNiGHTX
Thu Nov 23, 2006 4:40 pm


-----------------------------------
Oh I see.  Well, I implemented that in my main game, and it works flawlessly :)  I'm still using processes for sound however (Unless there is a way to do that as well, then :o [Looping by the way])

-----------------------------------
ericfourfour
Thu Nov 23, 2006 4:48 pm


-----------------------------------
I'm still using processes for sound however
You are right. There is no other way if you are doing sounds. If you are doing music however, I think there is a procedure that plays the music continuously so you do not have write a process.

-----------------------------------
[Gandalf]
Thu Nov 23, 2006 5:03 pm


-----------------------------------
Actually, it doesn't, unless you have more than one CPU, which i doubt. Processes, or "threading" in Turing is horribly implemented, and you are better off just spacing your actions throughout a mainline than running multiple things "concurrently".
Somehow I doubt Turing's processes are made in such a way as to take advantage of multi core CPUs.

-----------------------------------
Clayton
Thu Nov 23, 2006 5:34 pm


-----------------------------------
Oh I see.  Well, I implemented that in my main game, and it works flawlessly :)  I'm still using processes for sound however (Unless there is a way to do that as well, then :o 

take a look at Music.PlayFileReturn, and Music.PlayFileLoop, after that, take a gander at the Turing Walkthrough.

"]
Somehow I doubt Turing's processes are made in such a way as to take advantage of multi core CPUs.


Well I ran a test on my friends dual-core desktop and it seemed that the processes ran more in line with each other, although still not the greatest. Perhaps I was just getting lucky however....
