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

Username:   Password: 
 RegisterRegister   
 Rand Ball proggy help plz
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Lazarus




PostPosted: Tue Apr 19, 2005 11:57 am   Post subject: Rand Ball proggy help plz

k, I'm sure anyone of you could get this done in a few seconds, but I have a brain cramp, so no matter what I do it's not working properly, I know I have to get it to choose weither it will be positive or negative a rand. But I'm confuzzled, here's what I got:

code:
cls

var x : int := 600
var y : int := 100

loop
    x := x + -1 
    y := y + 1
    Draw.FillOval (x , y , 10, 10, red)
    delay (100)
    Draw.FillOval (x , y , 10, 10, white)
end loop
Sponsor
Sponsor
Sponsor
sponsor
Martin




PostPosted: Tue Apr 19, 2005 12:15 pm   Post subject: (No subject)

I'm not entirely sure what you're trying to do. Do you mean that you want it to start moving in a random direction from a random point on the screen?
Lazarus




PostPosted: Tue Apr 19, 2005 12:20 pm   Post subject: (No subject)

Completely Random, Start at a Random point, move to a random location, then move from that location to an other Random location. All I need to do is find out how to make it decide weither or not it to be positive or negative, and it cannot go off the screen.
Martin




PostPosted: Tue Apr 19, 2005 12:27 pm   Post subject: (No subject)

Type Rand.Int and press F10.

You'll want to generate 4 numbers: the start x and y location, and the end x and y location. Then figure out the slope of the line connecting the two points (remember grade 9?) and you're set.
Lazarus




PostPosted: Tue Apr 19, 2005 12:29 pm   Post subject: (No subject)

This does not help, because it will not be completely Random.
Martin




PostPosted: Tue Apr 19, 2005 12:39 pm   Post subject: (No subject)

I don't understand what you mean by completely random. Like, you want it to just shake around on the screen?
Lazarus




PostPosted: Tue Apr 19, 2005 12:41 pm   Post subject: (No subject)

Yep yep, but I got it, my brain cramp left me lol

code:
setscreen ("nooffscreenonly")
cls
var x : int := Rand.Int (100,600)
var y : int := Rand.Int (100,400)
loop
    x := x + (Rand.Int (-10,10))
    y := y + (Rand.Int (-10,10))
    Draw.FillOval (x, y, 10, 10, red)
    delay (100)
    Draw.FillOval (x, y, 10, 10, white)
end loop


now all I have to do is make a boundry so it doesn't go off the screen, how would I?
Martin




PostPosted: Tue Apr 19, 2005 12:53 pm   Post subject: (No subject)

code:
setscreen ("nooffscreenonly")
cls
var x : int := Rand.Int (100,600)
var y : int := Rand.Int (100,400)
var xchange, ychange : int
loop
    xchange := Rand.Int (-10, 10)
    ychange := Rand.Int (-10, 10)
    if (x + xchange) > 0 and (x + xchange) < maxx then
        x := x + xchange
    end if
    if (y + ychange) > 0 and (y + ychange) < maxy then
        y := y + ychange
    end if
    Draw.FillOval (x, y, 10, 10, red)
    delay (100)
    Draw.FillOval (x, y, 10, 10, white)
end loop
Sponsor
Sponsor
Sponsor
sponsor
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  [ 8 Posts ]
Jump to:   


Style:  
Search: