
-----------------------------------
Badsniper
Mon May 09, 2011 5:37 pm

Scrolling
-----------------------------------
I have the movement in my program working perfectly, no I just need to do scrolling. But I don't know how I would scroll across a screen. If I could get an "outline" of how to do it, I could probably start.

Thanks!

-----------------------------------
Raknarg
Mon May 09, 2011 5:46 pm

RE:Scrolling
-----------------------------------
umm... we need the context. What exactly does your game do? And if you have any code, that would be helpful.

-----------------------------------
Badsniper
Mon May 09, 2011 9:05 pm

Re: Scrolling
-----------------------------------
Well, Here is the code for my movement.

[code]
var screen : int
screen := Window.Open ("graphics:700;800,nobuttonbar")
View.Set ("title:GAME;offscreenonly")

var x : int := 673
var y : int := 60
var jv : int := 15
var key : array char of boolean
var back : int := Pic.FileNew ("back.bmp")
var fall, jump, horizontal : boolean := false
var Possible_Jump : boolean := true
var grav : real := 1
var del : int
var x1,y1,x2,y2 : int

Pic.Draw (back, 0, 0, picMerge)
View.UpdateArea (0, 0, maxx, maxy)

loop
    
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%      INITIALIZE      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    del := 2
    Possible_Jump := true
    horizontal := false

    Pic.Draw (back, 0, 0, picMerge)
    Input.KeyDown (key)

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   MOVE TO THE RIGHT   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    if key ('d') and whatdotcolour (x + 5, y - 5) ~= 7 and whatdotcolour (x + 5, y) ~= 7 and jump = false and fall = false then
        x += 2
        horizontal := true
        for a : 1 .. 8
            if whatdotcolour (x, y - a - 5) = 7 then
                y -= a
                exit
            end if
        end for
    elsif key ('d') and whatdotcolour (x + 5, y + 5) ~= 7 and jump = false and fall = false then
        x += 2
        horizontal := true
        for decreasing a : 8 .. 1
            if whatdotcolour (x, (y + a) - 5) = 7 then
                y += a
                exit
            end if
        end for
    end if

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   MOVE TO THE LEFT   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    if key ('a') and whatdotcolour (x - 5, y - 5) ~= 7 and whatdotcolour (x - 5, y) ~= 7 and jump = false and fall = false then
        x -= 2
        put 1 ..
        horizontal := true
        for a : 1 .. 8
            if whatdotcolour (x, y - a - 5) = 7 then
                y -= a
                exit
            end if
        end for
    elsif key ('a') and whatdotcolour (x - 5, y + 5) ~= 7 and whatdotcolour (x - 5, y - 5) = 7 and jump = false and fall = false then
        x -= 2
        put 2 ..
        horizontal := true
        for decreasing a : 8 .. 1
            if whatdotcolour (x, (y + a) - 5) = 7 then
                y += a
                exit
            end if
        end for
    end if

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%    POSSIBLE JUMP     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    for a : 1 .. 10
        if whatdotcolour (x, y + 5 + a) = 7 then
            Possible_Jump := false
        end if
    end for

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%         JUMP         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    if key ('w') and whatdotcolour (x, y - 5) = 7 and jump = false and whatdotcolour (x, y + 5) ~= 7 and Possible_Jump then
        if key ('d') and whatdotcolour (x + 5, y) ~= 7 and whatdotcolour (x + 6, y) ~= 7 and whatdotcolour (x + 7, y) ~= 7 and horizontal = false then
            x += 3
        end if
        if key ('a') and whatdotcolour (x - 5, y) ~= 7 and whatdotcolour (x - 6, y) ~= 7 and whatdotcolour (x - 7, y) ~= 7 and horizontal = false then
            x -= 3
            put 3 ..
        end if
        y += jv
        jump := true
        del := 16
        for a : y - jv .. y
            if whatdotcolour (x, a + 5) = 7 then
                jump := false
                jv := 15
                y := a
                exit
            end if
        end for
    elsif jump = true and whatdotcolour (x, y + 5) ~= 7 then
        if key ('d') and whatdotcolour (x + 5, y) ~= 7 and whatdotcolour (x + 6, y) ~= 7 and whatdotcolour (x + 7, y) ~= 7 and horizontal = false then
            x += 3
        end if
        if key ('a') and whatdotcolour (x - 5, y) ~= 7 and whatdotcolour (x - 6, y) ~= 7 and whatdotcolour (x - 7, y) ~= 7 and horizontal = false then
            x -= 3
            put 4 ..
        end if
        y += jv
        for a : y - jv .. y
            if whatdotcolour (x, a + 5) = 7 then
                jump := false
                jv := 15
                y := a
                exit
            end if
        end for
        jv -= 1
        del := 16
        if jv < 2 then
            jump := false
            jv := 15
        end if
    end if

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%         FALL        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    if whatdotcolour (x, y - 5) ~= 7 and fall = false then
        grav := 1
        y -= grav div 1
        if key ('d') and whatdotcolour (x + 5, y) ~= 7 and whatdotcolour (x + 6, y) ~= 7 and whatdotcolour (x + 7, y) ~= 7 and horizontal = false then
            x += 3
        end if
        if key ('a') and whatdotcolour (x - 5, y) ~= 7 and whatdotcolour (x - 6, y) ~= 7 and whatdotcolour (x - 7, y) ~= 7 and horizontal = false then
            x -= 3
            put 5 ..
        end if
        grav += 0.5
        fall := true
        del := 16
    elsif fall = true then
        y -= grav div 1
        for decreasing a : y + grav div 1 .. y
            if whatdotcolour (x, a - 5) = 7 then
                fall := false
                grav := 1
                y := a
                exit
            end if
        end for
        if grav < 12 then
            grav += 0.5
        else
            grav := 13
        end if
        if key ('d') and whatdotcolour (x + 5, y) ~= 7 and whatdotcolour (x + 6, y) ~= 7 and whatdotcolour (x + 7, y) ~= 7 and horizontal = false then
            x += 3
        end if
        if key ('a') and whatdotcolour (x - 5, y) ~= 7 and whatdotcolour (x - 6, y) ~= 7 and whatdotcolour (x - 7, y) ~= 7 and horizontal = false then
            x -= 3
            put 6 ..
        end if
        del := 16
    end if

    if whatdotcolour (x, y - 5) = 7 then
        grav := 1
        fall := false
        jump := false
        jv := 15
    end if

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%    VARIABLE TRACE    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    exit when whatdotcolour (x, y) = 145
    drawfilloval (x, y, 3, 3, 3)
    locate (2, 1)
    put "fall : ", fall, "    ", "jump : ", jump, "    ", " X/Y  ", x, " ", y
    put "jumpvalue : ", jv, "    ", "gravity : ", grav
    put "Dot colour for positive slopes: ", whatdotcolour (x + 5, y - 5), " ", whatdotcolour (x + 5, y + 5)
    put "Dot colour for negative slopes: ", whatdotcolour (x - 5, y - 5), " ", whatdotcolour (x - 5, y + 5)
    View.UpdateArea (0, 0, maxx, maxy)
    delay (del)
    cls

end loop
[/code]

Now I need it to be able to scroll, but I don't even know how to start.[/code]

-----------------------------------
Badsniper
Tue May 10, 2011 3:15 pm

Re: Scrolling
-----------------------------------
Is there anyone who can help me?

-----------------------------------
Raknarg
Tue May 10, 2011 6:06 pm

RE:Scrolling
-----------------------------------
Hmm... So assuming you want the character in the middle (you forgot the picture, btw ;P), you could just move the x and y coordinates of the field. Have you ever worked with Input.Keydown or some form of charachter movement?

-----------------------------------
Badsniper
Tue May 10, 2011 7:06 pm

Re: Scrolling
-----------------------------------
I am using Input.Keydown. I just need to know how scrolling normally works in 2D games, so I can adjust it to work in mine...

and you could really create any picture in paint called "back.bmp" and save it in the same file as that program.

-----------------------------------
RandomLetters
Tue May 10, 2011 9:36 pm

RE:Scrolling
-----------------------------------
Scrolling does not move the screen across the field in scroller games.  Instead, the sprites or background are moved across the screen.  This makes it easy to loop background animations by creating them offscreen, moving them across the screen, and removing them from the picture.
