Computer Science Canada getting an object to go toward center of window |
Author: | Skizzarz [ Tue Jan 20, 2004 7:32 pm ] |
Post subject: | 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 |
Author: | shorthair [ Tue Jan 20, 2004 7:40 pm ] |
Post subject: | |
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 |
Author: | Skizzarz [ Tue Jan 20, 2004 7:54 pm ] |
Post subject: | |
but how would make it randomized like using "proc" or whatever |
Author: | AsianSensation [ Tue Jan 20, 2004 8:37 pm ] | ||
Post subject: | |||
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. |
Author: | Skizzarz [ Tue Jan 20, 2004 8:48 pm ] | ||
Post subject: | |||
where can i find a brownian like program in turing (with source code), cuz my ball wont go towards the center:
if i could get a look at some brownian source then i could fix it |
Author: | Andy [ Tue Jan 20, 2004 8:53 pm ] |
Post subject: | |
just increase ur x and y in ratios of xdis/ydis of u and the center |
Author: | Skizzarz [ Tue Jan 20, 2004 8:55 pm ] |
Post subject: | |
im not tryin to be a code whore but could u gimme a little example plz? |
Author: | AsianSensation [ Tue Jan 20, 2004 8:57 pm ] | ||
Post subject: | |||
did you even try at all? I am seriously wondering.... |
Author: | Skizzarz [ Tue Jan 20, 2004 9:18 pm ] |
Post subject: | |
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? |
Author: | the_short1 [ Tue Jan 20, 2004 9:57 pm ] |
Post subject: | |
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<<<he pro>> |
Author: | AsianSensation [ Tue Jan 20, 2004 10:34 pm ] |
Post subject: | |
the_short1 wrote: 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...
arg, arg, arg. Don't use turing's process unless you really really really have to. It's way to inaccurate and out of sync with the rest of your program. Instead, just do everything in the loop. I only did calculations in there, the only part that really affects the output is the drawoval part. So basicly, I would suggest this, do all your calculation somewhere in the loop, and near the end of the loop, output everything to screen. That should let you have multiple things going on without process. |
Author: | Skizzarz [ Wed Jan 21, 2004 8:06 pm ] |
Post subject: | |
um asian, i totally dont get wut u mean, but i kind of understand the 'fork' thing, is there a tutorial i could find on 'forking'? thanks |
Author: | scryed [ Wed Jan 21, 2004 8:44 pm ] |
Post subject: | |
Ahhh...parents were a little too shy to explain the ins and outs of 'forking' eh? Seriously listen to AS, you only NEED to fork when you want to play beautiful music (for the most part) |
Author: | Skizzarz [ Wed Jan 21, 2004 9:30 pm ] |
Post subject: | |
but if u have a loop within a loop then it will never get out of the loop inside, because its endless, so forking makes sense to me... |
Author: | AsianSensation [ Wed Jan 21, 2004 10:40 pm ] | ||
Post subject: | |||
Skizzarz wrote: but if u have a loop within a loop then it will never get out of the loop inside, because its endless, so forking makes sense to me...
I never said loop within a loop, I meant something like this:
so you are constantly changing the position of self and enemy, and then you draw them, so it seem like both of them are moving. No forking needed. btw, if you have a loop in a loop, you can either use return to instantly terminates the program, or set flags of boolean value, and exit the loop when the flag is true. |