Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Problem.....for Drop the ball.
Author Message
spen

Posted: Sun Jun 13, 2004 2:36 am   Post subject: Problem.....for Drop the ball.

I am making game I got some problem that Drop the ball.

the player should avoid ball when the ball hit the ground.

1. So how can I drop the ball per seconds??

( The numbers of balls will be increased by time going)
1 sec = 1ball
2 sec =2 2 ball
3sec= 3 ball.......

The position of ball is from y= maxy, x = random

2. I asked this question before..but..I coludn't find the way....

How can I make movement smoothly for my character??
(same way as below program, Draw. command)

I hope u guys answer thank you~~

* the ball is an image file (bmp)
* When I use Delay command, the game is jammmed..too slow
* The character is made by Draw. Command

astronaut.zip
Description:
 This is not my program

Filename:  astronaut.zip
Filesize:  270.99 KB

Cervantes

Posted: Sun Jun 13, 2004 7:24 am   Post subject: (No subject)

here's how I would do it.
 code: setscreen ("offscreenonly") var ball_time := 0 var counter := 1 var x, y, vy : array 1 .. 15 of real var draw : array 1 .. 15 of boolean for i : 1 .. 15     x (i) := Rand.Int (0, maxx)     y (i) := maxy     vy (i) := 0     draw (i) := false end for const gravity := 0.015 loop     cls     if Time.Elapsed - ball_time >= 1000 then         ball_time := Time.Elapsed         if counter >= 15 then             counter := 1         else             counter += 1         end if         draw (counter) := true     end if     for b : 1 .. 15         if draw (b) then             vy (b) -= gravity             y (b) += vy (b)             drawfilloval (round (x (b)), round (y (b)), 10, 10, black)             if y (b) < 0 then                 y (b) := maxy                 vy (b) := 0                 draw (b) := false             end if         end if     end for     View.Update     delay (10) end loop

note that it would look a bit better if you were to make the balls spawn just a little above maxy, so that the user can't actually see them materialize like they do
spen

Posted: Sun Jun 13, 2004 11:32 am   Post subject: Thank u~!!

Thank u so much~

It's cool~
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 3 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: