
-----------------------------------
Skizzarz
Tue Jan 20, 2004 7:32 pm

getting an object to go toward center of window
-----------------------------------
How would i go about making an object (a cirlce for example) go toward the center of the screen but with some 'randmality', kind of like a brownian program but going to the center instead of totally random directions, thx allot

-----------------------------------
shorthair
Tue Jan 20, 2004 7:40 pm


-----------------------------------
You can make the randint have maxx and min values , just make it randomize on a certain area , the randomize is defined by the user

-----------------------------------
Skizzarz
Tue Jan 20, 2004 7:54 pm


-----------------------------------
but how would make it randomized like using "proc" or whatever

-----------------------------------
AsianSensation
Tue Jan 20, 2004 8:37 pm


-----------------------------------

-------------------------------------
|                                            |
|                                            |
|                                            |
|                                            |
|                     *                     |
|                                            |
|         O                                 |
|                                            |
|                                            |
-------------------------------------


calculate the difference in y position, and the difference in x position. Then use Rand.Int or something, and randomly choose to go up one or right one (in the example above)

if you want it to look very very random, then every five loop or so, randomly move to any direction.

-----------------------------------
Skizzarz
Tue Jan 20, 2004 8:48 pm


-----------------------------------
where can i find a brownian like program in turing (with source code), cuz my ball wont go towards the center:

setscreen ("nocursor")
var x : int := 1
var y : int := 1
var newx : int
loop
x := x + 3
y := y + 3
randint ( x, 0, 5)
randint ( y, 0, 5)
drawfilloval (x, y, 10, 10, 5)
cls
end loop

if i could get a look at some brownian source then i could fix it

-----------------------------------
Andy
Tue Jan 20, 2004 8:53 pm


-----------------------------------
just increase ur x and y in ratios of xdis/ydis of u and the center

-----------------------------------
Skizzarz
Tue Jan 20, 2004 8:55 pm


-----------------------------------
im not tryin to be a code whore but could u gimme a little example plz?

-----------------------------------
AsianSensation
Tue Jan 20, 2004 8:57 pm


-----------------------------------
var posx, posy, dx, dy, randnum : int := 0
posx := Rand.Int (0, maxx)
posy := Rand.Int (0, maxy)
loop
    dx := maxx div 2 - posx
    dy := maxy div 2 - posy

    randint (randnum, -1, 1)

    if randnum = -1 then
        posx += Rand.Int (-1, 1)
        posy += Rand.Int (-1, 1)
    elsif randnum = 0 then
        posx += 1 * sign (dx)
    elsif randnum = 1 then
        posy += 1 * sign (dy)
    end if

    drawfilloval (posx, posy, 10, 10, 5)
    delay (10)
    cls
end loop

did you even try at all? I am seriously wondering....

-----------------------------------
Skizzarz
Tue Jan 20, 2004 9:18 pm


-----------------------------------
i really did try, sorry but im kind of stupid, well ive been takeing turing since the start of the schoool year and i havnt really progressed allot. i have a really important question, how would u get that to run while other things are happening, because its a loop, just like a crosshair over a mouse, its a loop , so how would i get other things to happen while its looping?

-----------------------------------
the_short1
Tue Jan 20, 2004 9:57 pm


-----------------------------------
fork a proceedure... then it will do it at same time as loop.. if you want it to do it again and again... make a loop inside of process... see example:

process musik
    loop
if mus := "yes"
        Music.PlayFile ("wav/backroundbeat.mp3")
end if
    end loop
end musik
fork musik (once not in your loop)
then it will keep repeating my backround msuik... hope that helps...
i use Music.PlayFileStop and then i make mus := no to end my musik...
this can be used for counters on games for time and such....kinda slows down with movement of arrow keys tho....
make a pixel brownian program and randomize the x and the y value to either do nothing or plus 1 to center... i think that might work,,, or try previous post's example..AsianSensation