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

Username:   Password: 
 RegisterRegister   
 How would you make the balls drop to the ground after drawing and make the other balls bounce off of the green balls??
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
InViZable




PostPosted: Sun Jan 16, 2011 6:19 pm   Post subject: How would you make the balls drop to the ground after drawing and make the other balls bounce off of the green balls??

What is it you are trying to achieve?
I am trying to allow the green balls fall down to the floor after drawing them


What is the problem you are having?
I can't get the balls to drop to the floor


Describe what you have tried to solve this problem
I have tried to rearrange loops, try new codes... basically everything


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

Turing:


setscreen ("graphics:640;480,nocursor")
%Declare Variables
var X, Y, B, r, count, xdir, ydir, xpos, ypos, xdir1, ydir1, xpos1, ypos1, mypic, xmouse, ymouse, bnumvar, budvar, font1, total,total1,total2,total3 : int
%Declare what each variable is
font1 := Font.New ("Serif:12")
mypic := Pic.FileNew ("grey.jpg")
r := 0
count := 15
xdir := 1
ydir := 2
xpos := 50
ypos := 100

xdir1 := 2
ydir1 := 2
xpos1 := 100
ypos1 := 45


%Process greenball
process greenball
    loop
        loop
        %Get mouse location
            Mouse.Where (X, Y, B)
            %Drawball
            if B = 1 and X < 620 and X > 20 and Y > 20 and Y < 400 then

                drawfilloval (X, Y, r, r, 2)
                drawoval (X, Y, r, r, 7)
                delay (20)
                drawfilloval (X, Y, r, r, 0)
                r := r + 1

            end if
            total := r + X
            total1:= r + Y
            total2:= Y- r
            total3:= X - r
            %Exit statment
            exit when B = 0 or r + X = 620 or X - r = 20 or r + Y = 400 or Y - r = 20
        end loop
%Draw the circles again
        drawfilloval (X, Y, r, r, 2)
        drawoval (X, Y, r, r, 7)
        delay (20)
        Y:=Y - 1
        %Reset the radius
        r := 0
        %total := r + X
    end loop
end greenball
%Draw the borders
drawfillbox (0, 0, 20, 480, 7)
drawfillbox (0, 0, 640, 20, 7)
drawfillbox (620, 0, 640, 480, 7)
drawfillbox (0, 400, 640, 480, 7)
drawfillbox (40, 430, 100, 450, 27)
Font.Draw ("Pause", 50, 435, font1, 0)
fork greenball
loop
%Get grey background
    Pic.Draw (mypic, 20, 20, picUnderMerge)
    %If statments for the bouncing balls
    if xpos >= 610 or xpos <= 30 then
        xdir *= -1
    end if
    if xpos1 >= 610 or xpos1 <= 30 then
        xdir1 *= -1
    end if
    if ypos >= 390 or ypos <= 30 then
        ydir *= -1
    end if
    if ypos1 >= 390 or ypos1 <= 30 then
        ydir1 *= -1
    end if

    xpos += xdir
    ypos += ydir
    xpos1 += xdir1
    ypos1 += ydir1
%Draw the balls moving around the screen
    drawfilloval (xpos, ypos, 10, 10, 255)
    delay (1)
    drawfilloval (xpos, ypos, 10, 10, 0)
    drawfilloval (xpos1, ypos1, 10, 10, 255)
    delay (1)
    drawfilloval (xpos1, ypos1, 10, 10, 0)
if xpos = total or xpos = total3 then
xdir *= -1
elsif ypos = total1 or ypos = total2 then
ydir *= -1
elsif ypos1 = total1 or ypos1 = total2 then
ydir *= -1
elsif xpos1 = total or xpos1 = total3 then
xdir *= -1
end if
end loop




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




PostPosted: Sun Jan 16, 2011 6:39 pm   Post subject: Re: How would you make the balls drop to the ground after drawing and make the other balls bounce off of the green balls

InViZable @ Sun Jan 16, 2011 6:19 pm wrote:

I can't get the balls to drop to the floor

Turing:

for decreasing y: maxy .. 0
   Draw.FillOval(100, y, 5, 5, green)
   delay(10)
end for

Dropped.
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 1  [ 2 Posts ]
Jump to:   


Style:  
Search: