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

Username:   Password: 
 RegisterRegister   
 randomly moving
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
beedub




PostPosted: Sun Jun 15, 2003 10:41 pm   Post subject: randomly moving

i need something to randomly move across the screen 10 times in any direction. So in this case lets make it a circle..
Sponsor
Sponsor
Sponsor
sponsor
Andy




PostPosted: Mon Jun 16, 2003 9:28 am   Post subject: (No subject)

use xchange and ychange
krishon




PostPosted: Mon Jun 16, 2003 9:48 am   Post subject: (No subject)

do u mean like it goes to a random location 10 times?
Andy




PostPosted: Mon Jun 16, 2003 10:02 am   Post subject: (No subject)

ya if u want it to show randomly just do this
code:

for i:1..10
cls
drawfilloval(Rand.Int(0,maxx),Rand.Int(0,maxy),10,10,i)
delay(100)
end for
Tony




PostPosted: Mon Jun 16, 2003 10:41 am   Post subject: (No subject)

i think he ment randomly move, not appear...

say princial appliest though. Randomly generate a number from 1 to 4, that would determine in which direction piece would move.

if move=1 then
%move north
...
etc
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Homer_simpson




PostPosted: Mon Jun 16, 2003 11:01 am   Post subject: (No subject)

code:
View.Set("offscreenonly")
const xspeed := 1
const yspeed := 1
var y, x := 100
loop
    x += Rand.Int (-xspeed, xspeed)
    y += Rand.Int (-yspeed, yspeed)
    drawfilloval (x, y, 10, 10, 12)
    View.Update
    delay(5)
    drawfilloval (x, y, 10, 10, white)
end loop
krishon




PostPosted: Mon Jun 16, 2003 11:02 am   Post subject: (No subject)

ye, that works, lol
JayLo




PostPosted: Mon Jun 16, 2003 12:17 pm   Post subject: (No subject)

looks freaky though. I think he meant like bouncing? iunno. he isn't making it clear.
Andy




PostPosted: Mon Jun 16, 2003 2:38 pm   Post subject: (No subject)

i dun think so, i think he's trying to make a space shooter or something
Homer_simpson




PostPosted: Mon Jun 16, 2003 3:06 pm   Post subject: (No subject)

ic... ok i'll try to make a smooth moving one...
Homer_simpson




PostPosted: Mon Jun 16, 2003 4:23 pm   Post subject: (No subject)

how bout this one?!
code:
proc rotate (OriginX, OriginY : real, var secondpartX, secondpartY : real, Rotaion : real)
    var tempx := (((OriginX - secondpartX) * cosd (Rotaion)) + ((OriginY - secondpartY) * sind (Rotaion)))
    var tempy := (((OriginY - secondpartY) * cosd (Rotaion)) - ((OriginX - secondpartX) * sind (Rotaion)))
    secondpartY := OriginY - tempy
    secondpartX := OriginX - tempx
end rotate
View.Set ("offscreenonly")
const factor := 200
const speed := 1
var xx, yy : real := 200
var xr, yr := 100
var slope := 0.0
var i : int
loop
    i := 1
    xr := Rand.Int (-factor, factor)
    yr := Rand.Int (-factor, factor)
    xr += round (xx)
    yr += round (yy)
    loop
        i += 1
        rotate (xr, yr, xx, yy, speed)
        drawfilloval (round (xx), round (yy), 5, 5, 9)
        View.Update
        delay (5)
        exit when i = 10
    end loop
end loop
Andy




PostPosted: Mon Jun 16, 2003 4:39 pm   Post subject: (No subject)

man homer, u have too much free time, anyways if they're looking for mods, you should be their first pick and catalyst of course
Homer_simpson




PostPosted: Mon Jun 16, 2003 6:51 pm   Post subject: (No subject)

the code above took me less than 10 mins =)
Andy




PostPosted: Mon Jun 16, 2003 7:27 pm   Post subject: (No subject)

ya but ten minutes can get u 5 marks on an exam if u use it to study
PaddyLong




PostPosted: Mon Jun 16, 2003 10:38 pm   Post subject: (No subject)

study?? pffft the only studying you need to do is a once over of your notes Surprised people worry way too much about the numbers they get in school
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 2  [ 26 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: