Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
brick program help??
Author Message
shoobyman

Posted: 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 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)

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

Delos

Posted: 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: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 2 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: