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

Username:   Password: 
 RegisterRegister   
 Problem.....for Drop the ball.
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
spen




PostPosted: 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. Exclamation 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....

Exclamation 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

Download
 Filename:  astronaut.zip
 Filesize:  270.99 KB
 Downloaded:  94 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: 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 Confused
spen




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

Thank u so much~ Very Happy

It's cool~
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  [ 3 Posts ]
Jump to:   


Style:  
Search: