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 Previous  1, 2
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Nablo




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

How would I use Input Key Down with things like spacebars?
Sponsor
Sponsor
Sponsor
sponsor
Aange10




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

Use the ASCII values. In the program I showed you, thats what I did.

Turing:

if chars (chr(32)) = true then


KeyCodes
DemonWasp




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

Or, you could do things the obvious way:

Turing:
if chars(' ') then
Nablo




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

One thing I noticed is that I need the ball to be going in an set motion (which would require a loop) and I also need the character to be moving at the same time. I did this before using a process. Now that I eliminated using a process due to the "one view update" rule, how would I achieve the same effect?
Tony




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

move the ball and the character within the same single loop.
code:

loop
   move_ball
   move_character
   move_whatever_else

   draw_everything
   View.Update
   delay
   cls
end loop
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
DemonWasp




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

This is a common problem, so consider searching the forums for more details. The skeleton, however, looks like this:

code:

loop
    clear screen
    move everything a little
    draw everything in its current position
    View.Update
    Time.DelaySinceLast ( 50 )
end loop


That will lock your game to a maximum of 20 frames per second (pushing it, for Turing in most cases), and will let you move multiple things at the same time. Move everything a small amount, but consistent with its speed: each step is 50 milliseconds. A human walking moves about 1m/s, so they would move 1 * 0.05 = 5cm during that time; a car on a highway travels something like 30m/s, so it would move 30 * 0.05 = 1.5m in that time.
Nablo




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

Thanks guys! With your help and patience I managed to solve the flickering problem, but now because of that a new problem arose -> the weird update problem. Try running my program and see what I mean... I know which part of the program is causing the problem but I don't know how it is causing the problem.

Here is my refurbished program with the problematic section bolded:

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 : int
var speed : int := 1
var counter : int := 0
var chars : array char of boolean



% 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

% 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

% Declare and Assign Values to Scrap Boy's 'Particles'

var xe : int := CXRSBarm
var ye : int := CYSBarm + ((CYRSBarm - CYSBarm) div 2)

% Declare and Assign Values to Blaster's 'Particles'

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

xp (1) := CXB - 100
yp (1) := CYB
xp (2) := CXB - 100
yp (2) := CYB
xp (3) := CXB - 100
yp (3) := CYB
xp (4) := CXB - 100
yp (4) := CYB
xp (5) := CXB - 100
yp (5) := CYB
xp (6) := CXB - 100
yp (6) := CYB

process music

    loop
        play (">>>4e<egb>ef+1g2p4d<df+a>de1f+2p")
        play ("2<bbbba>d<4f+<f+b>c+de1f+2p")
        play ("2eeeedg1c2p")
        play ("<4fcfgsa>c2d4p<a>de2fed2c4pd2c<1a")
        play ("4a>c2d4p<a>de2fefg4pf2g1a2p")
        play (">2f+4pc+f+g+2ag+f+e4pf+2e1c+")
        play ("<<4ab>2c+c+c+c+<b>e<1a4g+e")
        play ("8f+<a>def+a>ded<def+a>d6f+<f+a>df+a>df+a>df+da<f+d<af+d<af+d<af+d")
        play (">>>2g<6gab->dgab->c2ddc<b-a<6fga>cfga>cf2f6<<defa>defa>d<afd<afd<a>>1b>2f+1f+2p")
        play ("<1a>2e1e<<6b>c+ef+g+ab>c+1e-")
        play ("<6f+g+b-b>c+e-ef+1bpp<<<e2bbag1f+>2d6<df+a+>1dpp")
        play ("2d<b-g1f>2c<e-4pc2e-4f<fa>cfga<a>cfab->c<fa>cfgacfgab->1c")
    end loop

end music

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




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

        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 music

        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)

            Input.KeyDown (chars)

            cls

            % 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)

            % Movement Condition for Scrap Boy

            if chars (KEY_UP_ARROW) then
                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

            elsif chars (KEY_DOWN_ARROW) then
                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

            elsif chars (KEY_LEFT_ARROW) then
                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
            elsif chars (KEY_RIGHT_ARROW) then
                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

            end if

            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)


            %ParticleGenerationBlaster

            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 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)

            % 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)

            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


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



            [b]if chars (chr (32)) = true then

                counter += 1

            end if

            if counter = 1 then

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

                xe := xe + speed

                drawfilloval (xe, ye, 10 + 3, 10 + 3, yellow)
                drawfilloval (xe, ye, 10, 10, red)

                if xe = 650 then
                    xe := CXRSBarm
                    counter -= 1

                end if[/b]



                put life, counter

                View.Update

                %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 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
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 2 of 2  [ 22 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: