Animation Problem
Author |
Message |
Sporg
|
Posted: Wed May 04, 2005 7:55 am Post subject: Animation Problem |
|
|
hello everybody, im in a programming class at school and we use turing. I have an assignment im doing in class. all i have to do is make a small program that uses animation. So im making a program where there is a cannon at the bottom of the picture that moves side to side, and shoots a cannon ball. I havnt gotten to the cannon ball yet. however im having a problem with the cannon, when it moves side to side it leaves streaks and i have no idea how to get rid of them.
code: | setscreen("graphics:600,400")%Sets screen size
var background : int %Variable for background
background := Pic.FileNew ("background.jpg") %Calls the photo used for background
Pic.Draw (background,0,0, picUnderMerge) %Displays photo in window
process CannonControl
var Cannon : int := Pic.FileNew ("Cannon.jpg")
Pic.SetTransparentColour(Cannon, white)
var x,y :int :=0
var hit : boolean := false
loop
var press :array char of boolean
Pic.Draw(Cannon,x,y,picMerge)
Pic.SetTransparentColour(Cannon, white)
Input.KeyDown (press)
if press (KEY_RIGHT_ARROW) then
Pic.Draw(Cannon,x+2,y,picMerge)
View.Update
x+=1
elsif press (KEY_LEFT_ARROW) then
Pic.Draw(Cannon,x-2,y,picMerge)
View.Update
x-=1
end if
end loop
end CannonControl
%Main Program
fork CannonControl
|
|
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
jamonathin

|
Posted: Wed May 04, 2005 8:13 am Post subject: (No subject) |
|
|
That programs a mess yo. Ok, first of all, you need to post pictures with your file (In a ZIP or RAR file).
Now, DO NOT USE PROCESSES. You dont even need it. For the most part, processes are only good for playin .wavs or .mp3s. Just use a procedure.
White is turing's default transparency color, so you dont need to use that command. And even If you were changing it to green or something, you only need to do it once, not every time through the loop. Same thing with your button var, only once in loop.
You only need to draw your cannon once. And dont put x + 2 and x - 2 in the Pic.Draw, because then it will look wierd when you move. Just have the x values +- 1, and that will be enough.
In order to use View.Update, you must have offscreenonly in your setscreen options.
Quote: setscreen ("graphics:600,400,offscreenonly")
Also, I recommend your "cannon" picture to be .bmp because .jpg means it wont be as clean, the program that made it .jpg will try to make it look better and you'll have unnecessary blocks of different colors everywhere. Open it back up in paint, clean out the grey blocks or whatever and save it as .bmp.
This is the format your loop should be in.
Clean up those things and reply back if there's still a problem  |
|
|
|
|
 |
Sporg
|
Posted: Wed May 04, 2005 4:25 pm Post subject: Thanks |
|
|
thanks for the help, i was able to fix my program, and i will take your advice with attaching my program as a zip next time. |
|
|
|
|
 |
|
|