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 Brick breaker
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
LastDance




PostPosted: Fri Jan 18, 2013 6:21 pm   Post subject: Need help with Brick breaker

I need help making the ball bounce off the paddle and how should I draw the blocks/make the ball hit the bricks

This is my code so far

setscreen ("graphics:640;480, nocursor")
%%%%%%%%%%%%%%%%%%%variables%%%%%%%%%%%%%%%%%%%%%%%%%
var x, y, px, py, x1, y1, x2, y2 : int
var counter := 0
var chars : array char of boolean
var dx, dy := 1
x := 100
y := 25
px := 60
py := 10
x1 := 320
y1 := 240
x2 := 200
y2 := 200
%%%%%%%%%%%%%%Paddle movment%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
process paddle
loop
Input.KeyDown (chars)
Draw.FillBox (x, y, x + px, py, brightred)
delay (25)
Draw.FillBox (x, y, x + px, py, colourbg)
if chars (KEY_RIGHT_ARROW) and x < 570
then
x := x + 10
end if
if chars (KEY_LEFT_ARROW) and x > 10
then
x := x - 10
end if
end loop
end paddle
%%%%%%%%%%%%%%%%%%Brickers%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%Ball%%%%%%%%%%%%%%%%%%%%%%%%%
process baller
%%%%%%%Border%%%%%%
Draw.Box (9, 9, 631, 451, green)
%%%%%%End of Border%%%%%%%%%%
loop
%%%%%%%%%Bouncing and keeping the ball in the border%%%%%
x2 += dx
y2 += dy
drawfilloval (x2, y2, 10, 10, blue)
delay (5)
drawfilloval (x2, y2, 10, 10, colourbg)
if x2 > maxx - 25 or x2 < 26 then
dx := -dx
end if
if y2 > maxy - 45 then
dy := -dy
end if

%%%%%%End of Bouncing and keeping the ball in the border%%%%%
%%%%%%%Bouncing.. the ball on the paddle%%%%%%%%%%%%

%%%%%%%%Messed up code%%%%%%%%%%%
if x + y = x2 then
dy := -dy
end if
if y + x = x2 then
dx := -dx
end if

end loop
%%%%%%%End of Bouncing th ball on the paddle%%%%%%%%%%%%
end baller
%%

%%%%%%%%%%%%%%%Main Program%%%%%%%%%%%%%%%%%%%%%%%

fork paddle
fork baller
Sponsor
Sponsor
Sponsor
sponsor
Panphobia




PostPosted: Fri Jan 18, 2013 6:26 pm   Post subject: RE:Need help with Brick breaker

search some collision detection tutorials, there are a ton on this site
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: