Camerascreen & -movement
#4

Quote:
Originally Posted by GiS
Посмотреть сообщение
pawn Код:
SetCameraPos(playerid, X + (floatcos(A, degrees) * R), Y + (floatsin(A, degrees) * R), Z + 10);
// Shouldn't that be SetPlayerCameraPos and what actually happens here?
Yeah it should be SetPlayerCameraPos

X, Y and Z are the coordinates of the center (the 0 in the image) in your example it is the building



The code repeats itself till the state of the player isnt PLAYER_STATE_WASTED
And with each tick it increase the angle by one

pawn Код:
SetTimerEx("TRotate", 100, false, "ifffff", playerid, X, Y, Z, R, A + 1.0);
We know that cos(Angle) gets the x offset and sin(Angle) the y offset for the circle

And we know that cos and sin get always a value between [-1;1] (cosІ + sinІ = 1 [pythagorean])

To get our circle with the correct radius we just multiply the cos / sin with our wanted amplitude

=> X = CENTER_X + cos(Angle) * Radius; Y = CENTER_Y + sin(Angle) * radius;

And Z = CENTER_Z + 10 for a nice camera position

Quote:
Originally Posted by GiS
Посмотреть сообщение
pawn Код:
if(down) { // What do you mean with 'down'? What do you ask here for?
        if(--opacity <= 0) { // Where did you define --opacity and what is it?
            TextDrawDestroy(tText);
            return ;
        }
    } else {
        if(++opacity >= 255) { // Where did you define ++opacity and what is it?
            SetTimerEx("cbOpacity", 100, false, "iiib", playerid, _:tText, opacity, true);
            SetPlayerCameraPos(playerid, cX, cY, cZ);
            SetPlayerCameraLookAt(playerid, X, Y, Z);
            return;
        }
    }
++variable / variable++ are in pawn the same like --variable / variable--
variable ++ = variable + 1, variable -- = variable - 1
(the operator can be found in float.inc)

Thats the main function where we create our temporary textdraw
pawn Код:
stock StartChange(playerid, Float: X, Float: Y, Float: Z, Float: cX, Float: cY, Float: cZ) {
    new Text:gText = TextDrawCreate(0.0, 0.0, "_");
    TextDrawUseBox(gText, true);
    cbOpacity(playerid, gText, 0, false, X, Y, Z, cX, cY, cZ);
}
Here you can see that the parameter down is set on false (down is only a flag, you could it call how you want)

First is that part executed till it reach 255 (0xFF) the full opacity

pawn Код:
//
        if(++opacity >= 255) { // Where did you define ++opacity and what is it?
            SetTimerEx("cbOpacity", 100, false, "iiib", playerid, _:tText, opacity, true);
            SetPlayerCameraPos(playerid, cX, cY, cZ);
            SetPlayerCameraLookAt(playerid, X, Y, Z);
            return;
        }
Than if its fully dark we change the camera position
And we call now our other code, so it vanish again
pawn Код:
"iiib", playerid, _:tText, opacity, true)
down is now set to true and this code is executed
pawn Код:
//
        if(--opacity <= 0) { // Where did you define --opacity and what is it?
            TextDrawDestroy(tText);
            return ;
        }
with that the code will stop repeating itself
at least we destroy our temporary textdraw => end

Good luck
Reply


Messages In This Thread
Camerascreen & -movement - by GiS - 22.05.2011, 15:38
AW: Camerascreen & -movement - by Nero_3D - 22.05.2011, 16:37
Re: Camerascreen & -movement - by GiS - 22.05.2011, 17:07
AW: Re: Camerascreen & -movement - by Nero_3D - 22.05.2011, 21:52

Forum Jump:


Users browsing this thread: 2 Guest(s)