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

Username:   Password: 
 RegisterRegister   
 my breakout game...
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
rhomer




PostPosted: Tue Jun 01, 2004 6:25 pm   Post subject: my breakout game...

This is my breakout game i just started

I have moved the code down below to save space
Sponsor
Sponsor
Sponsor
sponsor
SuperGenius




PostPosted: Tue Jun 01, 2004 6:51 pm   Post subject: (No subject)

Just your luck, My summative is super breakout. One thing that I would do right away is change the control to mouse; the gameplay is better. Also you have made it so the ball's path always has a slope of 1; this means that it is possible for the ball to settle onto a certain pattern, and it may never hit the last couple of bricks. Also you can make the x2 and y2 values for the paddle relative to x1 and y1, so there is only two numbers to manage instead of 4:

code:

Draw.FillBox(paddlex,paddley,paddlex+paddlesize, paddley+5,colour)


As for your question about the paddle: look at what I've done; a bit of debugging built in. I put in some put statements to see when certain code was executed. In the place where you have your boxes being drawn, there is a line that says
code:

ychange := -2


this is activated hundreds of times per second as you can see by the counter that I put it. Your detection for the paddle is good, but the y direction is being reset by the code for the boxes, it needs some work.
SuperGenius




PostPosted: Tue Jun 01, 2004 6:51 pm   Post subject: (No subject)

Just your luck, My summative is super breakout. One thing that I would do right away is change the control to mouse; the gameplay is better. Also you have made it so the ball's path always has a slope of 1; this means that it is possible for the ball to settle onto a certain pattern, and it may never hit the last couple of bricks. Also you can make the x2 and y2 values for the paddle relative to x1 and y1, so there is only two numbers to manage instead of 4:

code:

Draw.FillBox(paddlex,paddley,paddlex+paddlesize, paddley+5,colour)


As for your question about the paddle: look at what I've done; a bit of debugging built in. I put in some put statements to see when certain code was executed. In the place where you have your boxes being drawn, there is a line that says
code:

ychange := -2


this is activated hundreds of times per second as you can see by the counter that I put in it. Your detection for the paddle is good, but the y direction is being reset by the code for the boxes, it needs some work.
SuperGenius




PostPosted: Tue Jun 01, 2004 6:52 pm   Post subject: (No subject)

oops, how did that double post happen? oh well.
Paul




PostPosted: Tue Jun 01, 2004 7:00 pm   Post subject: (No subject)

Hehehe, my summative is breakout too, or part of it is, I already made the other game for the other part, and now Im on breakout. What I did was have a level editor which saves whatever level you make onto a text file and the actual game loads the text files and makes levels. Hehehe, now all I need to do is make powerups and level change.
rhomer




PostPosted: Tue Jun 01, 2004 7:30 pm   Post subject: (No subject)

Ok...I have updated it a bit. All the bugs are gone, i think...
Please give me advice on what to add...iff you had any (i was think of powerups and levels)...

code:

setscreen ("offscreenonly")
setscreen ("graphics:500;500")

const radius := 5
const paddley1 := 10
const paddley2 := 20
var chars : array char of boolean
var ballx, bally, xchange, ychange : int
var paddlex1, paddlex2 : int
var blockx1, blocky1, blockx2, blocky2 : int
var alreadyhit : array 1 .. 44 of boolean
var boxx1 : array 1 .. 44 of int
var boxy1 : array 1 .. 44 of int
var boxx2 : array 1 .. 44 of int
var boxy2 : array 1 .. 44 of int
var holding : boolean := true
var mousex, mousey, button : int

paddlex1 := (maxx div 2) - 40
paddlex2 := (maxx div 2) + 40
ballx := paddlex1 + 40
bally := paddley2 + 5
xchange := 0
ychange := 0
boxx1 (1) := 20
boxy1 (1) := maxy - 20
boxx2 (1) := 60
boxy2 (1) := maxy - 10

proc makeboxes
    for i : 1 .. 43
        if i = 9 then
            boxx1 (9) := 20
            boxx2 (9) := 60
            boxy1 (9) := maxy - 40
            boxy2 (9) := maxy - 30
        elsif i = 18 then
            boxx1 (18) := 20
            boxx2 (18) := 60
            boxy1 (18) := maxy - 60
            boxy2 (18) := maxy - 50
        elsif i = 27 then
            boxx1 (27) := 20
            boxx2 (27) := 60
            boxy1 (27) := maxy - 80
            boxy2 (27) := maxy - 70
        elsif i = 36 then
            boxx1 (36) := 20
            boxx2 (36) := 60
            boxy1 (36) := maxy - 100
            boxy2 (36) := maxy - 90
        end if
        boxx1 (i + 1) := boxx1 (i) + 60
        boxy1 (i + 1) := boxy1 (i)
        boxx2 (i + 1) := boxx2 (i) + 60
        boxy2 (i + 1) := boxy2 (i)

        alreadyhit (i) := false
    end for
end makeboxes


proc game
    loop
        Mouse.Where (mousex, mousey, button)
        Input.KeyDown (chars)
        ballx += xchange
        bally += ychange

        if ballx > (maxx - 5) then
            xchange *= -1
        elsif bally > (maxy - 5) then
            ychange := -2
        elsif bally < 0 then
            exit
        elsif ballx < 5 then
            xchange *= -1
        elsif bally < (paddley2 + 5) and bally > (paddley1) and ballx > paddlex1 and ballx < paddlex2 then
            if ballx < paddlex1 + 40 then
                ychange := 2
                xchange -= round (Math.Distance (paddlex1 + 40, bally, ballx, bally) / 10)
            elsif ballx > paddlex2 - 40 then
                ychange := 2
                xchange += round (Math.Distance (paddlex2 - 40, bally, ballx, bally) / 10)
            end if
        end if
        paddlex1 := mousex - 40
        paddlex2 := mousex + 40
        if button = 1 and holding = true then
            holding := false
            xchange := 2
            ychange := 2
        end if
        if holding = true then
            ballx := paddlex1 + 40
            bally := paddley2 + 5
        end if

        if paddlex1 < 0 then
            paddlex1 := 0
            paddlex2 := 80
        elsif paddlex2 > maxx then
            paddlex2 := maxx
            paddlex1 := maxx - 80
        end if

        for i : 1 .. 43
            drawfillbox (boxx1 (i), boxy1 (i), boxx2 (i), boxy2 (i), green)
            if (bally > boxy1 (i) - 5 and bally < boxy2 (i) and ballx > boxx1 (i) and ballx < boxx2 (i)) and alreadyhit (i) = false then
                alreadyhit (i) := true
                if ychange = 2 then
                    ychange := -2
                elsif ychange = -2 then
                    ychange := 2
                end if
            end if
            if alreadyhit (i) = true then
                drawfillbox (boxx1 (i), boxy1 (i), boxx2 (i), boxy2 (i), white)
            end if
        end for

        drawfilloval (ballx, bally, radius, radius, red)
        drawfillbox (paddlex1, paddley1, paddlex2, paddley2, blue)
        delay (5)
        View.Update
        cls
    end loop
end game

makeboxes

loop
    game
    if bally < 0 then
        exit
    end if
end loop


cls
put "YOU LOST"
View.Update
SuperGenius




PostPosted: Tue Jun 01, 2004 8:17 pm   Post subject: (No subject)

you could make a level editor... curiously, paul and I seem to have done the same thing. I made powerups for my game already, but I had to take off the through effect cause the powerups messed up. Ill probably program a fix so that I can put it back in though.

Paul: Can I see your editor, to compare with mine?
Paul




PostPosted: Tue Jun 01, 2004 8:31 pm   Post subject: (No subject)

My editor is very basic, just using drawfill and whatdotcolor to find the values for the 2d array of boolean, and then it inputs that as 0's or 1's on the text file, I think Im going to add blocks with different properties later, but thats if I have time. I have a better version at school, where you choose numbers of rows, but that isn't very different from this one.


blockedit.t
 Description:

Download
 Filename:  blockedit.t
 Filesize:  800 Bytes
 Downloaded:  263 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
noobprogrammer123




PostPosted: Tue Jun 01, 2004 9:09 pm   Post subject: (No subject)

Why doesn't Math.Distance work, is it just me?
rhomer




PostPosted: Tue Jun 01, 2004 9:35 pm   Post subject: (No subject)

thanks paul bian....


and noob, do you have version 4.0.5?
SuperGenius




PostPosted: Wed Jun 02, 2004 3:02 pm   Post subject: (No subject)

nice work paul. I think it would be more interesting though if it alllowed people to make blocks in different colours; thats what mine does... it outputs the colour number to the text file, and the game doesnt do anything if it reads a 0. Also this lets people choose the colour white to erase any bricks that they dont want, so they dont have to close the program and start all over.
Paul




PostPosted: Wed Jun 02, 2004 3:41 pm   Post subject: (No subject)

Yea, I made that already, 3 different kinds of blocks, 3 different colors, orange block when hit turns to purple, and purple block when hit turns to green, and green dissappears after being hit. Made it this morning in the library while the grade 9's had their exam in the caf.
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  [ 12 Posts ]
Jump to:   


Style:  
Search: