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

Username:   Password: 
 RegisterRegister   
 brick program help??
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
shoobyman




PostPosted: Thu Jan 12, 2006 9:32 am   Post subject: brick program help??

please help me with my brick program, i need to make the blocks at the top of the game and make the ball hit it and then the block disaapers and wen the ball hits the bottom, it seys the number of lives and once the number of lives r dun make it sey game over :
PLEASE I DUNT KNOW HOW TO DO IT AT ALL

var x, y, button : int
var paddleHEIGHT: int:=5
var objectVX, objectVY, x2, y2 : int
objectVY := 10
objectVX := 10
x2 := maxx div 2
y2 := maxy div 2
const ballRad : int := 5
setscreen ("offscreenonly")
loop
delay (30)
cls
mousewhere (x, y, button)

drawfillbox (x,13,x+60,paddleHEIGHT,black)

drawfilloval (x2, y2, ballRad, ballRad, black)
x2 += objectVX
y2 += objectVY
if x2 > maxx - 5 then
objectVX := -objectVX
elsif x2 < 5 then
objectVX := -objectVX
elsif y2 > maxy - 5 then
objectVY := -objectVY
elsif y2 < 5 then
objectVY := -objectVY
end if
if x2 > x and x2 < x + 60 and y2 < 13 then
y2 := -y2
end if
View.Update
end loop
Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Thu Jan 12, 2006 10:01 am   Post subject: (No subject)

You're off to a good start. First off though, please use either [code] or [syntax] tags when posting code.

You have the basics of the ball movement down. You have your x- and y- velocities, as well as your x- and y- coords. Now, you simply need to use some if conditions to determine when the ball has touched the lower bounds of the screen (when x=0). At this point, the player's lives would go down.
You'll also want to make sure that this condition makes sure that the ball has indeed touched the bottom screen and not just the paddle. When it touches the paddle, it can simply bounce as it's doing right now.
When all lives have been used up, exit your main loop and display the closing message.

In other words you do know what you're doing. Just apply your thoughts into the code. Post up when you're done so we can look over the final product.
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: