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

Username:   Password: 
 RegisterRegister   
 trying to load new screen when character gets to end of current screen
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
banette




PostPosted: Mon Jun 13, 2016 8:27 am   Post subject: trying to load new screen when character gets to end of current screen

im trying to make it so that when my characters position reaches the end of the screen (x > 798 or so) the character is moved to the front of the screen, and the objects on screen change. i tried using if x > 798 but it didnt go well, and the current solution i have does not work well either. suggestions? this is v4.1.


code:

setscreen ("graphics:800,600")

%VARIABLESDECLARED%
var font1, font2, font3, font4 : int
font1 := Font.New ("Courier:32")
font2 := Font.New ("Courier:16")
font3 := Font.New ("times new roman:16")
font4 := Font.New ("times new roman:8")
var gry, dgry, c : int
%tree, 99 tall, 12 wide always%
var trgr, trtp, trlft, trght : int
var fnsh : string (1)
var schoice : string (1)
var bchoice : string (3)
var x, y, jmp, flsh : int
var kp : string (1)
var posit : boolean
kp := "z"
x := 210
y := 281
gry := 30
dgry := 28
jmp := 0
flsh := 0
fnsh := "F"
posit := false
var charsa : array char of boolean
%SPLASHSCREENSTART%
colorback (black)
cls
%CHARACTER%
process character

    var chars : array char of boolean
    loop
        Input.KeyDown (chars)

        if chars (KEY_UP_ARROW) then
            c := whatdotcolor (x - 5, y + 26)
            if c not= dgry then
                c := whatdotcolor (x + 5, y + 26)
                if c not= dgry then
                    loop
                        y := y + 3
                        drawfillbox (x - 5, y, x + 5, y + 25, white)
                        delay (10)
                        drawfillbox (x - 5, y, x + 5, y + 25, black)
                        jmp := jmp + 1

                        Input.KeyDown (chars)


                        if chars (KEY_RIGHT_ARROW) then
                            c := whatdotcolor (x + 6, y)
                            if c not= dgry then
                                c := whatdotcolor (x + 6, y + 25)
                                if c not= dgry then
                                    x := x + 2
                                end if
                            end if
                        end if

                        if chars (KEY_LEFT_ARROW) then
                            c := whatdotcolor (x - 6, y)
                            if c not= dgry then
                                c := whatdotcolor (x - 6, y + 25)
                                if c not= dgry then
                                    x := x - 2
                                end if
                            end if
                        end if

                        exit when jmp = 28
                    end loop

                    jmp := 0

                    loop
                        Input.KeyDown (chars)


                        if chars (KEY_RIGHT_ARROW) then
                            c := whatdotcolor (x + 6, y)
                            if c not= dgry then
                                c := whatdotcolor (x + 6, y + 25)
                                if c not= dgry then
                                    x := x + 2
                                end if
                            end if
                        end if

                        if chars (KEY_LEFT_ARROW) then
                            c := whatdotcolor (x - 6, y)
                            if c not= dgry then
                                c := whatdotcolor (x - 6, y + 25)
                                if c not= dgry then
                                    x := x - 2
                                end if
                            end if
                        end if

                        y := y - 2
                        drawfillbox (x - 5, y, x + 5, y + 25, white)
                        delay (10)
                        drawfillbox (x - 5, y, x + 5, y + 25, black)

                        c := whatdotcolor (x - 5, y - 1)
                        if c = dgry then
                            exit
                        else
                            c := whatdotcolor (x + 5, y - 1)
                            if c = dgry then
                                exit
                            end if
                        end if
                    end loop
                end if
            end if
        end if

        if chars (KEY_DOWN_ARROW) then
            c := whatdotcolor (x - 5, y - 1)
            if c not= dgry then
                c := whatdotcolor (x + 5, y - 1)
                if c not= dgry then
                    y := y - 2
                end if
            end if
        end if


        if chars (KEY_RIGHT_ARROW) then
            c := whatdotcolor (x + 6, y)
            if c not= dgry then
                c := whatdotcolor (x + 6, y + 25)
                if c not= dgry then
                    x := x + 2
                end if
            end if
        end if

        if chars (KEY_LEFT_ARROW) then
            c := whatdotcolor (x - 6, y)
            if c not= dgry then
                c := whatdotcolor (x - 6, y + 25)
                if c not= dgry then
                    x := x - 2
                end if
            end if
        end if

        loop
            c := whatdotcolor (x - 5, y - 1)
            if c not= dgry then
                c := whatdotcolor (x + 5, y - 1)
                if c not= dgry then
                    y := y - 2
                    drawfillbox (x - 5, y, x + 5, y + 25, white)
                    delay (10)
                    drawfillbox (x - 5, y, x + 5, y + 25, black)
                end if
            end if

            c := whatdotcolor (x - 5, y - 1)
            if c = dgry then
                exit
            else
                c := whatdotcolor (x + 5, y - 1)
                if c = dgry then
                    exit
                end if
            end if
        end loop

        drawfillbox (x - 5, y, x + 5, y + 25, white)
        delay (10)
        drawfillbox (x - 5, y, x + 5, y + 25, black)

        if x > 798 then
            posit := true
        end if

    end loop
end character

%END INTRO, BEGIN GAMEPLAY%
%DGRY FOR GROUND, GRY FOR OBJS%

x := 8
y := 301
drawfillbox (0, 290, 800, 300, dgry)
trgr := 301
trtp := 400
trlft := 200
trght := 212
drawfillbox (trlft, trgr, trght, trtp, gry)
drawfillbox (trlft - 30, trgr + 20, trght, trgr + 32, gry)
drawfillbox (trlft + 12, trgr + 30, trght + 30, trgr + 42, gry)
drawfillbox (trlft - 20, trgr + 56, trght, trgr + 68, gry)
drawfillbox (trlft + 12, trgr + 74, trght + 12, trgr + 86, gry)

fork character
loop
    if posit = true then
        cls
        x := 8
        y := 301
        drawfillbox (0, 290, 800, 300, dgry)
        trgr := 301
        trtp := 400
        trlft := 350
        trght := 362
        drawfillbox (trlft, trgr, trght, trtp, gry)
        drawfillbox (trlft - 30, trgr + 20, trght, trgr + 32, gry)
        drawfillbox (trlft + 12, trgr + 30, trght + 30, trgr + 42, gry)
        drawfillbox (trlft - 20, trgr + 56, trght, trgr + 68, gry)
        drawfillbox (trlft + 12, trgr + 74, trght + 12, trgr + 86, gry)
    end if
    exit when posit = true
end loop
posit := false
Sponsor
Sponsor
Sponsor
sponsor
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  [ 1 Posts ]
Jump to:   


Style:  
Search: