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

Username:   Password: 
 RegisterRegister   
 ~~!Moving Background!~~
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
biggmak




PostPosted: Fri Mar 21, 2003 7:05 pm   Post subject: ~~!Moving Background!~~

im trying to make this game where this character walks around but i cant get the background to move over to the right by, let say five, so i set up an if statement for it and this is what i got...
code:


var win : int := Window.Open ("fullscreen")
View.Set ("graphics:max;max")
var ruine : int := Pic.FileNew ("Ruine.bmp")
var u1 : int := Pic.FileNew ("u1.bmp")
var u2 : int := Pic.FileNew ("u2.bmp")
var u3 : int := Pic.FileNew ("u3.bmp")
var r1 : int := Pic.FileNew ("r1.bmp")
var r2 : int := Pic.FileNew ("r2.bmp")
var r3 : int := Pic.FileNew ("r3.bmp")
var l1 : int := Pic.FileNew ("l1.bmp")
var l2 : int := Pic.FileNew ("l2.bmp")
var l3 : int := Pic.FileNew ("l3.bmp")
var d1 : int := Pic.FileNew ("d1.bmp")
var d2 : int := Pic.FileNew ("d2.bmp")
var d3 : int := Pic.FileNew ("d3.bmp")

x := 400       %character
y := 250        %character
xruine := 0        %background
yruine := 0       %background

loop

    View.Update
    Input.KeyDown (chars)
    Pic.Draw (ruine, xruine, yruine, 0) %backround picture


    if chars (KEY_UP_ARROW) then

        y := y + 10
        Pic.Draw (u1, x, y, 0)

        delay (200)
        View.Update
        cls
        y := y + 10
        Pic.Draw (u2, x, y, 0)

        delay (200)
        View.Update
        cls
        y := y + 10
        Pic.Draw (u3, x, y, 0)

        delay (200)
        View.Update
        cls
        y := y + 10
        Pic.Draw (u2, x, y, 0)

        delay (200)
        View.Update
        cls

    end if
    if chars (KEY_RIGHT_ARROW) then
        cls
        x := x + 10
        Pic.Draw (r1, x, y, 0)
        View.Update
        delay (200)
        cls
        x := x + 10
        Pic.Draw (r2, x, y, 0)
        View.Update
        delay (200)
        cls
        x := x + 10
        Pic.Draw (r3, x, y, 0)
        View.Update
        delay (200)
        cls
        x := x + 10
        Pic.Draw (r2, x, y, 0)
        View.Update
        delay (200)
        cls

    end if
    if chars (KEY_LEFT_ARROW) then
        cls
        x := x - 10
        Pic.Draw (l1, x, y, 0)
        View.Update
        delay (200)
        cls
        x := x - 10
        Pic.Draw (l2, x, y, 0)
        View.Update
        delay (200)
        cls
        x := x - 10
        Pic.Draw (l3, x, y, 0)
        View.Update
        delay (200)
        cls
        x := x - 10
        Pic.Draw (l2, x, y, 0)
        View.Update
        delay (200)
        cls
    end if
    if chars (KEY_DOWN_ARROW) then
        cls
        y := y - 10
        Pic.Draw (d1, x, y, 0)
        View.Update
        delay (200)
        cls
        y := y - 10
        Pic.Draw (d2, x, y, 0)
        View.Update
        delay (200)
        cls
        y := y - 10
        Pic.Draw (d3, x, y, 0)
        View.Update
        delay (200)
        cls
        y := y - 10
        Pic.Draw (d2, x, y, 0)
        View.Update
        delay (200)
        cls
    end if
    delay (10)
    if x <= 50 then
        x := x + 40
    elsif y <= 50 then
        y := y + 40
    end if

 %RIGHT HERE IS MY IF STATEMENT
    if x >= 500 then
        xruine := xruine - 10
    end if
end loop

This is not working correctly because the background constantly keeps on moving to the left by 10 as long as the guy is past 500. I need to make it move only when the character moves further to the right (past 500), and need it to stop when the character stops(past 500).
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Fri Mar 21, 2003 7:11 pm   Post subject: (No subject)

Crying or Very sad Why cant you people just read the tutorials first and see if there's anything there?

its called "MOVING BACKGROUND" - http://www.compsci.ca/bbs/viewtopic.php?t=193
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Delta




PostPosted: Fri Mar 21, 2003 7:24 pm   Post subject: (No subject)

hahahahahahaha I WIN! wait no I don't this post was useless
biggmak




PostPosted: Sat Mar 22, 2003 3:14 pm   Post subject: (No subject)

i read that tutorial but that only works if i have one character pic, but i have a total of 12. so do i have to set x and y variables for each picture?
Asok




PostPosted: Sat Mar 22, 2003 3:59 pm   Post subject: (No subject)

anything that is not the background should be on a sperate layer.
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  [ 5 Posts ]
Jump to:   


Style:  
Search: