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

Username:   Password: 
 RegisterRegister   
 images flikering =view.update ,cls
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Kyle




PostPosted: Sat Apr 23, 2005 9:25 pm   Post subject: images flikering =view.update ,cls

ok iv done this before but along time ago and i had to restore my computer so i lost how to do this Confused. im tring to make a helicopter game were u have to dodge the missles that randomly come at you. i have one hilicopter but two pictures and i have 2 missle pictures (so that the flame moves) ok so when i use the keys to move my heliopter the misle flikers a lot, i belive this is because of the cls. i tryed to put in View.Update but i think im doing it all wrong. i tryed removing some cls but then it leaves a helicopter trial.

{heres my code}
code:

View.Set ("offscreenonly:600;1000")
setscreen ("graphics:1000;500,position:middle;centre,nobuttonbar,title:CHOPPER DROPPER")
locatexy (0, maxy div 2)

cls
var x, y : int
x := 10
y := 65

proc chopperright
    var chopper1 : int := Pic.FileNew ("chopperlevel1.bmp")
    Pic.Draw (chopper1, x, y, 0)
    delay (20)
    View.Update
    Pic.Free (chopper1)
cls
    var chopper2 : int := Pic.FileNew ("chopperlevel2.bmp")
    Pic.Draw (chopper2, x, y, 0)
    delay (20)
    View.Update
    Pic.Free (chopper2)
cls
    var chopper3 : int := Pic.FileNew ("chopperlevel1.bmp")
    Pic.Draw (chopper3, x, y, 0)
    delay (20)
    View.Update
    Pic.Free (chopper3)
end chopperright
proc chopperup
    var chopper4 : int := Pic.FileNew ("chopperlevel1.bmp")
    Pic.Draw (chopper4, x, y, 0)
    delay (20)
    View.Update
    Pic.Free (chopper4)
cls
    var chopper5 : int := Pic.FileNew ("chopperlevel2.bmp")
    Pic.Draw (chopper5, x, y, 0)
    delay (20)
    View.Update
    Pic.Free (chopper5)
cls
    var chopper6 : int := Pic.FileNew ("chopperlevel1.bmp")
    Pic.Draw (chopper6, x, y, 0)
    delay (20)
    View.Update
    Pic.Free (chopper6)
end chopperup
proc chopperleft
    var chopper7 : int := Pic.FileNew ("chopperlevel1.bmp")
    Pic.Draw (chopper7, x, y, 0)
    delay (20)
    View.Update
    Pic.Free (chopper7)
cls
    var chopper8 : int := Pic.FileNew ("chopperlevel2.bmp")
    Pic.Draw (chopper8, x, y, 0)
    delay (20)
    View.Update
    Pic.Free (chopper8)
cls
    var chopper9 : int := Pic.FileNew ("chopperlevel1.bmp")
    Pic.Draw (chopper9, x, y, 0)
    delay (20)
    View.Update
    Pic.Free (chopper9)
end chopperleft
proc chopperdown
    var chopper10 : int := Pic.FileNew ("chopperlevel1.bmp")
    Pic.Draw (chopper10, x, y, 0)
    delay (20)
    View.Update

    Pic.Free (chopper10)
cls
    var chopper11 : int := Pic.FileNew ("chopperlevel2.bmp")
    Pic.Draw (chopper11, x, y, 0)
    delay (20)
    View.Update
cls
    Pic.Free (chopper11)
    var chopper12 : int := Pic.FileNew ("chopperlevel1.bmp")
    Pic.Draw (chopper12, x, y, 0)
    delay (20)
    View.Update
    Pic.Free (chopper12)
end chopperdown
var chars : array char of boolean
loop
    Input.KeyDown (chars)

    if chars (KEY_UP_ARROW) then
        y := y + 10
    end if
    if chars (KEY_RIGHT_ARROW) then
        x := x + 10
    end if
    if chars (KEY_DOWN_ARROW) then
        y := y - 10
    end if
    if chars (KEY_LEFT_ARROW) then
        x := x - 10
    end if
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%LOWER WALL%%%%%%%%
    if y <= 40 then
        y := 60
    end if
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%TOP WALL%%%
    if y >= 300 then
        y := 60
    end if
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    if chars (KEY_RIGHT_ARROW) then     % right key starts here
        chopperright
    end if
    if chars (KEY_UP_ARROW) then     % up key starts here
        chopperup
    end if
    if chars (KEY_LEFT_ARROW) then     % my left key startes here
        chopperleft
    end if
    if chars (KEY_DOWN_ARROW) then  % DOWN key starts here
        chopperdown
       
    end if
    var bomb1 : int := Pic.FileNew ("bomb1.bmp")
    Pic.Draw (bomb1, 1, 1, 0)
    View.Update
    delay (1)
    Pic.Free (bomb1)


end loop %View. and delays were swiched



Chopper Dropper.rar
 Description:
Here the file with the pics so u can se what im talking about

Download
 Filename:  Chopper Dropper.rar
 Filesize:  28.45 KB
 Downloaded:  117 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Kyle




PostPosted: Sat Apr 23, 2005 11:34 pm   Post subject: (No subject)

I would like to Thank JonnyTightLips for Fixing my program.
Ok now i ran into another problem it says
:cannot allocate item. Out of id numbers (max 1000)
heres my new code
code:

View.Set ("offscreenonly")
setscreen ("graphics,position:middle;centre,nobuttonbar,title:CHOPPER DROPPER")
locatexy (0, maxy div 2)
var x, y : int
x := 10
y := 65
proc chopperright
    var chopper1 : int := Pic.FileNew ("chopperlevel1.bmp")
    Pic.Draw (chopper1, x, y, 0)
    delay (20)
    Pic.Free (chopper1)
    var chopper2 : int := Pic.FileNew ("chopperlevel2.bmp")
    Pic.Draw (chopper2, x, y, 0)
    delay (20)
    Pic.Free (chopper2)   
    var chopper3 : int := Pic.FileNew ("chopperlevel1.bmp")
    Pic.Draw (chopper3, x, y, 0)
    delay (20)
    Pic.Free (chopper3)
end chopperright
proc chopperup
    var chopper4 : int := Pic.FileNew ("chopperlevel1.bmp")
    Pic.Draw (chopper4, x, y, 0)
    delay (20)
    Pic.Free (chopper4)   
    var chopper5 : int := Pic.FileNew ("chopperlevel2.bmp")
    Pic.Draw (chopper5, x, y, 0)
    delay (20)
    Pic.Free (chopper5)   
    var chopper6 : int := Pic.FileNew ("chopperlevel1.bmp")
    Pic.Draw (chopper6, x, y, 0)
    delay (20)
    Pic.Free (chopper6)
end chopperup
proc chopperleft
    var chopper7 : int := Pic.FileNew ("chopperlevel1.bmp")
    Pic.Draw (chopper7, x, y, 0)
    delay (20)
    Pic.Free (chopper7)   
    var chopper8 : int := Pic.FileNew ("chopperlevel2.bmp")
    Pic.Draw (chopper8, x, y, 0)
    delay (20)
    Pic.Free (chopper8)   
    var chopper9 : int := Pic.FileNew ("chopperlevel1.bmp")
    Pic.Draw (chopper9, x, y, 0)
    delay (20)
    Pic.Free (chopper9)
end chopperleft
proc chopperdown
    var chopper10 : int := Pic.FileNew ("chopperlevel1.bmp")
    Pic.Draw (chopper10, x, y, 0)
    delay (20)
    Pic.Free (chopper10)   
    var chopper11 : int := Pic.FileNew ("chopperlevel2.bmp")
    Pic.Draw (chopper11, x, y, 0)
    delay (20)
    Pic.Free (chopper11)
    var chopper12 : int := Pic.FileNew ("chopperlevel1.bmp")
    Pic.Draw (chopper12, x, y, 0)
    delay (20)
    Pic.Free (chopper12)
end chopperdown
var chopper:int
var chars : array char of boolean
loop
cls
    Input.KeyDown (chars)

    if chars (KEY_UP_ARROW) then
        y := y + 10
    end if
    if chars (KEY_RIGHT_ARROW) then
        x := x + 10
    end if
    if chars (KEY_DOWN_ARROW) then
        y := y - 10
    end if
    if chars (KEY_LEFT_ARROW) then
        x := x - 10
    end if
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%LOWER WALL%%%%%%%%
    if y <= 40 then
        y := 60
    end if
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%TOP WALL%%%
    if y >= 300 then
        y := 60
    end if
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    if chars (KEY_RIGHT_ARROW) then     % right key starts here
        chopperright
    end if
    if chars (KEY_UP_ARROW) then     % up key starts here
        chopperup
    end if
    if chars (KEY_LEFT_ARROW) then     % my left key startes here
        chopperleft
    end if
    if chars (KEY_DOWN_ARROW) then  % DOWN key starts here
        chopperdown
        else       
    var normal : int := Pic.FileNew ("chopperlevel1.bmp")
    Pic.Draw (normal, x, y, 0)
    end if
    var bomb1 : int := Pic.FileNew ("bomb1.bmp")
    Pic.Draw (bomb1, 1, 1, 0)
    View.Update
    delay (1)
    Pic.Free (bomb1)
end loop %View. and delays were swiched

sory guys im not computer programing compatible
Bacchus




PostPosted: Sun Apr 24, 2005 12:08 am   Post subject: (No subject)

see where u keep making the Pic.FileNew ... you need to free those pictures, after you draw the picture just use
Pic.Free(picID:int)
Kyle




PostPosted: Sun Apr 24, 2005 8:05 am   Post subject: (No subject)

WoW thanks never would of thougt, hmm now i think i put the Pic.Free (chopper:int) but i cant find that code any more :s. oops. well thanks for the help your a life saver. Very Happy
jamonathin




PostPosted: Mon Apr 25, 2005 6:09 am   Post subject: (No subject)

It's good that your saving space by var pic :int := Pic.FIleNew("blah"), but unless you plan on reseting the variable to its default value every time, then just array your pics, and draw them seperately, without using Pic.FileNew everytime. and besides, it saves on time, if you were to use larger pictures.
Kyle




PostPosted: Mon Apr 25, 2005 4:38 pm   Post subject: (No subject)

exsplain? im a little slow at this.
Kyle




PostPosted: Mon Apr 25, 2005 4:54 pm   Post subject: (No subject)

ok nvm about that for now... wel yesterday i add a lot of cool stuff like a high score list and blowing up animation and ground but turuing did not save it? even after saving more then once. ok so i had to start all over. but the one thing that i can not fix is that there are 2 hillicopter images that are suposed to rotate threw each other (animation to make it look like its putting out smoke) exy "chopperlevel1.bmp" and "chopperlevel2.bmp" is there any way to do this with out making the flikering ? what am i doing wrong? Crying or Very sad
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  [ 7 Posts ]
Jump to:   


Style:  
Search: