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

Username:   Password: 
 RegisterRegister   
 Rays and atoms bounce
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
fdsafdsa




PostPosted: Sun Feb 19, 2006 3:36 pm   Post subject: Rays and atoms bounce

I need some one to fix my rays program it wont bounce off the attom can anyone make my prog shorter so the rays can all be same and not serperated thanks i really need help
SadSadSadSad
HERES MY CODE

code:

setscreen ("graphics:600;600,title:Laser Atoms KABOOM")
const pic := Pic.FileNew ("/Computer Science/Turing Pcitures/atom.jpg")
const pic2 := Pic.FileNew ("/Computer Science/Turing Pcitures/raygun.jpg")
const pic3 := Pic.FileNew ("/Computer Science/Turing Pcitures/raygun2.jpg")
const pic4 := Pic.FileNew ("/Computer Science/Turing Pcitures/raygun3.jpg")
const pic5 := Pic.FileNew ("/Computer Science/Turing Pcitures/raygun4.jpg")
var g : int := 145
var h : int := 145
cls

var typeatom : array 1 .. 25 of int
var num : int := 1
var num2 := 100
var num3 := 100
var grid : array 1 .. 10, 1 .. 10 of int
for a : 1 .. 10
    for b : 1 .. 10
        grid (a, b) := num2
        num2 := num2 + 40
        drawbox (num3, grid (a, b), num3 + 40, grid (a, b) + 40, black)
    end for
    num2 := 100
    num3 += 40
end for

var a : int
var b : int
var num6 : int := 1
loop
    randint (a, 2, 9)
    randint (b, 2, 9)
    grid (a, b) := pic
    var num4, num5 : int := 143
    for c : 2 .. 10
        for d : 2 .. 10
            if a = c and b = d then
                Pic.Draw (grid (a, b), num4, num5, picCopy)
            elsif a = c and b not= d then
                num5 += 40
            elsif a not= c and b = d then
                num4 += 40
            end if
        end for
    end for
    num6 += 1
    exit when num6 = 11
end loop

var count := 0
Pic.Draw (pic2, -150, 85, picCopy)
var picount : int := 0
var cdist : int := 100
var x, y, button : int

var mx2, my2, btn : int
var dist : int := 100
var dist1 : int := 100
var dist2 : int := 40
var dist3 : int := 120
var dist4 : int := 40
var count2 := 0
var col : int := 10
proc BottomLasers


    if mx2 >= dist and mx2 <= dist2 + dist and my2 <= 100 and btn = 1 then
        for a : 1 .. 10
            randint (col, 1, 250)
            drawfillbox (dist3, 100, dist3 + 1, dist1, red)
            dist1 := dist1 + 1
            count2 := 1
        end for
    else
        if count2 = 1 then
            dist := dist + dist2
            dist3 := dist3 + dist4
            dist1 := 100
            count2 := 0
        elsif mx2 >= dist and mx2 <= dist + 40 then
            loop
                dist := dist + dist2
                dist3 := dist3 + dist4
                count2 := 0
                exit when dist3 = 500
            end loop
        end if
    end if

    if mx2 <= dist and mx2 <= dist - dist2 and btn = 1 then
        loop
            dist := dist - dist2
            dist3 := dist3 - dist4
            exit when mx2 >= dist and mx2 <= dist2 + dist

        end loop
    end if



end BottomLasers

proc RightLasers
    loop
        if my2 >= dist and my2 <= dist2 + dist and mx2 >= 500 and btn = 1 then
            for a : 1 .. 10
                randint (col, 1, 250)
                drawfillbox (500, dist3, dist1, dist3 - 1, red)
                dist1 := dist1 - 1
                count2 := 1
            end for
        else
            if count2 = 1 then
                dist := dist + dist2
                dist3 := dist3 + dist4
                dist1 := 500
                count2 := 0
            elsif mx2 >= dist and mx2 <= dist + 40 then
                loop
                    dist := dist + dist2
                    dist3 := dist3 + dist4
                    count2 := 0
                    exit when dist3 = 500
                end loop
            end if
        end if

        if my2 <= dist and my2 <= dist - dist2 and btn = 1 then
            loop
                dist := dist - dist2
                dist3 := dist3 - dist4
                exit when my2 >= dist and my2 <= dist2 + dist
            end loop
        end if
        if dist = 500 then
            dist := 100
            dist1 := 100
            dist2 := 40
            dist3 := 120
            dist4 := 40
            count2 := 0
            col := 0
        end if
        exit when btn = 1
    end loop

end RightLasers

proc TopLasers

    loop
        if mx2 <= dist + 400 and mx2 >= dist + 400 - dist2 and my2 >= 500 and btn = 1 then
            for a : 1 .. 10
                randint (col, 1, 250)
                drawfillbox (dist3 + 360, 500, dist3 + 360 - 1, dist1, red)
                dist1 := dist1 - 1
                count2 := 1
            end for
        else
            if count2 = 1 then
                dist := dist - dist2
                dist3 := dist3 - dist4
                dist1 := 500
                count2 := 0
            elsif mx2 <= dist and mx2 <= dist + 40 then
                loop
                    dist := dist + dist2
                    dist3 := dist3 + dist4
                    count2 := 0
                    exit
                end loop
            end if
        end if

        if mx2 >= dist + 400 and mx2 >= dist + 400 + dist2 and btn = 1 then
            loop
                dist := dist + dist2
                dist3 := dist3 + dist4
                exit when mx2 >= dist and mx2 <= dist2 + dist
            end loop
        end if
        exit when btn = 1
    end loop
    if dist1 = 100 and mx2 >= 100 and mx2 <= 140 then
        dist := 100
        dist1 := 100
        dist2 := 40
        dist3 := 120
        dist4 := 40
        count2 := 0
        col := 0
    end if
end TopLasers

proc LeftLasers

    loop
        if my2 <= dist + 400 and my2 >= dist + 400 - dist2 and mx2 <= 400 and btn = 1 then
            for a : 1 .. 10
                randint (col, 1, 250)
                drawfillbox (100, dist3 + 360, dist1, dist3 + 360 - 1, red)
                dist1 := dist1 + 1
                count2 := 1
            end for
        else
            if count2 = 1 then
                dist := dist - dist2
                dist3 := dist3 - dist4
                dist1 := 100
                count2 := 0
            elsif mx2 <= dist and mx2 <= dist + 40 then
                loop
                    dist := dist + dist2
                    dist3 := dist3 + dist4
                    count2 := 0
                    exit
                end loop
            end if
        end if

        if my2 >= dist + 400 and my2 >= dist + 400 + dist2 and btn = 1 then
            loop
                dist := dist + dist2
                dist3 := dist3 + dist4
                exit when my2 >= dist and my2 <= dist2 + dist
            end loop
        end if
        exit when btn = 1
    end loop
end LeftLasers

proc Check




end Check



View.Set ("offscreenonly")
loop
    delay (10)
    mousewhere (mx2, my2, btn)
    locate (1, 1)

    if mx2 <= 100 then
        if btn = 1 then
            LeftLasers
        end if

        drawfillbox (0, 0, 99, 600, white)
        drawfillbox (0, 0, 600, 100, white)
        drawfillbox (501, 0, 600, 600, white)
        drawfillbox (0, 500, 600, 600, white)
        drawfillbox (100, 100, 100, 500, black)
        drawfillbox (500, 100, 500, 500, black)
        drawfillbox (100, 100, 500, 100, black)
        drawfillbox (100, 500, 500, 500, black)
        Pic.Draw (pic2, mx2 - 90, my2 - 38, picCopy)

        if btn = 0 then
            put mx2 : 4, "  ", my2 : 4
        else
            put mx2 : 4, "  ", my2 : 4
        end if

    elsif mx2 >= 100 and mx2 <= 500 and my2 <= 100 then
        drawfillbox (0, 0, 99, 600, white)
        drawfillbox (0, 0, 600, 100, white)
        if btn = 1 then
            BottomLasers
        end if
        drawfillbox (501, 0, 600, 600, white)
        drawfillbox (0, 500, 600, 600, white)
        drawfillbox (100, 100, 100, 500, black)
        drawfillbox (500, 100, 500, 500, black)
        drawfillbox (100, 100, 500, 100, black)
        drawfillbox (100, 500, 500, 500, black)
        Pic.Draw (pic3, mx2 - 19, my2 - 90, picCopy)
        if btn = 0 then
            put mx2 : 4, "  ", my2 : 4
        else
            put mx2 : 4, "  ", my2 : 4
        end if
    elsif mx2 >= 502 then
        if btn = 1 then
            RightLasers
        end if
        drawfillbox (0, 0, 99, 600, white)
        drawfillbox (0, 0, 600, 100, white)
        drawfillbox (501, 0, 600, 600, white)
        drawfillbox (0, 500, 600, 600, white)
        drawfillbox (100, 100, 100, 500, black)
        drawfillbox (500, 100, 500, 500, black)
        drawfillbox (100, 100, 500, 100, black)
        drawfillbox (100, 500, 500, 500, black)
        Pic.Draw (pic4, mx2, my2 - 35, picCopy)
        if btn = 0 then
            put mx2 : 4, "  ", my2 : 4
        else
            put mx2 : 4, "  ", my2 : 4
        end if
    elsif mx2 <= 500 and my2 >= 501 then
        if btn = 1 then
            TopLasers
        end if
        drawfillbox (0, 0, 99, 600, white)
        drawfillbox (0, 0, 600, 100, white)
        drawfillbox (501, 0, 600, 600, white)
        drawfillbox (0, 500, 600, 600, white)
        drawfillbox (100, 100, 100, 500, black)
        drawfillbox (500, 100, 500, 500, black)
        drawfillbox (100, 100, 500, 100, black)
        drawfillbox (100, 500, 500, 500, black)
        Pic.Draw (pic5, mx2 - 15, my2, picCopy)
        if btn = 0 then
            put mx2 : 4, "  ", my2 : 4
        else
            put mx2 : 4, "  ", my2 : 4
        end if
    else
        drawfillbox (0, 0, 99, 600, white)
        drawfillbox (0, 0, 600, 100, white)
        drawfillbox (501, 0, 600, 600, white)
        drawfillbox (0, 500, 600, 600, white)
        drawfillbox (100, 100, 100, 500, black)
        drawfillbox (500, 100, 500, 500, black)
        drawfillbox (100, 100, 500, 100, black)
        drawfillbox (100, 500, 500, 500, black)
        if btn = 0 then
            put mx2 : 4, "  ", my2 : 4
        else
            put mx2 : 4, "  ", my2 : 4
        end if
    end if
    View.Update

[code][/code][code][/code][code][/code][code][/code]
setscreen ("graphics:600;600,title:Laser Atoms KABOOM")
const pic := Pic.FileNew ("/Computer Science/Turing Pcitures/atom.jpg")
const pic2 := Pic.FileNew ("/Computer Science/Turing Pcitures/raygun.jpg")
const pic3 := Pic.FileNew ("/Computer Science/Turing Pcitures/raygun2.jpg")
const pic4 := Pic.FileNew ("/Computer Science/Turing Pcitures/raygun3.jpg")
const pic5 := Pic.FileNew ("/Computer Science/Turing Pcitures/raygun4.jpg")
var g : int := 145
var h : int := 145
cls

var typeatom : array 1 .. 25 of int
var num : int := 1
var num2 := 100
var num3 := 100
var grid : array 1 .. 10, 1 .. 10 of int
for a : 1 .. 10
    for b : 1 .. 10
        grid (a, b) := num2
        num2 := num2 + 40
        drawbox (num3, grid (a, b), num3 + 40, grid (a, b) + 40, black)
    end for
    num2 := 100
    num3 += 40
end for

var a : int
var b : int
var num6 : int := 1
loop
    randint (a, 2, 9)
    randint (b, 2, 9)
    grid (a, b) := pic
    var num4, num5 : int := 143
    for c : 2 .. 10
        for d : 2 .. 10
            if a = c and b = d then
                Pic.Draw (grid (a, b), num4, num5, picCopy)
            elsif a = c and b not= d then
                num5 += 40
            elsif a not= c and b = d then
                num4 += 40
            end if
        end for
    end for
    num6 += 1
    exit when num6 = 11
end loop

var count := 0
Pic.Draw (pic2, -150, 85, picCopy)
var picount : int := 0
var cdist : int := 100
var x, y, button : int

var mx2, my2, btn : int
var dist : int := 100
var dist1 : int := 100
var dist2 : int := 40
var dist3 : int := 120
var dist4 : int := 40
var count2 := 0
var col : int := 10
proc BottomLasers


    if mx2 >= dist and mx2 <= dist2 + dist and my2 <= 100 and btn = 1 then
        for a : 1 .. 10
            randint (col, 1, 250)
            drawfillbox (dist3, 100, dist3 + 1, dist1, red)
            dist1 := dist1 + 1
            count2 := 1
        end for
    else
        if count2 = 1 then
            dist := dist + dist2
            dist3 := dist3 + dist4
            dist1 := 100
            count2 := 0
        elsif mx2 >= dist and mx2 <= dist + 40 then
            loop
                dist := dist + dist2
                dist3 := dist3 + dist4
                count2 := 0
                exit when dist3 = 500
            end loop
        end if
    end if

    if mx2 <= dist and mx2 <= dist - dist2 and btn = 1 then
        loop
            dist := dist - dist2
            dist3 := dist3 - dist4
            exit when mx2 >= dist and mx2 <= dist2 + dist

        end loop
    end if



end BottomLasers

proc RightLasers
    loop
        if my2 >= dist and my2 <= dist2 + dist and mx2 >= 500 and btn = 1 then
            for a : 1 .. 10
                randint (col, 1, 250)
                drawfillbox (500, dist3, dist1, dist3 - 1, red)
                dist1 := dist1 - 1
                count2 := 1
            end for
        else
            if count2 = 1 then
                dist := dist + dist2
                dist3 := dist3 + dist4
                dist1 := 500
                count2 := 0
            elsif mx2 >= dist and mx2 <= dist + 40 then
                loop
                    dist := dist + dist2
                    dist3 := dist3 + dist4
                    count2 := 0
                    exit when dist3 = 500
                end loop
            end if
        end if

        if my2 <= dist and my2 <= dist - dist2 and btn = 1 then
            loop
                dist := dist - dist2
                dist3 := dist3 - dist4
                exit when my2 >= dist and my2 <= dist2 + dist
            end loop
        end if
        if dist = 500 then
            dist := 100
            dist1 := 100
            dist2 := 40
            dist3 := 120
            dist4 := 40
            count2 := 0
            col := 0
        end if
        exit when btn = 1
    end loop

end RightLasers

proc TopLasers

    loop
        if mx2 <= dist + 400 and mx2 >= dist + 400 - dist2 and my2 >= 500 and btn = 1 then
            for a : 1 .. 10
                randint (col, 1, 250)
                drawfillbox (dist3 + 360, 500, dist3 + 360 - 1, dist1, red)
                dist1 := dist1 - 1
                count2 := 1
            end for
        else
            if count2 = 1 then
                dist := dist - dist2
                dist3 := dist3 - dist4
                dist1 := 500
                count2 := 0
            elsif mx2 <= dist and mx2 <= dist + 40 then
                loop
                    dist := dist + dist2
                    dist3 := dist3 + dist4
                    count2 := 0
                    exit
                end loop
            end if
        end if

        if mx2 >= dist + 400 and mx2 >= dist + 400 + dist2 and btn = 1 then
            loop
                dist := dist + dist2
                dist3 := dist3 + dist4
                exit when mx2 >= dist and mx2 <= dist2 + dist
            end loop
        end if
        exit when btn = 1
    end loop
    if dist1 = 100 and mx2 >= 100 and mx2 <= 140 then
        dist := 100
        dist1 := 100
        dist2 := 40
        dist3 := 120
        dist4 := 40
        count2 := 0
        col := 0
    end if
end TopLasers

proc LeftLasers

    loop
        if my2 <= dist + 400 and my2 >= dist + 400 - dist2 and mx2 <= 400 and btn = 1 then
            for a : 1 .. 10
                randint (col, 1, 250)
                drawfillbox (100, dist3 + 360, dist1, dist3 + 360 - 1, red)
                dist1 := dist1 + 1
                count2 := 1
            end for
        else
            if count2 = 1 then
                dist := dist - dist2
                dist3 := dist3 - dist4
                dist1 := 100
                count2 := 0
            elsif mx2 <= dist and mx2 <= dist + 40 then
                loop
                    dist := dist + dist2
                    dist3 := dist3 + dist4
                    count2 := 0
                    exit
                end loop
            end if
        end if

        if my2 >= dist + 400 and my2 >= dist + 400 + dist2 and btn = 1 then
            loop
                dist := dist + dist2
                dist3 := dist3 + dist4
                exit when my2 >= dist and my2 <= dist2 + dist
            end loop
        end if
        exit when btn = 1
    end loop
end LeftLasers

proc Check




end Check



View.Set ("offscreenonly")
loop
    delay (10)
    mousewhere (mx2, my2, btn)
    locate (1, 1)

    if mx2 <= 100 then
        if btn = 1 then
            LeftLasers
        end if

        drawfillbox (0, 0, 99, 600, white)
        drawfillbox (0, 0, 600, 100, white)
        drawfillbox (501, 0, 600, 600, white)
        drawfillbox (0, 500, 600, 600, white)
        drawfillbox (100, 100, 100, 500, black)
        drawfillbox (500, 100, 500, 500, black)
        drawfillbox (100, 100, 500, 100, black)
        drawfillbox (100, 500, 500, 500, black)
        Pic.Draw (pic2, mx2 - 90, my2 - 38, picCopy)

        if btn = 0 then
            put mx2 : 4, "  ", my2 : 4
        else
            put mx2 : 4, "  ", my2 : 4
        end if

    elsif mx2 >= 100 and mx2 <= 500 and my2 <= 100 then
        drawfillbox (0, 0, 99, 600, white)
        drawfillbox (0, 0, 600, 100, white)
        if btn = 1 then
            BottomLasers
        end if
        drawfillbox (501, 0, 600, 600, white)
        drawfillbox (0, 500, 600, 600, white)
        drawfillbox (100, 100, 100, 500, black)
        drawfillbox (500, 100, 500, 500, black)
        drawfillbox (100, 100, 500, 100, black)
        drawfillbox (100, 500, 500, 500, black)
        Pic.Draw (pic3, mx2 - 19, my2 - 90, picCopy)
        if btn = 0 then
            put mx2 : 4, "  ", my2 : 4
        else
            put mx2 : 4, "  ", my2 : 4
        end if
    elsif mx2 >= 502 then
        if btn = 1 then
            RightLasers
        end if
        drawfillbox (0, 0, 99, 600, white)
        drawfillbox (0, 0, 600, 100, white)
        drawfillbox (501, 0, 600, 600, white)
        drawfillbox (0, 500, 600, 600, white)
        drawfillbox (100, 100, 100, 500, black)
        drawfillbox (500, 100, 500, 500, black)
        drawfillbox (100, 100, 500, 100, black)
        drawfillbox (100, 500, 500, 500, black)
        Pic.Draw (pic4, mx2, my2 - 35, picCopy)
        if btn = 0 then
            put mx2 : 4, "  ", my2 : 4
        else
            put mx2 : 4, "  ", my2 : 4
        end if
    elsif mx2 <= 500 and my2 >= 501 then
        if btn = 1 then
            TopLasers
        end if
        drawfillbox (0, 0, 99, 600, white)
        drawfillbox (0, 0, 600, 100, white)
        drawfillbox (501, 0, 600, 600, white)
        drawfillbox (0, 500, 600, 600, white)
        drawfillbox (100, 100, 100, 500, black)
        drawfillbox (500, 100, 500, 500, black)
        drawfillbox (100, 100, 500, 100, black)
        drawfillbox (100, 500, 500, 500, black)
        Pic.Draw (pic5, mx2 - 15, my2, picCopy)
        if btn = 0 then
            put mx2 : 4, "  ", my2 : 4
        else
            put mx2 : 4, "  ", my2 : 4
        end if
    else
        drawfillbox (0, 0, 99, 600, white)
        drawfillbox (0, 0, 600, 100, white)
        drawfillbox (501, 0, 600, 600, white)
        drawfillbox (0, 500, 600, 600, white)
        drawfillbox (100, 100, 100, 500, black)
        drawfillbox (500, 100, 500, 500, black)
        drawfillbox (100, 100, 500, 100, black)
        drawfillbox (100, 500, 500, 500, black)
        if btn = 0 then
            put mx2 : 4, "  ", my2 : 4
        else
            put mx2 : 4, "  ", my2 : 4
        end if
    end if
    View.Update
end loop
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: