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

Username:   Password: 
 RegisterRegister   
 Seeking advice to solve a flickering problem and picMerge not working...
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Xianxin




PostPosted: Tue Jan 23, 2007 6:02 pm   Post subject: Seeking advice to solve a flickering problem and picMerge not working...

Here is my coding for my program

code:

setscreen ("offscreenonly,graphics:768;340")
var background : int
background := Pic.FileNew ("IceCave.jpg")

var chars : array char of boolean
var blueatk1, blueatk2, blueatk3, blueatk4 : int %Attack 1
var bluestab1, bluestab2, bluestab3, bluestab4 : int %Attack 2
var bluejump1 : int % Jump
var bluestance1, bluestand1 : int % Stances
var bluewalk1, bluewalk2, bluewalk3, bluewalk4 : int % Walk
var bluewalk1r, bluewalk2r, bluewalk3r, bluewalk4r : int % Reverse Walk
var bluedef1, bluedef2, bluedef3, bluedef4, bluedef5, bluedef6, bluedef7, bluedef8 : int % Defence
var batk1 : string := "blueatk1.jpg"
var batk2 : string := "blueatk2.jpg"
var batk3 : string := "blueatk3e.jpg"
var batk4 : string := "blueatk4e.jpg"
var bstab1 : string := "bluestab1.jpg"
var bstab2 : string := "bluestab2.jpg"
var bstab3 : string := "bluestab3.jpg"
var bstab4 : string := "bluestab4e.jpg"
var bjump1 : string := "bluejump1.jpg"
var bstance1 : string := "bluestance1.jpg"
var bstand1 : string := "bluestand1.jpg"
var bwalk1 : string := "bluewalk1.jpg"
var bwalk2 : string := "bluewalk2.jpg"
var bwalk3 : string := "bluewalk3.jpg"
var bwalk4 : string := "bluewalk4.jpg"
var bwalk1r : string := "bluewalk1r.jpg"
var bwalk2r : string := "bluewalk2r.jpg"
var bwalk3r : string := "bluewalk3r.jpg"
var bwalk4r : string := "bluewalk4r.jpg"
var bdef1 : string := "bluedef1.jpg"
var bdef2 : string := "bluedef2.jpg"
var bdef3 : string := "bluedef3.jpg"
var bdef4 : string := "bluedef4.jpg"
var bdef5 : string := "bluedef5.jpg"
var bdef6 : string := "bluedef6.jpg"
var bdef7 : string := "bluedef7.jpg"
var bdef8 : string := "bluedef8.jpg"
blueatk1 := Pic.FileNew (batk1)
blueatk2 := Pic.FileNew (batk2)
blueatk3 := Pic.FileNew (batk3)
blueatk4 := Pic.FileNew (batk4)
bluestab1 := Pic.FileNew (bstab1)
bluestab2 := Pic.FileNew (bstab2)
bluestab3 := Pic.FileNew (bstab3)
bluestab4 := Pic.FileNew (bstab4)
bluejump1 := Pic.FileNew (bjump1)
bluestance1 := Pic.FileNew (bstance1)
bluestand1 := Pic.FileNew (bstand1)
bluewalk1 := Pic.FileNew (bwalk1)
bluewalk2 := Pic.FileNew (bwalk2)
bluewalk3 := Pic.FileNew (bwalk3)
bluewalk4 := Pic.FileNew (bwalk4)
bluewalk1r := Pic.FileNew (bwalk1r)
bluewalk2r := Pic.FileNew (bwalk2r)
bluewalk3r := Pic.FileNew (bwalk3r)
bluewalk4r := Pic.FileNew (bwalk4r)
bluedef1 := Pic.FileNew (bdef1)
bluedef2 := Pic.FileNew (bdef2)
bluedef3 := Pic.FileNew (bdef3)
bluedef4 := Pic.FileNew (bdef4)
bluedef5 := Pic.FileNew (bdef5)
bluedef6 := Pic.FileNew (bdef6)
bluedef7 := Pic.FileNew (bdef7)
bluedef8 := Pic.FileNew (bdef8)
var x := 550
var y := 50

proc knight
    Input.KeyDown (chars)
    if chars ('o') then     % Up Jump
        for a : 1 .. 15
            y := y + 7
            View.Update
            cls
            delay (10)
            Pic.Draw (background, 0, 0, picMerge)
            Pic.Draw (bluejump1, x, y, picMerge)
        end for
        for a : 1 .. 15     % Down Sequence
            y := y - 7
            View.Update
            cls
            delay (10)
            Pic.Draw (background, 0, 0, picMerge)
            Pic.Draw (bluejump1, x, y, picMerge)
        end for
        View.Update
        Pic.Draw (bluestand1, x + 10, y - 7, picMerge)
    elsif chars ('p') then     % Backward Jump
        for a : 1 .. 15
            y := y + 7
            x := x + 3
            View.Update
            cls
            delay (10)
            Pic.Draw (background, 0, 0, picMerge)
            Pic.Draw (bluejump1, x, y, picMerge)
        end for
        for a : 1 .. 15     % Down Sequence
            y := y - 7
            x := x + 2
            View.Update
            cls
            delay (10)
            Pic.Draw (background, 0, 0, picMerge)
            Pic.Draw (bluejump1, x, y, picMerge)
        end for
        View.Update
        Pic.Draw (bluestand1, x + 10, y - 7, picMerge)
    elsif chars ('i') then     % Forward Jump
        for a : 1 .. 15
            y := y + 7
            x := x - 3
            View.Update
            cls
            delay (10)
            Pic.Draw (background, 0, 0, picMerge)
            Pic.Draw (bluejump1, x, y, picMerge)
        end for
        for a : 1 .. 15     % Down Sequence
            y := y - 7
            x := x - 2
            View.Update
            cls
            delay (10)
            Pic.Draw (background, 0, 0, picMerge)
            Pic.Draw (bluejump1, x, y, picMerge)
        end for
        View.Update
        Pic.Draw (bluestand1, x + 10, y - 7, picMerge)
        % Walking Forwards for the Blue Knight
    elsif chars ('k') then
        x := x - 7
        View.Update
        cls
        delay (40)
        Pic.Draw (background, 0, 0, picMerge)
        Pic.Draw (bluewalk1, x + 10, y - 5, picMerge)
        x := x - 7
        View.Update
        cls
        delay (40)
        Pic.Draw (background, 0, 0, picMerge)
        Pic.Draw (bluewalk2, x + 10, y - 5, picMerge)
        x := x - 7
        View.Update
        cls
        delay (40)
        Pic.Draw (background, 0, 0, picMerge)
        Pic.Draw (bluewalk3, x + 10, y - 5, picMerge)
        x := x - 7
        View.Update
        cls
        delay (40)
        Pic.Draw (background, 0, 0, picMerge)
        Pic.Draw (bluewalk4, x + 10, y - 5, picMerge)
        % Picture set is repeated as Draw since for statements cancel P2's key inputs
        View.Update
        cls
        delay (40)
        Pic.Draw (background, 0, 0, picMerge)
        Pic.Draw (bluewalk1, x + 10, y - 5, picMerge)
        x := x - 7
        View.Update
        cls
        delay (40)
        Pic.Draw (background, 0, 0, picMerge)
        Pic.Draw (bluewalk2, x + 10, y - 5, picMerge)
        x := x - 7
        View.Update
        cls
        delay (40)
        Pic.Draw (background, 0, 0, picMerge)
        Pic.Draw (bluewalk3, x + 10, y - 5, picMerge)
        x := x - 7
        View.Update
        cls
        delay (40)
        Pic.Draw (background, 0, 0, picMerge)
        Pic.Draw (bluewalk4, x + 10, y - 5, picMerge)
        View.Update
        Pic.Draw (bluestand1, x + 10, y - 7, picMerge)
        % Walking Backwards for the Blue Knight

    elsif chars (';') then
        x := x + 7
        View.Update
        cls
        delay (40)
        Pic.Draw (background, 0, 0, picMerge)
        Pic.Draw (bluewalk4r, x + 10, y - 5, picMerge)
        x := x + 7
        View.Update
        cls
        delay (40)
        Pic.Draw (background, 0, 0, picMerge)
        Pic.Draw (bluewalk3r, x + 10, y - 5, picMerge)
        x := x + 7

        View.Update
        cls
        delay (40)
        Pic.Draw (background, 0, 0, picMerge)
        Pic.Draw (bluewalk2r, x + 10, y - 5, picMerge)
        x := x + 7
        View.Update
        cls
        delay (40)
        % Pictures are repeated as Draw since for statements cancel P2's key inputs
        Pic.Draw (background, 0, 0, picMerge)
        Pic.Draw (bluewalk1r, x + 10, y - 5, picMerge)
        x := x + 7
        View.Update
        cls
        delay (40)
        Pic.Draw (background, 0, 0, picMerge)
        Pic.Draw (bluewalk4r, x + 10, y - 5, picMerge)
        x := x + 7
        View.Update
        cls
        delay (40)
        Pic.Draw (background, 0, 0, picMerge)
        Pic.Draw (bluewalk3r, x + 10, y - 5, picMerge)
        x := x + 7
        View.Update
        cls
        delay (40)
        Pic.Draw (background, 0, 0, picMerge)
        Pic.Draw (bluewalk2r, x + 10, y - 5, picMerge)
        x := x + 7
        View.Update
        cls
        delay (40)
        Pic.Draw (background, 0, 0, picMerge)
        Pic.Draw (bluewalk1r, x + 10, y - 5, picMerge)
        View.Update
        Pic.Draw (bluestand1, x + 10, y - 7, picMerge)
    elsif chars ('l') then     % Defence Sequence
        View.Update
        cls
        delay (75)
        Pic.Draw (background, 0, 0, picMerge)
        Pic.Draw (bluedef1, x - 20, y - 10, picMerge)
        View.Update
        cls
        delay (75)
        Pic.Draw (background, 0, 0, picMerge)
        Pic.Draw (bluedef2, x - 20, y - 10, picMerge)
        View.Update
        cls
        delay (75)
        Pic.Draw (background, 0, 0, picMerge)
        Pic.Draw (bluedef3, x - 20, y - 10, picMerge)
        View.Update
        cls
        delay (75)
        Pic.Draw (background, 0, 0, picMerge)
        Pic.Draw (bluedef4, x - 20, y - 10, picMerge)
        View.Update
        cls
        delay (75)
        Pic.Draw (background, 0, 0, picMerge)
        Pic.Draw (bluedef5, x - 20, y - 10, picMerge)
        View.Update
        cls
        delay (800)
        Pic.Draw (background, 0, 0, picMerge)
        Pic.Draw (bluedef6, x - 20, y - 10, picMerge)
        View.Update
        cls
        delay (100)
        Pic.Draw (background, 0, 0, picMerge)
        Pic.Draw (bluedef7, x - 20, y - 10, picMerge)
        View.Update
        cls
        delay (100)
        Pic.Draw (background, 0, 0, picMerge)
        Pic.Draw (bluedef8, x - 20, y - 10, picMerge)
        View.Update
        Pic.Draw (bluestand1, x + 10, y - 7, picMerge)
    elsif chars ('m') then     % Power Smash
        x := x - 2
        View.Update
        cls
        delay (100)
        Pic.Draw (background, 0, 0, picMerge)
        Pic.Draw (blueatk1, x - 40, y, picMerge)
        x := x - 5
        View.Update
        cls
        delay (100)
        Pic.Draw (background, 0, 0, picMerge)
        Pic.Draw (blueatk2, x - 40, y, picMerge)
        x := x - 5
        View.Update
        cls
        delay (100)
        Pic.Draw (background, 0, 0, picMerge)
        Pic.Draw (blueatk3, x, y + 15, picMerge)
        x := x - 5
        View.Update
        cls
        delay (150)
        Pic.Draw (background, 0, 0, picMerge)
        Pic.Draw (blueatk4, x - 145, y - 35, picMerge)
        x := x - 5
        View.Update
        cls
        delay (300)
        Pic.Draw (background, 0, 0, picMerge)
        Pic.Draw (bluestance1, x - 15, y - 3, picMerge)
        View.Update
        cls
        delay (400)
        View.Update
        Pic.Draw (bluestand1, x + 10, y - 7, picMerge)
    elsif chars ('n') then     % Stab Attack
        x := x - 2
        View.Update
        cls
        delay (100)
        Pic.Draw (background, 0, 0, picMerge)
        Pic.Draw (bluestab1, x - 40, y, picMerge)
        x := x - 5
        View.Update
        cls
        delay (100)
        Pic.Draw (background, 0, 0, picMerge)
        Pic.Draw (bluestab2, x - 40, y, picMerge)
        x := x - 5
        View.Update
        cls
        delay (100)
        Pic.Draw (background, 0, 0, picMerge)
        Pic.Draw (bluestab3, x - 10, y, picMerge)
        x := x - 5
        View.Update
        cls
        delay (100)
        Pic.Draw (background, 0, 0, picMerge)
        Pic.Draw (bluestab4, x - 145, y - 15, picMerge)
        x := x - 5
        View.Update
        cls
        delay (150)
        Pic.Draw (background, 0, 0, picMerge)
        Pic.Draw (bluestance1, x - 15, y - 3, picMerge)
        View.Update
        cls
        delay (200)
        View.Update
        Pic.Draw (bluestand1, x + 10, y - 7, picMerge)
    end if
    View.Update
    Pic.Draw (bluestand1, x + 10, y - 7, picMerge)
end knight

loop
    View.Update
    cls
    Pic.Draw (background, 0, 0, picMerge)
    knight
end loop


The background stays, but the character still flickers when it's just standing. Also, the picMerge command isn't working since there's still white stuff around the image. I also tried using arrays to assign the pictures, but it didn't work. What suggestions can you guys give me? Thanks!
Sponsor
Sponsor
Sponsor
sponsor
CodeMonkey2000




PostPosted: Tue Jan 23, 2007 7:56 pm   Post subject: RE:Seeking advice to solve a flickering problem and picMerge not working...

can you please include the pictures?
Xianxin




PostPosted: Tue Jan 23, 2007 8:12 pm   Post subject: Re: Seeking advice to solve a flickering problem and picMerge not working...

OKay, I have taken your request into accounting and I've sent you the files through PM. Thanks for all your help!
CodeMonkey2000




PostPosted: Tue Jan 23, 2007 8:26 pm   Post subject: RE:Seeking advice to solve a flickering problem and picMerge not working...

to get rid of the flicker problem, just remove the Pic.Draw (background, 0, 0, picMerge) in the main loop. As for the problem with pic.merge, the picture isnt exactly white. go in to ms paint and fill all those gaps with white. It's painfal, but it is the only way. Like I said before, get rid of the for loops in the knight procedure. Also you should really use arrays, that would cut down on code, and make it MUCH easier to mange.
Xianxin




PostPosted: Tue Jan 23, 2007 8:44 pm   Post subject: Re: Seeking advice to solve a flickering problem and picMerge not working...

Okay, but is there a way to set a background into the image without putting it in the main loop? My friend told me to do that and it obviously isn't working... Thanks for your help!

EDIT: My partner and I decided to use his images (no Paint editing required) to make a 1 player game since the 2nd player is not working well for us
CodeMonkey2000




PostPosted: Tue Jan 23, 2007 8:58 pm   Post subject: RE:Seeking advice to solve a flickering problem and picMerge not working...

What do you mean by setting the background into the image?
Xianxin




PostPosted: Tue Jan 23, 2007 9:05 pm   Post subject: Re: Seeking advice to solve a flickering problem and picMerge not working...

Well, like make it the background of the "arena" so it's always there. Kinda like colourback but an image instead. Thanks for your input
CodeMonkey2000




PostPosted: Tue Jan 23, 2007 9:27 pm   Post subject: Re: Seeking advice to solve a flickering problem and picMerge not working...

You could use predefiened moduels like BSprites (can be foung here http://www.compsci.ca/v3/viewtopic.php?t=8108). There is an example included to show how it should be used. If you follow the way he moves the sprites, your code will be much cleaner, and easier to manage.
Sponsor
Sponsor
Sponsor
sponsor
Xianxin




PostPosted: Tue Jan 23, 2007 9:45 pm   Post subject: Re: Seeking advice to solve a flickering problem and picMerge not working...

Okay, thanks for your input. I don't want to avoid doing what my partner told me to do (draw the background before each Pic.Draw for the sprites)

EDIT: I heard that the Sprite commands are new and for the new versions of Turing, I don't think the school has the updated version nor do I know I have it =(
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  [ 9 Posts ]
Jump to:   


Style:  
Search: