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

Username:   Password: 
 RegisterRegister   
 Massive GIF Troubles
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
DKNiGHTX




PostPosted: Tue Nov 21, 2006 8:09 pm   Post subject: 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:

code:
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:

code:
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:

Posted Image, might have been reduced in size. Click Image to view fullscreen.
Sponsor
Sponsor
Sponsor
sponsor
Clayton




PostPosted: Tue Nov 21, 2006 11:26 pm   Post subject: (No subject)

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




PostPosted: Wed Nov 22, 2006 3:05 pm   Post subject: (No subject)

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 Razz)
Clayton




PostPosted: Wed Nov 22, 2006 5:22 pm   Post subject: (No subject)

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




PostPosted: Wed Nov 22, 2006 9:41 pm   Post subject: (No subject)

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 Wink.
Clayton




PostPosted: Wed Nov 22, 2006 9:49 pm   Post subject: (No subject)

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: This will explain better than I can.
ericfourfour




PostPosted: Wed Nov 22, 2006 10:48 pm   Post subject: (No subject)

Here is an example of how it would look.
code:
main loop
    think (update variables)
    render (draw)
DKNiGHTX




PostPosted: Thu Nov 23, 2006 4:40 pm   Post subject: (No subject)

Oh I see. Well, I implemented that in my main game, and it works flawlessly Smile I'm still using processes for sound however (Unless there is a way to do that as well, then Surprised [Looping by the way])
Sponsor
Sponsor
Sponsor
sponsor
ericfourfour




PostPosted: Thu Nov 23, 2006 4:48 pm   Post subject: (No subject)

DKNiGHTX wrote:
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]




PostPosted: Thu Nov 23, 2006 5:03 pm   Post subject: (No subject)

Freakman wrote:
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




PostPosted: Thu Nov 23, 2006 5:34 pm   Post subject: (No subject)

DKNiGHTX wrote:
Oh I see. Well, I implemented that in my main game, and it works flawlessly Smile I'm still using processes for sound however (Unless there is a way to do that as well, then Surprised [Looping by the way])


take a look at Music.PlayFileReturn, and Music.PlayFileLoop, after that, take a gander at the Turing Walkthrough.

[Gandalf] wrote:

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....
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 11 Posts ]
Jump to:   


Style:  
Search: