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 My Brick Breaker Turing Game
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Coult.49




PostPosted: Tue Jun 03, 2014 7:50 am   Post subject: Need Help With My Brick Breaker Turing Game

What is it you are trying to achieve?
i am trying to make it so when the ball hits red bricks they disappear


What is the problem you are having?
when the ball hits the red bricks they do not disapear and everything still stays the same


Describe what you have tried to solve this problem
i have tried to implement a collision detection between the red bricks and the ball


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

Turing:


var x, y : int
var x1, y1 : int
var move : string (1)
var isball : boolean := false
var numball : int := 0
var yball : int := 1
var col, row : int := 0
var bricklist : array 1 .. 5, 1 .. 9 of int
const movement := 22
const dist := 5
var xx := 100
var yy := 15
x := 200
y := 0
x1 := 310
y1 := 20
var ballx, bally, xmod, ymod : int := 200
xmod := 1
ymod := 1
var drawx : int := 10
var drawy : int := 363


for a : 1 .. 5
    for b : 1 .. 9
        bricklist (a, b) := 1
    end for
end for




loop


    drawx := 10
    drawy := 363
    for a : 1 .. 5
        for b : 1 .. 9
            if bricklist (a, b) = 1 then
                drawfillbox (drawx, drawy, drawx + 60, drawy + 17, red)
                drawx := drawx + 70
            end if
        end for
        drawx := 10
        drawy := drawy - 30
    end for

    if hasch then
        getch (move); %Get Input
        if move = chr (203) and x > 5 then
            drawfillbox (x, y, x1, y1, 0)
            x := x - 7
            x1 := x1 - 7
        elsif move = chr (205) and x < 520 then
            drawfilloval (x, y, x1, y1, 0)
            x := x + 7
            x1 := x1 + 7
        end if
    end if
    ballx += xmod
    bally += ymod
    if ballx + 10 >= maxx then
        xmod := -1
    elsif ballx - 10 <= 0 then
        xmod := 1
    end if
    if bally + 10 >= maxy then
        ymod := -1
    elsif bally - 10 <= 0 then
        ymod := 1
    end if
    drawfillbox (x, y, x1, y1, black)
    drawfilloval (ballx, bally, 10, 10, 12)
    delay (7)
    drawfilloval (ballx, bally, 10, 10, 0)

    if whatdotcolour (ballx, bally - 11) = black then
        ymod := 1
    end if

    if bally + 10 >= maxy then
        ymod := -1
    elsif bally - 10 <= 0 then
        ymod := 1
    end if
    if whatdotcolour (ballx, bally + 11) = red then
        ymod := -1
        if ballx >= 10 and ballx <= 70 then

            bricklist (5, 1) := 0

        elsif ballx >= 80 and ballx <= 140 then
            bricklist (5, 2) := 0
        end if
    end if

end loop




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




PostPosted: Tue Jun 03, 2014 10:48 am   Post subject: Re: Need Help With My Brick Breaker Turing Game

Since you are using whatdotcolour to detect collisions, you should be able to solve the issue by simply drawing over the brick with white. I noticed you have vertical redirection implemented, but make sure you add detection for horizontal as well for when the ball hits the side of a block.
Tony




PostPosted: Tue Jun 03, 2014 12:03 pm   Post subject: RE:Need Help With My Brick Breaker Turing Game

If I'm reading this correctly, then only blocks (5, 1) and (5, 2) are.

As Srlancelot39 points out, if the blocks are not cleared from the screen, the collision check would still determine that something is there.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
way2smrt




PostPosted: Wed Jun 04, 2014 6:41 pm   Post subject: Re: Need Help With My Brick Breaker Turing Game

Just going to point out that you can reduce lag in your game by using View.Update. Just open a window, and have ;offscreenonly in the setup string. http://compsci.ca/holtsoft/doc/window_open.html Then when you want to update what you drew to the screen, just call View.Update
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  [ 4 Posts ]
Jump to:   


Style:  
Search: