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

Username:   Password: 
 RegisterRegister   
 [tutorial] Smooth Animation / Moving Background
Index -> Programming, Turing -> Turing Tutorials
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Tony




PostPosted: Fri Dec 20, 2002 4:17 pm   Post subject: [tutorial] Smooth Animation / Moving Background

This source file was send to me by Tom West, it is well commented and shows an interesting aspect of how you can smoothly move your images and how you can move your background image.

Note Works only in 4.x

Download the file attached.



AnimateBackground.zip
 Description:
download the source code example

Download
 Filename:  AnimateBackground.zip
 Filesize:  58.43 KB
 Downloaded:  3377 Time(s)

Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
FwuffyTheBunny




PostPosted: Wed Apr 09, 2003 10:07 am   Post subject: (No subject)

Word...
ShadowStorm




PostPosted: Fri Apr 25, 2003 9:43 am   Post subject: (No subject)

i'm quite new to Turing and i need a little help on this... the screen keeps on flickering and i can't get a clean/smooth animation

code:

setscreen ( "graphics:1000;700")
var x,y : int
var sky : int
var ship : int
var backgroundPictureWidth, backgroundPictureHeight : int
var backgroundPictureX, backgroundPictureY : int

ship := Pic.FileNew ("c5.bmp")
sky := Pic.FileNew ("sky.jpg")
backgroundPictureWidth := Pic.Width (sky)
backgroundPictureHeight := Pic.Height (sky)
backgroundPictureX := (backgroundPictureWidth - (maxx + 1)) div 2
backgroundPictureY := (backgroundPictureHeight - (maxy + 1)) div 2



x:=100
y:=100
var chars : array char of boolean
        loop
       
        Input.KeyDown (chars)
            if chars (KEY_UP_ARROW) then
                y:=y+15
            end if
            if chars (KEY_RIGHT_ARROW) then
                x:=x+15
            end if
            if chars (KEY_LEFT_ARROW) then
                x:=x-15
            end if
            if chars (KEY_DOWN_ARROW) then
                y:=y-15
            end if
            cls
            Pic.Draw (sky, -backgroundPictureX, -backgroundPictureY, picCopy)
            Pic.Draw(ship,x,y,picMerge)
            View.Update
        end loop


thanx..
Prince




PostPosted: Fri Apr 25, 2003 10:05 am   Post subject: (No subject)

does neone wanna b nice enuf to send me turing 4 seeing as how my skool doesnt wanna use it and theres no other way of me gettin it Smile... im missin out on too many great programs Sad
jamez




PostPosted: Fri Apr 25, 2003 1:05 pm   Post subject: (No subject)

code:


setscreen ( "graphics:1000;700,offscreenonly")
var x,y : int
var sky : int
var ship : int
var backgroundPictureWidth, backgroundPictureHeight : int
var backgroundPictureX, backgroundPictureY : int

ship := Pic.FileNew ("c5.bmp")
sky := Pic.FileNew ("sky.jpg")
backgroundPictureWidth := Pic.Width (sky)
backgroundPictureHeight := Pic.Height (sky)
backgroundPictureX := (backgroundPictureWidth - (maxx + 1)) div 2
backgroundPictureY := (backgroundPictureHeight - (maxy + 1)) div 2



x:=100
y:=100
var chars : array char of boolean
        loop
       
        Input.KeyDown (chars)
            if chars (KEY_UP_ARROW) then
                y:=y+15
            end if
            if chars (KEY_RIGHT_ARROW) then
                x:=x+15
            end if
            if chars (KEY_LEFT_ARROW) then
                x:=x-15
            end if
            if chars (KEY_DOWN_ARROW) then
                y:=y-15
            end if
View.Update
delay(10)
            cls
            Pic.Draw (sky, -backgroundPictureX, -backgroundPictureY, picCopy)
            Pic.Draw(ship,x,y,picMerge)
            View.Update
        end loop
ShadowStorm




PostPosted: Fri Apr 25, 2003 3:17 pm   Post subject: (No subject)

thanx alot man... Very Happy
hello




PostPosted: Sun May 11, 2003 2:40 pm   Post subject: Smooth Moving Background

This is what i did and it seems to work very well

u can start off with the background

have two pic ids both of the same picture or different pictures

then for each id have a separate y value so when its in the loop it can change

within the loop
draw the first picture in screen
and then draw the next picture off screen above the first one

then have both y values decrease or increase in the same amount

have two if statements checking for each y value
if the y value is less than the negative of the length of y of the window
set the y value to the positive of the y length of the window
and draw it
¿§¥Jåmës¥§¿




PostPosted: Mon Aug 25, 2003 1:13 pm   Post subject: (No subject)

jamez wut did you change in that program?
I can see that U addad the View.Update but I tryed that in my program and it didn't work Confused Do you have to hav all the Draw commaneds in bettewn the View.Update? because in my program there not does that matter?
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Mon Aug 25, 2003 4:49 pm   Post subject: (No subject)

you gotta have
code:

View.Set("offscreenonly")


at top of your program. Then:

loop
draw something
draw something else
..
View.Update
end loop
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
¿§¥Jåmës¥§¿




PostPosted: Mon Aug 25, 2003 5:35 pm   Post subject: Thanx

thanx alot that did the trick and I was right I had to put all my pics togeter in on spot. Thanx Tony!!! Very Happy 8)
HeTeRiC




PostPosted: Sat Nov 22, 2003 3:53 pm   Post subject: (No subject)

code:
if jupiterX - MARGIN < 0 then
        jupiterX := MARGIN
    elsif jupiterX + jupiterWidth > spaceWidth - MARGIN then
        jupiterX := spaceWidth - MARGIN - jupiterWidth
    end if


k i know that this tell the prog to move the background insted of the
jupiter pic, but how would you make the jupiter pic just stop??
(like hitting a wall in a game)
i've only been learning this fer like 7 hours so if this is extremly easy just call me stupid Wink
Tony




PostPosted: Sat Nov 22, 2003 3:58 pm   Post subject: (No subject)

to stop, you just don't allow the picture to move pass 0. such as
code:

var x:int := maxx

loop

Draw.Oval(x,100,5,5,red)
if x-5 < 0 then
%you've hit the wall, can't move pass
exit %exits loop
else
%otherwise still space in front to move
x:=x-5 %move 5 pixels to the left
delay(25)
end if

end loop
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
HeTeRiC




PostPosted: Sat Nov 22, 2003 4:17 pm   Post subject: (No subject)

Wow that was fast!
Thank You Burn
"one more thing!"
how do you stop it from moving past the point then still be able to move the object.
(move star around box but non let if exit box?)
i just need to know how to stop if from moving while still being able to controll it in other directions
thnaks again
HeTeRiC




PostPosted: Sat Nov 22, 2003 6:49 pm   Post subject: (No subject)

whoops!!
Found it somewhere else
nevermind
thanx anyways
bevoyleick




PostPosted: Wed Mar 17, 2004 9:59 am   Post subject: (No subject)

is there anyway that Turing can load faster?? i mean, i made this "space invaders" program for my comp sci proj, but as more and more aliens come down, the entire game just becomes slower and slower. (aliens are .jpg files)
Display posts from previous:   
   Index -> Programming, Turing -> Turing Tutorials
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 29 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: