Ricochet and Turbulence Effect

Non-platform specific questions.

Ricochet and Turbulence Effect

Postby MudRat_02 » Sat Feb 02, 2008 3:28 am

Ok, i have two effects I'm trying to get into two separate sections of a game I'm making (but have been thus far unsuccessful!)

First effect is turbulence. In the game, you're in a fighter cockpit, and you're aim is to bring your crosshair onto a target long enough to lock your missiles on (which is when you pass this level). However, I want the crosshair to randomly move and 'buck' about to simulate the turbulence that your aircraft is experiencing. I have a very VERY primitive version working, where the crosshair randomly and statically flicks about the screen which is useless. What I need is the crosshair to be randomly trying to move in a different direction from the target (and you have to try and counter this independent movement) and accelerating (as opposed to instantly boosting off at a given velocity!). And every random amount of time, slowing and accelerating in a different direction. I want the acceleration and ultimate velocity to increase as well of the frequency of direction change to increase as the game goes on, and thus your level of control decrease. I have a pic below (this is game 2)

And the next game is easier. I just want the target circle to bounce off the edges of screen at a 45 degree trajectory while you try and keep your target on it (game 1)

The crosshairs .etc are only to represent the underlying mechanics of the game, I'll add the eye candy later :D

Thanks in advance for any help!
Attachments
Game.JPG
MudRat_02
 
Posts: 21
Joined: Thu Feb 01, 2007 2:04 am
Score: 0 Give a positive score

Re: Ricochet and Turbulence Effect

Postby zygoth » Sat Feb 02, 2008 11:02 pm

I think this is what you want...

Draw Actor --> Crosshair
if(xvelocity <=3 && xvelocity >= -3)xvelocity = xvelocity + (rand(3) -2);
if(yvelocity <=3 && yvelocity >= -3)yvelocity = yvelocity + (rand(3) -2);
if(xvelocity >=4)xvelocity = xvelocity - 1;
if(xvelocity <=-4)xvelocity = xvelocity + 1;
if(yvelocity >=4)yvelocity = yvelocity - 1;
if(yvelocity <=-4)yvelocity = yvelocity + 1;

This seems a clumsy way of doing it but I think it will work...if you want the values to be controllable replace them with variables and set timers to increase them every so often.
Nova: 100% Vertigo/Mazeman: 100%
Visit my website to download them both! http://www.ketonegames.com
User avatar
zygoth
 
Posts: 140
Joined: Mon Jun 11, 2007 6:37 pm
Score: 5 Give a positive score

Re: Ricochet and Turbulence Effect

Postby MudRat_02 » Sun Feb 03, 2008 1:40 am

I tried your code, but unfortunately It didn't work. Initially the crosshair moves away from the center, but as soon as I press enter (action event to control the crosshair) it all stops, and I have complete control. This is the code i was using before, but all it does is make the crosshair randomly skip about

fourChance = rand(4); //This is used to randomly select what direction to move in (x,y, -x,y, x,-y, -x.-y)

turbulencex = 10 + rand(5);
turbulencey = 10 + rand(5);


i=rand(10);
if (i==0){


if (fourChance == 1)
{

x += rand(turbulencex);
y += rand(turbulencey);

}

else if (fourChance == 2)
{

x -= rand(turbulencex);
y -= rand(turbulencey);

}

else if (fourChance == 3)
{

x -= rand(turbulencex);
y += rand(turbulencey);


}

else if (fourChance == 4)
{

x += rand(turbulencex);
y -= rand(turbulencey);

}

else
{
x = x;
y = y;
}
}
MudRat_02
 
Posts: 21
Joined: Thu Feb 01, 2007 2:04 am
Score: 0 Give a positive score

Re: Ricochet and Turbulence Effect

Postby Bee-Ant » Sun Feb 03, 2008 8:58 am

I wanna help...but...I hate reading a long text...can you explain it shorty? :mrgreen:
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Ricochet and Turbulence Effect

Postby MudRat_02 » Sun Feb 03, 2008 10:24 am

Haha ok, here's it is in short.
I need to make an object onscreen move about randomly away from the center (doesnt matter what direction, just as long as it isnt getting any closer to the middle). It needs to be smooth (to simulate turbulence), and the aim is to try and counter the effects of turbulence to keep the object in the middle of the screen.
MudRat_02
 
Posts: 21
Joined: Thu Feb 01, 2007 2:04 am
Score: 0 Give a positive score

Re: Ricochet and Turbulence Effect

Postby Bee-Ant » Sun Feb 03, 2008 10:29 am

Very very simple...
make an actor called "center" parented with view actor...place it in the center position.
center>DrawActor>ScriptEditor>
Code: Select all
VisibilityState("Event Actor", DONT_DRAW_ONLY);

MovingObject>DrawActor>ScriptEditor
Code: Select all
if(x<center.x)
{
    xvelocity+=1;
}
if(x>center.x)
{
    xvelocity-=1;
}
if(y<center.y)
{
    yvelocity+=1;
}
if(y>center.y)
{
    yvelocity-=1;
}
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Ricochet and Turbulence Effect

Postby Bee-Ant » Sun Feb 03, 2008 10:30 am

Still confused???
I'll make the demo...
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Ricochet and Turbulence Effect

Postby MudRat_02 » Sun Feb 03, 2008 1:53 pm

Very nice! Only problem here is that you press enter to start the game (and thus control the crosshair). Before I press enter, the crosshair is indeed moving in a nice smooth action, but as soon as I hit enter I once again have complete control of the crosshair. Any idea how to remedy this?
MudRat_02
 
Posts: 21
Joined: Thu Feb 01, 2007 2:04 am
Score: 0 Give a positive score

Re: Ricochet and Turbulence Effect

Postby Bee-Ant » Sun Feb 03, 2008 1:57 pm

Actor1->KeyDown->Enter->ScriptEditor
Code: Select all
start=1;

Actor1->DrawActor->ScriptEditor
Code: Select all
if(start==1)
{
    if(x<center.x)
    {
        xvelocity+=1;
    }
    if(x>center.x)
    {
        xvelocity-=1;
    }
    if(y<center.y)
    {
        yvelocity+=1;
    }
    if(y>center.y)
    {
        yvelocity-=1;
    }
}
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Ricochet and Turbulence Effect

Postby MudRat_02 » Sun Feb 03, 2008 2:09 pm

I tried that, same result except the crosshair doesnt move at all before I hit enter now :S
MudRat_02
 
Posts: 21
Joined: Thu Feb 01, 2007 2:04 am
Score: 0 Give a positive score

Re: Ricochet and Turbulence Effect

Postby Bee-Ant » Sun Feb 03, 2008 2:16 pm

That code works perfectly in my comp...it's weird
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Ricochet and Turbulence Effect

Postby MudRat_02 » Sun Feb 03, 2008 2:17 pm

must be something to do with the variable. Start is just a standard user-created variable right? I'm also controlling the crosshair by mouse, does that make a difference?
MudRat_02
 
Posts: 21
Joined: Thu Feb 01, 2007 2:04 am
Score: 0 Give a positive score

Re: Ricochet and Turbulence Effect

Postby Bee-Ant » Sun Feb 03, 2008 2:33 pm

That's the problem...before you control it with mouse, put
Code: Select all
if(start==1)
{
    //mouse control
}
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Ricochet and Turbulence Effect

Postby MudRat_02 » Sun Feb 03, 2008 2:38 pm

Sry im confused - // is for notation, and apart from that its the same :S. Am i supposed to put that somewhere else?
MudRat_02
 
Posts: 21
Joined: Thu Feb 01, 2007 2:04 am
Score: 0 Give a positive score

Re: Ricochet and Turbulence Effect

Postby Bee-Ant » Mon Feb 04, 2008 7:58 am

Oh...uh...ah...
How hard it's gonna be...
OK...I'll make a demo
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Next

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron