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

Username:   Password: 
 RegisterRegister   
 Scrolling Issue
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
johnnyrocks




PostPosted: Sun Jun 16, 2013 2:13 pm   Post subject: Scrolling Issue

What is it you are trying to achieve?
I'm trying to achieve vertical scrolling, I've looked up a few tutorials online and I tried to understand it in the best of my abilities, but I seem to get stumped here.


What is the problem you are having?
I'm trying to generate random pictures, and then have them fall down, with the vertical scrolling so that after I can have my character jump on the platform, while having a score. Any pointers are nice, thanks!


Describe what you have tried to solve this problem
I first used randint to randomly position the pictures everywhere, then I realized by doing that, it'll just disappear and it will probably go down, but keep on randomly generating. I tried to also create the for loop first then have it drop, but that didn't work either. I'm pretty stumped on this.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)

Turing:

setscreen ("graphics:800,600,nobuttonbar")
var plat := Pic.FileNew ("platform.bmp")
var platnum : int := 50
var scrollSpeed := 1
var GROUND_HEIGHT := 120
var platx, platy : int
%------------------SCROLLING-----------------
proc scroll
    GROUND_HEIGHT -= scrollSpeed
    % Pic.Draw (plat, platformx, platformy, picCopy)
    drawline (0, GROUND_HEIGHT, maxx, GROUND_HEIGHT, black)
end scroll
proc generate
    for i : 1 .. platnum
        randint (platx, 100, 760)
        randint (platy, 100, 760)
        Pic.Draw (plat, platx, platy, picMerge)
        platy -= scrollSpeed
    end for
end generate
setscreen ("offscreenonly")
loop
    scroll
    generate
    View.Update
    delay (20)
    cls
end loop



Please specify what version of Turing you are using
4.0.5
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Sun Jun 16, 2013 2:15 pm   Post subject: RE:Scrolling Issue

You need to have X and Y coordinates for every single object on the screen. You then want to have an offset, which is just an integer. When you draw your objects, use the coordinates (x, y-offset). To move objects down, simple increase the offset.
johnnyrocks




PostPosted: Sun Jun 16, 2013 2:19 pm   Post subject: Re: RE:Scrolling Issue

Insectoid @ Sun Jun 16, 2013 2:15 pm wrote:
You need to have X and Y coordinates for every single object on the screen. You then want to have an offset, which is just an integer. When you draw your objects, use the coordinates (x, y-offset). To move objects down, simple increase the offset.


So if I were to randomly generate the x and y position, I would have to find those x & Y positions I generated? Confused
johnnyrocks




PostPosted: Sun Jun 16, 2013 3:01 pm   Post subject: Re: Scrolling Issue

Turing:

setscreen ("graphics:800,600,nobuttonbar")
var plat := Pic.FileNew ("platform.bmp")
var scrollSpeed := 1
var GROUND_HEIGHT := 120
var platx, platy : array 1 .. 50 of int
%------------------SCROLLING-----------------
proc scroll
    GROUND_HEIGHT -= scrollSpeed
    drawline (0, GROUND_HEIGHT, maxx, GROUND_HEIGHT, black)
end scroll

setscreen ("offscreenonly")
loop
    for i : 1 .. 50
        randint (platx (i), 120, 700)
        randint (platy (i), 120, 700)
    end for
    loop
        scroll
        for i : 1 .. 50
            Pic.Draw (plat, platx (i), platy (i), picMerge)
            platy (i) -= scrollSpeed
        end for
        View.Update
        delay (20)
        cls
    end loop
end loop


Okay I got it to work! Thank you!!
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  [ 4 Posts ]
Jump to:   


Style:  
Search: