Page 1 of 1

independent movement

PostPosted: Mon Aug 13, 2007 1:12 pm
by MudRat_02
Ok, i've got a problem here and no (effective) way to solve it. In my game, i control a crosshair with the mouse (the crosshair actually indicates your aircraft's attitude) whereas in the middle of the screen is the objective. However, as the level progresses you encounter more and more turbulence that effectively makes it harder to keep your targeting crosshair in the target area that you shoot at the end of hte level (if you performed well enough).

So heres the problem with that scenario, i dont know how to make the crosshair slowly start to move around independently and randomly (to simulate random turbulence). All my attempts have ended up too static. Anyone have any ideas?

PostPosted: Mon Aug 13, 2007 5:56 pm
by pixelpoop
could you give your crosshairs some directional veloctiy and an angle then change them randomly?

create integer variable "i" then put this in the draw script.

i=rand(5);
if (i==0){angle=rand(360); directional_velocity=rand(3);}

or just jump around with x, y.

i=rand(5);
if (i==0){x+=rand(5)-2; y+=rand(5)-2;}

PostPosted: Tue Aug 14, 2007 6:58 am
by MudRat_02
ok that first option was quite good, but theres only one problem-
At the start of the game it says hit return to begin (which starts the timer and is also a keydown event to control the crosshair with the mouse). Your script worked great, but as soon as i hit enter to begin the game, i have complete control of the crosshair :? Any way i can fix that?

PostPosted: Tue Aug 14, 2007 4:26 pm
by Sgt. Sparky
MudRat_02 wrote:ok that first option was quite good, but theres only one problem-
At the start of the game it says hit return to begin (which starts the timer and is also a keydown event to control the crosshair with the mouse). Your script worked great, but as soon as i hit enter to begin the game, i have complete control of the crosshair :? Any way i can fix that?

just make a variable called turbulence(a global integer.)
and when the crosshair encounters turbulence:
Code: Select all
turbulence = 10 + rand(5);
x -= rand(turbulence);
x += rand(turbulence * 2;
y -= rand(turbulence);
y += rand(turbulence * 2);

and make that a code on a draw actor event. :D

PostPosted: Wed Aug 15, 2007 6:08 am
by MudRat_02
thanx man that worked great :D
The crosshair is moving very static and very quick though, i've been trying some stuff to see what I can do about that. The main problem at the moment is that the crosshair moves random so quick, and so random (lol) that i can just move the crosshair to the approximate target zone, the the crosshair will average in that area, winning the game for me :shock:

Heres what i think may remedy the problem
- Acceleration (to give the user some warning so they can counter the turbulence)
- Some sort of event (timer or something) that dictates how often the turbulence is randomly changed
- Basically, although the turbulence is random, I need to really have the crosshair randomly try and escape away from the target zone

If anyone has some ideas to how this could go down (the acceleration and the crosshair trying to get away from the center of the screen part mainly), dont hold back :D Thanx again for the help so far

PostPosted: Wed Aug 15, 2007 7:14 am
by pixelpoop
use part of the code I gave above to randomly change when the random happens:
i=rand(5);
if (i==0){//turbulence coding
}

Also maybe you could turn off and on the control of the crosshairs during turbulence.

PostPosted: Wed Aug 15, 2007 8:09 am
by MudRat_02
cool, that helped slow it down. I've noticed that before i hit enter (to assume control of the crosshair) it goes randomly about teh screen, but after i hit enter it randomly flicks somewhere else before returning to the mouse location :? I'll need to add both acceleration (so its not so static) and i think that may solve the mouse override problem.

Maybe im going about this the wrong way. Obviously the mouse location is a big hurdle, because the crosshair can move, but the mouse cursor (as far as i know) cant be moved by this random thing really...or can it?

I've attached my project so far, if someone wants to have a crack at it (plz do! This is driving me up the wall :wink: )

(Btw, in case anyone is wondering lol, I know this is a strange game. Well, for starters its not really a 'game', rather, i'm simulating a set of airforce fighter pilot tests, and this basic scenario is the basis for a dozen or so similar ones. As it is, this doesnt come close to simulating the test, but it will eventually)