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

Username:   Password: 
 RegisterRegister   
 Need Help with Collision and Screen Flickering
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Nablo




PostPosted: Mon Dec 19, 2011 4:53 pm   Post subject: Need Help with Collision and Screen Flickering

What is it you are trying to achieve?
<Replace all the <> with your answers/code and remove the <>>


What is the problem you are having?
Screen Flickers too much due to the nature of the way I generated the bullets.
Collision with edge of screen not working. Boot collision with the black part of the portal doesnt work


Describe what you have tried to solve this problem
Tried using various types of arrays and configurations with arrays to help with the bullet problem. Tried moving the View.Update to various sensible places in the program. Tried using only one view.update (which didnt work).


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

Turing:


% Declare Variables

var CXBLSSBbody, CYBLSSBbody, CXTRSSBbody, CYTRSSBbody, CXSBarm, CYSBarm, CXRSBarm, CYRSBarm, CXSBfan, CYSBfan, CXRSBfan : int
var CYRSBfan, CXBLSSBhead, CYBLSSBhead, CXTRSSBhead, CYTRSSBhead, CXBLSSBleftleg, CYBLSSBleftleg, CXTRSSBleftleg : int
var CYTRSSBleftleg, CXBLSSBrightleg, CYBLSSBrightleg, CXTRSSrightleg, CYTRSSBrightleg, CXBLSSBleftshoe, CYBLSSBleftshoe : int
var CXTRSSBleftshoe, CYTRSSBleftshoe, CXBLSSBrightshoe, CYBLSSBrightshoe, CXTRSSrightshoe, CYTRSSBrightshoe : int
var CXSBlefteye, CYSBlefteye, CXRSBlefteye, CYRSBlefteye, CXSBrighteye, CYSBrighteye, CXRSBrighteye, CYRSBrighteye : int
var CXBLP, CYBLP, CXRSBbiglandingpad, CYRBLP, CXSLP, CYSLP, CXRSLP, CYRSLP, CXESbody, CYESbody, CXRESbody, CYRESbody : int
var CX1ESspiketopleft, CX2ESspiketopleft, XY1ESspiketopleft, CY2spiketopleft, CX1ESspiketopright, CX2ESspiketopright : int
var XY1ESspiketopright, CY2spiketopright, CX1ESspikebottomleft, CX2ESspikebottomleft, XY1ESspikebottomleft : int
var CY2spikebottomleft, CX1ESspikebottomright, CX2ESspikebottomright, XY1ESspikebottomright, CY2spikebottomright : int
var CX1ESspikeleftleft, CX2ESspikeleftleft, XY1ESspikeleftleft, CY2spikeleftleft, CX1ESspikeleftright : int
var CX2ESspikeleftright, XY1ESspikeleftright, CY2spikeleftright, CX1ESspikerightleft, CX2ESspikerightleft : int
var XY1ESspikerightleft, CY2spikerightleft, CX1ESspikerightright, CX2ESspikerightright, XY1ESspikerightright : int
var CY2spikerightright, CXBLSP, CYBLSP, CXTRSP, CYTRSP, CXB, CYB, CXRB, CYRB, CXBLSBH, CYBLSBH, CXTRSBH, CYTRSBH : int
var life, speed : int
var ch : string (1)


% Assign Values to Big Landing Pad

CXBLP := 50
CYBLP := 0
CXRSBbiglandingpad := 50
CYRBLP := 15

% Assign Values to Small Landing Pad

CXSLP := 50
CYSLP := 0
CXRSLP := 25
CYRSLP := 7

% Assign Values to Portal

CXBLSP := 600
CYBLSP := 0
CXTRSP := 640
CYTRSP := 150

% Assign Values to Blaster

CXB := 640
CYB := 250
CXRB := 100
CYRB := 25

% Assign Values to Black Hole

CXBLSBH := (maxx div 2) - 125
CYBLSBH := 0
CXTRSBH := (maxx div 2) + 125
CYTRSBH := 300


process Grid

    for x : 1 .. 640 by 20
        for y : 1 .. 420 by 20
            drawbox (x, y, x + 20, y + 20, black)
        end for
    end for

end Grid

process ParticleGenerationScrapBoy

    View.Set ("offscreenonly")

    var a : int := 1
    var xe, ye : array 1 .. a + 1 of int
    var speed : int := 1

    a += 1
    xe (a) := CXRSBarm
    ye (a) := CYSBarm + ((CYRSBarm - CYSBarm) div 2)

    loop

        drawfilloval (xe (a), ye (a), 10 + 3, 10 + 3, white)

        % Draw BG

        drawfillbox (0, 0, maxx, maxy, gray)

        % Draw Landing Pad
        drawfilloval (CXBLP, CYBLP, CXRSBbiglandingpad, CYRBLP, 25)
        drawfilloval (CXSLP, CYSLP, CXRSLP, CYRSLP, 12)

        % Draw Robot

        drawfillbox (CXSBarm - 2, CYSBarm - 2, CXRSBarm + 2, CYRSBarm + 2, black)
        drawfillbox (CXSBarm, CYSBarm, CXRSBarm, CYRSBarm, 122)
        drawfillbox (CXBLSSBbody - 1, CYBLSSBbody - 1, CXTRSSBbody + 1, CYTRSSBbody + 1, black)
        drawfillbox (CXBLSSBbody, CYBLSSBbody, CXTRSSBbody, CYTRSSBbody, 92)
        drawfilloval (CXSBfan, CYSBfan, CXRSBfan + 2, CYRSBfan + 2, black)
        drawfilloval (CXSBfan, CYSBfan, CXRSBfan, CYRSBfan, 13)
        drawfillbox (CXBLSSBhead - 2, CYBLSSBhead - 2, CXTRSSBhead + 2, CYTRSSBhead + 2, black)
        drawfillbox (CXBLSSBhead, CYBLSSBhead, CXTRSSBhead, CYTRSSBhead, 54)
        drawfillbox (CXBLSSBleftleg, CYBLSSBleftleg, CXTRSSBleftleg, CYTRSSBleftleg, 81)
        drawfillbox (CXBLSSBrightleg, CYBLSSBrightleg, CXTRSSrightleg, CYTRSSBrightleg, 81)
        drawfillbox (CXBLSSBleftshoe - 1, CYBLSSBleftshoe - 1, CXTRSSBleftshoe + 1, CYTRSSBleftshoe + 1, black)
        drawfillbox (CXBLSSBleftshoe, CYBLSSBleftshoe, CXTRSSBleftshoe, CYTRSSBleftshoe, 51)
        drawfillbox (CXBLSSBrightshoe - 1, CYBLSSBrightshoe + -1, CXTRSSrightshoe + 1, CYTRSSBrightshoe + 1, black)
        drawfillbox (CXBLSSBrightshoe, CYBLSSBrightshoe, CXTRSSrightshoe, CYTRSSBrightshoe, 51)
        drawfilloval (CXSBlefteye, CYSBlefteye, CXRSBlefteye, CYRSBlefteye, 12)
        drawfilloval (CXSBrighteye, CYSBrighteye, CXRSBrighteye, CYRSBrighteye, 12)
        drawfilloval (CXSBlefteye, CYSBlefteye, CXRSBlefteye - 3, CYRSBlefteye - 3, black)
        drawfilloval (CXSBrighteye, CYSBrighteye, CXRSBrighteye - 3, CYRSBrighteye - 3, black)
        drawfilloval (CXSBlefteye + 2, CYSBlefteye + 2, CXRSBlefteye - 5, CYRSBlefteye - 5, white)
        drawfilloval (CXSBrighteye + 2, CYSBrighteye + 2, CXRSBrighteye - 5, CYRSBrighteye - 5, white)

        % Draw Portal
        drawfillbox (CXBLSP, CYBLSP, CXTRSP, CYTRSP, blue)

        % Draw Blaster
        drawfilloval (CXB, CYB, CXRB, CYRB, 122)

        %Draw Black Hole

        drawfillbox (CXBLSBH - 10, CYBLSBH, CXTRSBH + 10, CYTRSBH + 10, purple)
        drawfillbox (CXBLSBH, CYBLSBH, CXTRSBH, CYTRSBH, black)

        xe (a) := xe (a) + speed

        drawfilloval (xe (a), ye (a), 10 + 3, 10 + 3, yellow)
        drawfilloval (xe (a), ye (a), 10, 10, red)
        put life

        View.Update

        exit when xe (a) = maxx + 100
    end loop
end ParticleGenerationScrapBoy

process ParticleGenerationBlaster

    View.Set ("offscreenonly")

    var xp, yp : array 1 .. 6 of int
    var speed : int := 1

    xp (1) := CXB - 100
    yp (1) := CYB
    xp (2) := CXB - 100
    yp (2) := CYB

    loop

        drawfilloval (xp (1), yp (1), 10 + 3, 10 + 3, white)
        drawfilloval (xp (2), yp (2), 10 + 3, 10 + 3, white)

        % Draw BG

        drawfillbox (0, 0, maxx, maxy, gray)

        % Draw Landing Pad
        drawfilloval (CXBLP, CYBLP, CXRSBbiglandingpad, CYRBLP, 25)
        drawfilloval (CXSLP, CYSLP, CXRSLP, CYRSLP, 12)

        % Draw Robot

        drawfillbox (CXSBarm - 2, CYSBarm - 2, CXRSBarm + 2, CYRSBarm + 2, black)
        drawfillbox (CXSBarm, CYSBarm, CXRSBarm, CYRSBarm, 122)
        drawfillbox (CXBLSSBbody - 1, CYBLSSBbody - 1, CXTRSSBbody + 1, CYTRSSBbody + 1, black)
        drawfillbox (CXBLSSBbody, CYBLSSBbody, CXTRSSBbody, CYTRSSBbody, 92)
        drawfilloval (CXSBfan, CYSBfan, CXRSBfan + 2, CYRSBfan + 2, black)
        drawfilloval (CXSBfan, CYSBfan, CXRSBfan, CYRSBfan, 13)
        drawfillbox (CXBLSSBhead - 2, CYBLSSBhead - 2, CXTRSSBhead + 2, CYTRSSBhead + 2, black)
        drawfillbox (CXBLSSBhead, CYBLSSBhead, CXTRSSBhead, CYTRSSBhead, 54)
        drawfillbox (CXBLSSBleftleg, CYBLSSBleftleg, CXTRSSBleftleg, CYTRSSBleftleg, 81)
        drawfillbox (CXBLSSBrightleg, CYBLSSBrightleg, CXTRSSrightleg, CYTRSSBrightleg, 81)
        drawfillbox (CXBLSSBleftshoe - 1, CYBLSSBleftshoe - 1, CXTRSSBleftshoe + 1, CYTRSSBleftshoe + 1, black)
        drawfillbox (CXBLSSBleftshoe, CYBLSSBleftshoe, CXTRSSBleftshoe, CYTRSSBleftshoe, 51)
        drawfillbox (CXBLSSBrightshoe - 1, CYBLSSBrightshoe + -1, CXTRSSrightshoe + 1, CYTRSSBrightshoe + 1, black)
        drawfillbox (CXBLSSBrightshoe, CYBLSSBrightshoe, CXTRSSrightshoe, CYTRSSBrightshoe, 51)
        drawfilloval (CXSBlefteye, CYSBlefteye, CXRSBlefteye, CYRSBlefteye, 12)
        drawfilloval (CXSBrighteye, CYSBrighteye, CXRSBrighteye, CYRSBrighteye, 12)
        drawfilloval (CXSBlefteye, CYSBlefteye, CXRSBlefteye - 3, CYRSBlefteye - 3, black)
        drawfilloval (CXSBrighteye, CYSBrighteye, CXRSBrighteye - 3, CYRSBrighteye - 3, black)
        drawfilloval (CXSBlefteye + 2, CYSBlefteye + 2, CXRSBlefteye - 5, CYRSBlefteye - 5, white)
        drawfilloval (CXSBrighteye + 2, CYSBrighteye + 2, CXRSBrighteye - 5, CYRSBrighteye - 5, white)

        % Draw Portal
        drawfillbox (CXBLSP, CYBLSP, CXTRSP, CYTRSP, blue)

        % Draw Blaster
        drawfilloval (CXB, CYB, CXRB, CYRB, 122)

        %Draw Black Hole

        drawfillbox (CXBLSBH - 10, CYBLSBH, CXTRSBH + 10, CYTRSBH + 10, purple)
        drawfillbox (CXBLSBH, CYBLSBH, CXTRSBH, CYTRSBH, black)

        xp (1) := xp (1) - speed
        xp (2) := xp (2) - speed

        drawfilloval (xp (1), yp (1), 10 + 3, 10 + 3, yellow)
        drawfilloval (xp (1), yp (1), 10, 10, red)

        if xp (1) = CXB - 200
                then
            drawfilloval (xp (2), yp (2), 10 + 3, 10 + 3, yellow)
            drawfilloval (xp (2), yp (2), 10, 10, red)
        end if
        put life

        View.Update

        if xp (1) = -10 then
            xp (1) := CXB - 100
        end if
        if xp (2) = -10 then
            xp (2) := CXB - 100
        end if
    end loop
end ParticleGenerationBlaster


setscreen ("graphics:640;480,nocursor")

for x1 : 1 .. 640 by 20
    for y1 : 1 .. 480 by 20
        drawbox (x1, y1, x1 + 20, y1 + 20, black)
    end for

    drawfillbox (0, 0, maxx, maxy, black)

end for
var arials, arialb, c : int
c := 66
arials := Font.New ("Arial:26:bold")
arialb := Font.New ("Arial:30:bold")
assert arials > 0
assert arialb > 0
Font.Draw ("The Adventures of Scrap Boy", 50, maxy - 50, arialb, yellow)


Font.Free (arials)

loop
    var x, y, button : int
    mousewhere (x, y, button)

    Font.Draw ("Play", 50, maxy - 150, arialb, c)
    if button = 0 and x > 50 and x < 130 and y > 320 and y < 356 then
        c := 94
    elsif
            button = 1 and x > 50 and x < 130 and y > 320 and y < 356 then

        cls

        % Assign Values to Scrap Boy's Right Shoe

        CXBLSSBrightshoe := 20
        CYBLSSBrightshoe := 0
        CXTRSSrightshoe := 45
        CYTRSSBrightshoe := 20

        % Assign Values to Scrap Boy's Left Shoe

        CXBLSSBleftshoe := 50
        CYBLSSBleftshoe := 0
        CXTRSSBleftshoe := 75
        CYTRSSBleftshoe := 20

        % Assign Values to Scrap Boy's Left Leg

        CXBLSSBleftleg := 25
        CYBLSSBleftleg := 20
        CXTRSSBleftleg := 40
        CYTRSSBleftleg := 24

        % Assign Values to Scrap Boy's Right Leg

        CXBLSSBrightleg := 55
        CYBLSSBrightleg := 20
        CXTRSSrightleg := 70
        CYTRSSBrightleg := 24

        % Assign Values to Scrap Boy's Body

        CXBLSSBbody := 15
        CYBLSSBbody := 25
        CXTRSSBbody := 80
        CYTRSSBbody := 65

        % Assign Values to Scrap Boy's Fan

        CXSBfan := 12
        CYSBfan := 45
        CXRSBfan := 5
        CYRSBfan := 10

        % Assign Values to Scrap Boy's Arm

        CXSBarm := 60
        CYSBarm := 55
        CXRSBarm := 100
        CYRSBarm := 65

        % Assign Values to Scrap Boy's Head

        CXBLSSBhead := 24
        CYBLSSBhead := 60
        CXTRSSBhead := 71
        CYTRSSBhead := 90

        % Assign Values to Scrap Boy's Left Eye

        CXSBlefteye := (CXTRSSBhead - CXBLSSBhead) - 10
        CYSBlefteye := 75
        CXRSBlefteye := 7
        CYRSBlefteye := 7

        % Assign Values to Scrap Boy's Right Eye

        CXSBrighteye := (CXTRSSBhead - CXBLSSBhead) + 10
        CYSBrighteye := 75
        CXRSBrighteye := 7
        CYRSBrighteye := 7



        % Assign Values to Life, Speed

        life := 4
        speed := 1


        fork Grid

        % Draw Landing Pad

        drawfilloval (CXBLP, CYBLP, CXRSBbiglandingpad, CYRBLP, 25)
        drawfilloval (CXSLP, CYSLP, CXRSLP, CYRSLP, 12)

        % Draw Robot

        drawfillbox (CXSBarm - 2, CYSBarm - 2, CXRSBarm + 2, CYRSBarm + 2, black)
        drawfillbox (CXSBarm, CYSBarm, CXRSBarm, CYRSBarm, 122)
        drawfillbox (CXBLSSBbody - 1, CYBLSSBbody - 1, CXTRSSBbody + 1, CYTRSSBbody + 1, black)
        drawfillbox (CXBLSSBbody, CYBLSSBbody, CXTRSSBbody, CYTRSSBbody, 92)
        drawfilloval (CXSBfan, CYSBfan, CXRSBfan + 2, CYRSBfan + 2, black)
        drawfilloval (CXSBfan, CYSBfan, CXRSBfan, CYRSBfan, 13)
        drawfillbox (CXBLSSBhead - 2, CYBLSSBhead - 2, CXTRSSBhead + 2, CYTRSSBhead + 2, black)
        drawfillbox (CXBLSSBhead, CYBLSSBhead, CXTRSSBhead, CYTRSSBhead, 54)
        drawfillbox (CXBLSSBleftleg, CYBLSSBleftleg, CXTRSSBleftleg, CYTRSSBleftleg, 81)
        drawfillbox (CXBLSSBrightleg, CYBLSSBrightleg, CXTRSSrightleg, CYTRSSBrightleg, 81)
        drawfillbox (CXBLSSBleftshoe - 1, CYBLSSBleftshoe - 1, CXTRSSBleftshoe + 1, CYTRSSBleftshoe + 1, black)
        drawfillbox (CXBLSSBleftshoe, CYBLSSBleftshoe, CXTRSSBleftshoe, CYTRSSBleftshoe, 51)
        drawfillbox (CXBLSSBrightshoe - 1, CYBLSSBrightshoe + -1, CXTRSSrightshoe + 1, CYTRSSBrightshoe + 1, black)
        drawfillbox (CXBLSSBrightshoe, CYBLSSBrightshoe, CXTRSSrightshoe, CYTRSSBrightshoe, 51)
        drawfilloval (CXSBlefteye, CYSBlefteye, CXRSBlefteye, CYRSBlefteye, 12)
        drawfilloval (CXSBrighteye, CYSBrighteye, CXRSBrighteye, CYRSBrighteye, 12)
        drawfilloval (CXSBlefteye, CYSBlefteye, CXRSBlefteye - 3, CYRSBlefteye - 3, black)
        drawfilloval (CXSBrighteye, CYSBrighteye, CXRSBrighteye - 3, CYRSBrighteye - 3, black)
        drawfilloval (CXSBlefteye + 2, CYSBlefteye + 2, CXRSBlefteye - 5, CYRSBlefteye - 5, white)
        drawfilloval (CXSBrighteye + 2, CYSBrighteye + 2, CXRSBrighteye - 5, CYRSBrighteye - 5, white)


        /*% Draw Evil Spikeria

         drawfilloval (CXESbody, CYESbody, CXRESbody, CYRESbody, red)
         drawline (CX1ESspiketopleft, CX2ESspiketopleft, XY1ESspiketopleft, CY2spiketopleft, black)
         drawline (CX1ESspiketopright, CX2ESspiketopright, XY1ESspiketopright, CY2spiketopright, black)
         drawline (CX1ESspikebottomleft, CX2ESspikebottomleft, XY1ESspikebottomleft, CY2spikebottomleft, black)
         drawline (CX1ESspikebottomright, CX2ESspikebottomright, XY1ESspikebottomright, CY2spikebottomright, black)
         drawline (CX1ESspikeleftleft, CX2ESspikeleftleft, XY1ESspikeleftleft, CY2spikeleftleft, black)
         drawline (CX1ESspikeleftright, CX2ESspikeleftright, XY1ESspikeleftright, CY2spikeleftright, black)
         drawline (CX1ESspikerightleft, CX2ESspikerightleft, XY1ESspikerightleft, CY2spikerightleft, black)
         drawline (CX1ESspikerightright, CX2ESspikerightright, XY1ESspikerightright, CY2spikerightright, black)*/


        % Draw Portal

        drawfillbox (CXBLSP, CYBLSP, CXTRSP, CYTRSP, blue)

        % Draw Blaster

        drawfilloval (CXB, CYB, CXRB, CYRB, 122)

        %Draw Black Hole

        drawfillbox (CXBLSBH - 10, CYBLSBH, CXTRSBH + 10, CYTRSBH + 10, purple)
        drawfillbox (CXBLSBH, CYBLSBH, CXTRSBH, CYTRSBH, black)

        %Movement for Scrap Boy

        setscreen ("graphics:640;480,nocursor")
        View.Set ("offscreenonly")

        fork ParticleGenerationBlaster

        loop

            % Draw BG

            drawfillbox (0, 0, maxx, maxy, gray)

            % Draw Landing Pad
            drawfilloval (CXBLP, CYBLP, CXRSBbiglandingpad, CYRBLP, 25)
            drawfilloval (CXSLP, CYSLP, CXRSLP, CYRSLP, 12)

            % Draw Portal
            drawfillbox (CXBLSP, CYBLSP, CXTRSP, CYTRSP, blue)

            % Draw Blaster
            drawfilloval (CXB, CYB, CXRB, CYRB, 122)

            %Draw Black Hole

            drawfillbox (CXBLSBH - 10, CYBLSBH, CXTRSBH + 10, CYTRSBH + 10, purple)
            drawfillbox (CXBLSBH, CYBLSBH, CXTRSBH, CYTRSBH, black)

            getch (ch)

            cls

            if ord (ch) = 32 then
                fork ParticleGenerationScrapBoy
            end if

            % BackgroundColour

            colourback (gray)

            % Draw BG

            drawfillbox (0, 0, maxx, maxy, gray)

            % Draw Landing Pad
            drawfilloval (CXBLP, CYBLP, CXRSBbiglandingpad, CYRBLP, 25)
            drawfilloval (CXSLP, CYSLP, CXRSLP, CYRSLP, 12)

            % Draw Robot

            drawfillbox (CXSBarm - 2, CYSBarm - 2, CXRSBarm + 2, CYRSBarm + 2, black)
            drawfillbox (CXSBarm, CYSBarm, CXRSBarm, CYRSBarm, 122)
            drawfillbox (CXBLSSBbody - 1, CYBLSSBbody - 1, CXTRSSBbody + 1, CYTRSSBbody + 1, black)
            drawfillbox (CXBLSSBbody, CYBLSSBbody, CXTRSSBbody, CYTRSSBbody, 92)
            drawfilloval (CXSBfan, CYSBfan, CXRSBfan + 2, CYRSBfan + 2, black)
            drawfilloval (CXSBfan, CYSBfan, CXRSBfan, CYRSBfan, 13)
            drawfillbox (CXBLSSBhead - 2, CYBLSSBhead - 2, CXTRSSBhead + 2, CYTRSSBhead + 2, black)
            drawfillbox (CXBLSSBhead, CYBLSSBhead, CXTRSSBhead, CYTRSSBhead, 54)
            drawfillbox (CXBLSSBleftleg, CYBLSSBleftleg, CXTRSSBleftleg, CYTRSSBleftleg, 81)
            drawfillbox (CXBLSSBrightleg, CYBLSSBrightleg, CXTRSSrightleg, CYTRSSBrightleg, 81)
            drawfillbox (CXBLSSBleftshoe - 1, CYBLSSBleftshoe - 1, CXTRSSBleftshoe + 1, CYTRSSBleftshoe + 1, black)
            drawfillbox (CXBLSSBleftshoe, CYBLSSBleftshoe, CXTRSSBleftshoe, CYTRSSBleftshoe, 51)
            drawfillbox (CXBLSSBrightshoe - 1, CYBLSSBrightshoe + -1, CXTRSSrightshoe + 1, CYTRSSBrightshoe + 1, black)
            drawfillbox (CXBLSSBrightshoe, CYBLSSBrightshoe, CXTRSSrightshoe, CYTRSSBrightshoe, 51)
            drawfilloval (CXSBlefteye, CYSBlefteye, CXRSBlefteye, CYRSBlefteye, 12)
            drawfilloval (CXSBrighteye, CYSBrighteye, CXRSBrighteye, CYRSBrighteye, 12)
            drawfilloval (CXSBlefteye, CYSBlefteye, CXRSBlefteye - 3, CYRSBlefteye - 3, black)
            drawfilloval (CXSBrighteye, CYSBrighteye, CXRSBrighteye - 3, CYRSBrighteye - 3, black)
            drawfilloval (CXSBlefteye + 2, CYSBlefteye + 2, CXRSBlefteye - 5, CYRSBlefteye - 5, white)
            drawfilloval (CXSBrighteye + 2, CYSBrighteye + 2, CXRSBrighteye - 5, CYRSBrighteye - 5, white)

            % Draw Portal
            drawfillbox (CXBLSP, CYBLSP, CXTRSP, CYTRSP, blue)

            % Draw Blaster
            drawfilloval (CXB, CYB, CXRB, CYRB, 122)

            %Draw Black Hole

            drawfillbox (CXBLSBH - 10, CYBLSBH, CXTRSBH + 10, CYTRSBH + 10, purple)
            drawfillbox (CXBLSBH, CYBLSBH, CXTRSBH, CYTRSBH, black)

            % Exit Condition

            exit when ord (ch) = 27

            % Movement Condition for Scrap Boy

            case ord (ch) of

                label 200 :
                    CYSBarm := CYSBarm + 5
                    CYBLSSBbody := CYBLSSBbody + 5
                    CYSBfan := CYSBfan + 5
                    CYBLSSBhead := CYBLSSBhead + 5
                    CYBLSSBleftleg := CYBLSSBleftleg + 5
                    CYBLSSBrightleg := CYBLSSBrightleg + 5
                    CYBLSSBleftshoe := CYBLSSBleftshoe + 5
                    CYBLSSBrightshoe := CYBLSSBrightshoe + 5
                    CYSBlefteye := CYSBlefteye + 5
                    CYSBrighteye := CYSBrighteye + 5
                    CYRSBarm := CYRSBarm + 5
                    CYTRSSBbody := CYTRSSBbody + 5
                    CYTRSSBhead := CYTRSSBhead + 5
                    CYTRSSBleftleg := CYTRSSBleftleg + 5
                    CYTRSSBrightleg := CYTRSSBrightleg + 5
                    CYTRSSBleftshoe := CYTRSSBleftshoe + 5
                    CYTRSSBrightshoe := CYTRSSBrightshoe + 5

                label 208 :
                    CYSBarm := CYSBarm - 5
                    CYBLSSBbody := CYBLSSBbody - 5
                    CYSBfan := CYSBfan - 5
                    CYBLSSBhead := CYBLSSBhead - 5
                    CYBLSSBleftleg := CYBLSSBleftleg - 5
                    CYBLSSBrightleg := CYBLSSBrightleg - 5
                    CYBLSSBleftshoe := CYBLSSBleftshoe - 5
                    CYBLSSBrightshoe := CYBLSSBrightshoe - 5
                    CYSBlefteye := CYSBlefteye - 5
                    CYSBrighteye := CYSBrighteye - 5
                    CYRSBarm := CYRSBarm - 5
                    CYTRSSBbody := CYTRSSBbody - 5
                    CYTRSSBhead := CYTRSSBhead - 5
                    CYTRSSBleftleg := CYTRSSBleftleg - 5
                    CYTRSSBrightleg := CYTRSSBrightleg - 5
                    CYTRSSBleftshoe := CYTRSSBleftshoe - 5
                    CYTRSSBrightshoe := CYTRSSBrightshoe - 5
                label 203 :
                    CXSBarm := CXSBarm - 5
                    CXBLSSBbody := CXBLSSBbody - 5
                    CXSBfan := CXSBfan - 5
                    CXBLSSBhead := CXBLSSBhead - 5
                    CXBLSSBleftleg := CXBLSSBleftleg - 5
                    CXBLSSBrightleg := CXBLSSBrightleg - 5
                    CXBLSSBleftshoe := CXBLSSBleftshoe - 5
                    CXBLSSBrightshoe := CXBLSSBrightshoe - 5
                    CXSBlefteye := CXSBlefteye - 5
                    CXSBrighteye := CXSBrighteye - 5
                    CXRSBarm := CXRSBarm - 5
                    CXTRSSBbody := CXTRSSBbody - 5
                    CXTRSSBhead := CXTRSSBhead - 5
                    CXTRSSBleftleg := CXTRSSBleftleg - 5
                    CXTRSSrightleg := CXTRSSrightleg - 5
                    CXTRSSBleftshoe := CXTRSSBleftshoe - 5
                    CXTRSSrightshoe := CXTRSSrightshoe - 5
                label 205 :
                    CXSBarm := CXSBarm + 5
                    CXBLSSBbody := CXBLSSBbody + 5
                    CXSBfan := CXSBfan + 5
                    CXBLSSBhead := CXBLSSBhead + 5
                    CXBLSSBleftleg := CXBLSSBleftleg + 5
                    CXBLSSBrightleg := CXBLSSBrightleg + 5
                    CXBLSSBleftshoe := CXBLSSBleftshoe + 5
                    CXBLSSBrightshoe := CXBLSSBrightshoe + 5
                    CXSBlefteye := CXSBlefteye + 5
                    CXSBrighteye := CXSBrighteye + 5
                    CXRSBarm := CXRSBarm + 5
                    CXTRSSBbody := CXTRSSBbody + 5
                    CXTRSSBhead := CXTRSSBhead + 5
                    CXTRSSBleftleg := CXTRSSBleftleg + 5
                    CXTRSSrightleg := CXTRSSrightleg + 5
                    CXTRSSBleftshoe := CXTRSSBleftshoe + 5
                    CXTRSSrightshoe := CXTRSSrightshoe + 5
                label :
                    CYSBarm := CYSBarm * 1

            end case

            drawfillbox (CXSBarm - 2, CYSBarm - 2, CXRSBarm + 2, CYRSBarm + 2, black)
            drawfillbox (CXSBarm, CYSBarm, CXRSBarm, CYRSBarm, 122)
            drawfillbox (CXBLSSBbody - 1, CYBLSSBbody - 1, CXTRSSBbody + 1, CYTRSSBbody + 1, black)
            drawfillbox (CXBLSSBbody, CYBLSSBbody, CXTRSSBbody, CYTRSSBbody, 92)
            drawfilloval (CXSBfan, CYSBfan, CXRSBfan + 2, CYRSBfan + 2, black)
            drawfilloval (CXSBfan, CYSBfan, CXRSBfan, CYRSBfan, 13)
            drawfillbox (CXBLSSBhead - 2, CYBLSSBhead - 2, CXTRSSBhead + 2, CYTRSSBhead + 2, black)
            drawfillbox (CXBLSSBhead, CYBLSSBhead, CXTRSSBhead, CYTRSSBhead, 54)
            drawfillbox (CXBLSSBleftleg, CYBLSSBleftleg, CXTRSSBleftleg, CYTRSSBleftleg, 81)
            drawfillbox (CXBLSSBrightleg, CYBLSSBrightleg, CXTRSSrightleg, CYTRSSBrightleg, 81)
            drawfillbox (CXBLSSBleftshoe - 1, CYBLSSBleftshoe - 1, CXTRSSBleftshoe + 1, CYTRSSBleftshoe + 1, black)
            drawfillbox (CXBLSSBleftshoe, CYBLSSBleftshoe, CXTRSSBleftshoe, CYTRSSBleftshoe, 51)
            drawfillbox (CXBLSSBrightshoe - 1, CYBLSSBrightshoe + -1, CXTRSSrightshoe + 1, CYTRSSBrightshoe + 1, black)
            drawfillbox (CXBLSSBrightshoe, CYBLSSBrightshoe, CXTRSSrightshoe, CYTRSSBrightshoe, 51)
            drawfilloval (CXSBlefteye, CYSBlefteye, CXRSBlefteye, CYRSBlefteye, 12)
            drawfilloval (CXSBrighteye, CYSBrighteye, CXRSBrighteye, CYRSBrighteye, 12)
            drawfilloval (CXSBlefteye, CYSBlefteye, CXRSBlefteye - 3, CYRSBlefteye - 3, black)
            drawfilloval (CXSBrighteye, CYSBrighteye, CXRSBrighteye - 3, CYRSBrighteye - 3, black)
            drawfilloval (CXSBlefteye + 2, CYSBlefteye + 2, CXRSBlefteye - 5, CYRSBlefteye - 5, white)
            drawfilloval (CXSBrighteye + 2, CYSBrighteye + 2, CXRSBrighteye - 5, CYRSBrighteye - 5, white)

            put life

            View.Update
            delay (10)

            %Colission with Border

            if CXRSBarm >= maxx and CXSBarm <= 0 and CYRSBarm >= maxy and CYSBarm <= 0 then
                life := life - 1

            elsif CXTRSSBbody >= maxx and CXBLSSBbody <= 0 and CYBLSSBbody >= maxy and CYTRSSBbody <= 0 then
                life := life - 1

            elsif CXTRSSBhead >= maxx and CXBLSSBhead <= 0 and CYBLSSBhead >= maxy and CYTRSSBhead <= 0 then
                life := life - 1

            elsif CXTRSSBleftleg >= maxx and CXBLSSBleftleg <= 0 and CYBLSSBleftleg >= maxy and CYTRSSBleftleg <= 0 then
                life := life - 1

            elsif CXTRSSrightleg >= maxx and CXBLSSBrightleg <= 0 and CYBLSSBrightleg >= maxy and CYTRSSBrightleg <= 0 then
                life := life - 1

            elsif CXTRSSBleftshoe >= maxx and CXBLSSBleftshoe <= 0 and CYBLSSBleftshoe >= maxy and CYTRSSBleftshoe <= 0 then
                life := life - 1

            elsif CXTRSSrightshoe >= maxx and CXBLSSBrightshoe <= 0 and CYBLSSBrightshoe >= maxy and CYTRSSBrightshoe <= 0 then
                life := life - 1

            end if

            % Colission with Portal

            if CXRSBarm >= CXBLSBH and CXSBarm <= CXTRSBH and CYRSBarm >= CYBLSBH and CYSBarm <= CYTRSBH then
                life := life - 1

            elsif CXTRSSBbody >= CXBLSBH and CXBLSSBbody <= CXTRSBH and CYBLSSBbody >= CYBLSBH and CYTRSSBbody <= CYTRSBH then
                life := life - 1

            elsif CXTRSSBhead >= CXBLSBH and CXBLSSBhead <= CXTRSBH and CYBLSSBhead >= CYBLSBH and CYTRSSBhead <= CYTRSBH then
                life := life - 1

            elsif CXTRSSBleftleg >= CXBLSBH and CXBLSSBleftleg <= CXTRSBH and CYBLSSBleftleg >= CYBLSBH and CYTRSSBleftleg <= CYTRSBH then
                life := life - 1

            elsif CXTRSSrightleg >= CXBLSBH and CXBLSSBrightleg <= CXTRSBH and CYBLSSBrightleg >= CYBLSBH and CYTRSSBrightleg <= CYTRSBH then
                life := life - 1

            elsif CXTRSSBleftshoe >= CXBLSBH and CXBLSSBleftshoe <= CXTRSBH and CYBLSSBleftshoe >= CYBLSBH and CYTRSSBleftshoe <= CYTRSBH then
                life := life - 1

            elsif CXTRSSrightshoe >= CXBLSBH and CXBLSSBrightshoe <= CXTRSBH and CYBLSSBrightshoe >= CYBLSBH and CYTRSSBrightshoe <= CYTRSBH then
                life := life - 1

                /*elsif x2 >= CXBLSBH and x1 <= CXTRSBH and y2 >= CYBLSBH and y1 <= CYTRSBH then
                 life := life - 1

                 elsif x2 >= CXBLSBH and x1 <= CXTRSBH and y2 >= CYBLSBH and y1 <= CYTRSBH then
                 life := life - 1

                 elsif x2 >= CXBLSBH and x1 <= CXTRSBH and y2 >= CYBLSBH and y1 <= CYTRSBH then
                 life := life - 1*/

            end if

        end loop


        var r, axle : int
        var h, k, x1 : real
        var xchange : int := 20
        const pi := 22 / 7
        r := 640
        k := 18
        x1 := r
        axle := 300
        loop
            x1 := x1 + xchange
            if x = 200 then
                xchange := xchange * -1
            end if

            if x = 0 then
                xchange := xchange * -1
            end if
            h := r * cos (k * x1) + axle
            drawfilloval (round (x1), round (h), 25, 25, black)
            put h
            %View.Update
            delay (100)
            cls
        end loop

    else
        c := 66
    end if
end loop




Please specify what version of Turing you are using
Turing 4.1
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Mon Dec 19, 2011 5:09 pm   Post subject: RE:Need Help with Collision and Screen Flickering

Quote:

fork ParticleGenerationBlaster

Well there's your problem. You can't have a forked loop that draws things to screen _and_ View.Update. Think a bit about what View.Update does and what fork does to figure out why those two are mutually exclusive.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Nablo




PostPosted: Mon Dec 19, 2011 5:19 pm   Post subject: Re: Need Help with Collision and Screen Flickering

I know that much but I don't know how to do it another way :/
Tony




PostPosted: Mon Dec 19, 2011 5:34 pm   Post subject: RE:Need Help with Collision and Screen Flickering

if you can't have both View.Update and fork, then you've got to remove at least one of them. Which would make more sense to take out?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Nablo




PostPosted: Mon Dec 19, 2011 5:45 pm   Post subject: Re: Need Help with Collision and Screen Flickering

The fork for sure but how else will I run the process?
Tony




PostPosted: Mon Dec 19, 2011 6:03 pm   Post subject: RE:Need Help with Collision and Screen Flickering

You... don't. There is no need for a process.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Nablo




PostPosted: Tue Dec 20, 2011 8:11 am   Post subject: Re: Need Help with Collision and Screen Flickering

Sorry, I was a little bit ill when I posted the last post. I meant to say how would I only execute the fork once when I press the spacebar and all other spacebar presses will effect the proccess itself and not start another fork.

EDIT: Actually, I think the better question to ask would be how to get all the View.Update's to synchronize with each other.
Insectoid




PostPosted: Tue Dec 20, 2011 9:17 am   Post subject: RE:Need Help with Collision and Screen Flickering

You don't. You don't use processes at all. You don't (and can't) synchronize View.Updates. You only need one. There are many, many threads explaining how to make things move at the same time. I suggest you search for them. There's probably even a few on the front page of Turing Help.
Sponsor
Sponsor
Sponsor
sponsor
Nablo




PostPosted: Tue Dec 20, 2011 1:23 pm   Post subject: Re: Need Help with Collision and Screen Flickering

I tried eliminating the processes and making one big program but that didnt work because of the nature of my bullet generation.
Aange10




PostPosted: Tue Dec 20, 2011 1:43 pm   Post subject: RE:Need Help with Collision and Screen Flickering

Look at this.

Turing:

View.Set ("offscreenonly")
for i : 1 .. maxx
    cls
    drawfilloval (maxx - 25 - i, maxx div 2 + 50, 25, 25, blue)
    drawfilloval (maxx - 25 - (i - 100), maxx div 2 - 50, 25, 25, red)
    View.Update
    Time.DelaySinceLast (17)
end for


You don't need a process to move multiple things. And if you wanted to add something else, we'll that's just ingenuity.

Turing:

View.Set ("offscreenonly")
var chars : array char of boolean
for i : 1 .. maxx
    cls
    Input.KeyDown (chars)
    if chars (chr(32)) = true then
        drawfilloval (maxx - 65 - i, maxx div 2, 25, 25, green)
    end if
    drawfilloval (maxx - 25 - i, maxx div 2 + 50, 20, 20, blue)
    drawfilloval (maxx - 25 - (i - 100), maxx div 2 - 50, 25, 25, red)
    View.Update
    Time.DelaySinceLast (17)
end for


There are many ways to do the same thing. With that aside, if you understand now that you don't need proccesses, then good. You're done with the first step.

I bet you next question is 'But Aange! How do I make bullets?", to which my response is: 'Search for it in the tutorial section and the help section. If anything, as a last resort, look in the submissions and see how they did it!'
Raknarg




PostPosted: Tue Dec 20, 2011 1:50 pm   Post subject: RE:Need Help with Collision and Screen Flickering

Well put. You see, the basic logic of animation in Turing is:

1. Set all the points of everything (bullets, characters, etc.)

You check the environment for certain conditions, such as a button being pressed or if a bullet hits an enemy, or an enemy hits you, if a bullet is live, etc. You calculate the next step for everything on screen

2. Draw everything in the same loop

After all the positions have been calculated, you can then draw them to the screen at it's new position. Processes are unessesary.

You're logic was probably "I need them all to move at the same time; I must use processes." However, that's not true. You need them to seem like they're moving at the same time. Therefore, if you calculate all the points and then draw them in a sequence, you'll get the same effect without the annoyance and unpredictability of processes.
Aange10




PostPosted: Tue Dec 20, 2011 2:16 pm   Post subject: RE:Need Help with Collision and Screen Flickering

And also, to add, proccess (unless ran on multiple cores) do not run at the same time, rather, they run EXTEREMLY fast between each process.
Nablo




PostPosted: Tue Dec 20, 2011 2:22 pm   Post subject: Re: Need Help with Collision and Screen Flickering

@Raknarg, how can I can everything in the same loop if my bullet generation is triggered by the pressing of a button. Now I know you might suggest "Well, then put an if statement to run the bullet generation if you press the button" but then the getch would prevent the next sequence of animation from taking place due to the getch. So I'm rather confused onto what to do. Btw, I saw how other people did their bullet generation and their variable system is much different from mine and because of that I cant understand some of their systems.
DemonWasp




PostPosted: Tue Dec 20, 2011 2:23 pm   Post subject: RE:Need Help with Collision and Screen Flickering

Actually, Turing's process implementation is entirely single-threaded at the OS level: Turing does all the task switching itself (and clumsily at that). That means that although those processes are running asynchronously from your "main" thread, they aren't running in parallel.
Tony




PostPosted: Tue Dec 20, 2011 2:57 pm   Post subject: Re: Need Help with Collision and Screen Flickering

Nablo @ Tue Dec 20, 2011 2:22 pm wrote:
the getch would prevent the next sequence of animation from taking place due to the getch.

Good point; so then you need to use non-blocking IO. Examples include Input.KeyDown or using hasch.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
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 2  [ 22 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: