
-----------------------------------
reckless
Fri May 06, 2005 12:07 pm

Breakout game, need advice
-----------------------------------
well this is my first year of turing, coming from C++ it is quite an odd change...

but yeah, im being forced to basically work on it for a mark so i can get my credit so im not complaining

basically ive tried to make a breakout game to hand in for my end of the year project so i need advice for how to make it better because there is alot of glitches in it right now heres the coding

setscreen ("offscreenonly")
var key : array char of boolean
var power1, power2, paddlex, paddley, xmod, ymod, ballx, bally, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6, x7, y7, x8, y8, x9, y9, x10, y10, x11, y11, x12, y12, x13, y13, x14, y14, x15, y15 : int
paddlex := 200
paddley := 10
power1 := 200
power2 := 10
xmod := 1
ymod := 1
ballx := Rand.Int (0, 180)
bally := Rand.Int (0, 180)
x1 := 400
y1 := 200
x2 := 300
y2 := 200
x3 := 200
y3 := 200
x4 := 100
y4 := 200
x5 := 400
y5 := 300
x6 := 300
y6 := 300
x7 := 200
y7 := 300
x8 := 100
y8 := 300
x9 := 400
y9 := 400
x10 := 300
y10 := 400
x11 := 200
y11 := 400
x12 := 100
y12 := 400
x13 := 300
y13 := 400
x14 := 200
y14 := 400
x15 := 100
y15 := 400


loop
    Draw.FillBox (0, 0, maxx, maxy, 0)
    Draw.FillBox (paddlex, paddley, paddlex - 100, paddley - 5, 12)
    Draw.FillOval (ballx, bally, 10, 10, 16)
    Input.KeyDown (key)
    ballx += xmod
    bally += ymod
    if ballx >= maxx then
        xmod := -xmod
    elsif ballx = maxy then
        ymod := -ymod
    elsif bally  paddlex - 100 and bally < paddley - 5 and bally < paddley then
        ymod *= -1
    end if
    Draw.FillBox (x1 - 10, y1 - 10, x1 + 80, y1 - 3, Rand.Int (1, 16))
    if ballx > x1 - 10 and ballx < x1 + 80 and bally > y1 - 10 and bally < y1 - 3 then
        ymod *= -1
        x1 := 0
        y1 := 0
    end if
    Draw.FillBox (x2 - 10, y2 - 10, x2 + 80, y2 - 3, Rand.Int (1, 16))
    if ballx > x2 - 10 and ballx < x2 + 80 and bally > y2 - 10 and bally < y2 - 3 then
        ymod *= -1
        x2 := 0
        y2 := 0
    end if
    Draw.FillBox (x3 - 10, y3 - 10, x3 + 80, y3 - 3, Rand.Int (1, 16))
    if ballx > x3 - 10 and ballx < x3 + 80 and bally > y3 - 10 and bally < y3 - 3 then
        ymod *= -1
        x3 := 0
        y3 := 0
    end if
    Draw.FillBox (x4 - 10, y4 - 10, x4 + 80, y4 - 3, Rand.Int (1, 16))
    if ballx > x4 - 10 and ballx < x4 + 80 and bally > y4 - 10 and bally < y4 - 3 then
        ymod *= -1
        x4 := 0
        y4 := 0
    end if
    Draw.FillBox (x5 - 10, y5 - 10, x5 + 80, y5 - 3, Rand.Int (1, 16))
    if ballx > x5 - 10 and ballx < x5 + 80 and bally > y5 - 10 and bally < y5 - 3 then
        ymod *= -1
        x5 := 0
        y5 := 0
    end if
    Draw.FillBox (x6 - 10, y6 - 10, x6 + 80, y6 - 3, Rand.Int (1, 16))
    if ballx > x6 - 10 and ballx < x6 + 80 and bally > y6 - 10 and bally < y6 - 3 then
        ymod *= -1
        x6 := 0
        y6 := 0
    end if
    Draw.FillBox (x7 - 10, y7 - 10, x7 + 80, y7 - 3, Rand.Int (1, 16))
    if ballx > x7 - 10 and ballx < x7 + 80 and bally > y7 - 10 and bally < y7 - 3 then
        ymod *= -1
        x7 := 0
        y7 := 0
    end if
    Draw.FillBox (x8 - 10, y8 - 10, x8 + 80, y8 - 3, Rand.Int (1, 16))
    if ballx > x8 - 10 and ballx < x8 + 80 and bally > y8 - 10 and bally < y8 - 3 then
        ymod *= -1
        x8 := 0
        y8 := 0
    end if
    Draw.FillBox (x9 - 10, y9 - 10, x9 + 80, y9 - 3, Rand.Int (1, 16))
    if ballx > x9 - 10 and ballx < x9 + 80 and bally > y9 - 10 and bally < y9 - 3 then
        ymod *= -1
        x9 := 0
        y9 := 0
    end if
    Draw.FillBox (x10 - 10, y10 - 10, x10 + 80, y10 - 3, Rand.Int (1, 16))
    if ballx > x10 - 10 and ballx < x10 + 80 and bally > y10 - 10 and bally < y10 - 3 then
        ymod *= -1
        x10 := 0
        y10 := 0
    end if
    Draw.FillBox (x11 - 10, y11 - 10, x11 + 80, y11 - 3, Rand.Int (1, 16))
    if ballx > x11 - 10 and ballx < x11 + 80 and bally > y11 - 10 and bally < y11 - 3 then
        ymod *= -1
        x11 := 0
        y11 := 0
    end if
    Draw.FillBox (x12 - 10, y12 - 10, x12 + 80, y12 - 3, Rand.Int (1, 16))
    if ballx > x12 - 10 and ballx < x12 + 80 and bally > y12 - 10 and bally < y12 - 3 then
        ymod *= -1
        x12 := 1
        y12 := 1
    end if
    Draw.FillBox (x13 - 10, y13 - 10, x13 + 80, y13 - 3, Rand.Int (1, 16))
    if ballx > x13 - 10 and ballx < x13 + 80 and bally > y13 - 10 and bally < y13 - 3 then
        ymod *= -1
        x13 := 0
        y13 := 0
    end if
    Draw.FillBox (x14 - 10, y14 - 10, x14 + 80, y14 - 3, Rand.Int (1, 16))
    if ballx > x14 - 10 and ballx < x14 + 80 and bally > y14 - 10 and bally < y14 - 3 then
        ymod *= -1
        x14 := 0
        y14 := 0
    end if
    Draw.FillBox (x15 - 10, y15 - 10, x15 + 80, y15 - 3, Rand.Int (1, 16))
    if ballx > x15 - 10 and ballx < x15 + 80 and bally > y15 - 10 and bally < y15 - 3 then
        ymod *= -1
        x15 := 0
        y15 := 0
    end if
    if whatdotcolour (ballx + 12, bally + 12) = 24 or whatdotcolour (ballx - 12, bally - 12) = -24 then
        xmod := -xmod
    end if
    if paddlex >= maxx - 7 then
        paddlex := paddlex - 1
    elsif paddlex 