Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //From my Amnesia Rebirth Tutorial Series
- //Episode 38 Randomness Pt.1!
- //https://www.youtube.com/playlist?list=PL4KkjlmOwLwwMVqedCNpi6caUxhgyf8Qr
- //-----------------------------------------------------------
- ///////////////////////////////////////////////////
- // Functions used in today's episode
- //////////////////////////////////////////////////
- //Set a seed where random values will originate from
- cMath_Randomize(1234);
- //seed (int)- the seed that should be used to generate all randomness.
- //Generate random float between 2 numbers (including the 2 numbers)
- cMath_RandRectf(0.0, 10.0);
- //minValue (float)- bottom value that the random number will start being randomized.
- //maxValue (float)- top value that the random number will end being randomized.
- //Generate random int between 2 numbers (including the 2 numbers)
- cMath_RandRectl(0, 10);
- //minValue (int)- bottom value that the random number will start being randomized.
- //maxValue (int)- top value that the random number will end being randomized.
- //Generate random color between 2 color values
- cMath_RandRectColor(cColor(0.0, 0.0, 0.0), cColor(1.0, 1.0, 1.0));
- //minColorValue (cColor)- bottom color values that the random number will start being randomized.
- //maxColorValue (cColor)- top color values that the random number will end being randomized.
- //Generate random X Y vector between 2 2D vector values
- cMath_RandRectVector2f(cVector2f(0.0, 0.0), cVector2f(10.0, 10.0))
- //minVectorValue (cVector2f)- bottom vector values that the random number will start being randomized.
- //maxVectorValue (cVector2f)- top vector values that the random number will end being randomized.
- //Generate random X Y Z vector between 2 3D vector values
- cMath_RandRectVector3f(cVector3f(0.0, 0.0, 0.0), cVector3f(10.0, 10.0, 10.0));
- //minVectorValue (cVector3f)- bottom vector values that the random number will start being randomized.
- //maxVectorValue (cVector3f)- top vector values that the random number will end being randomized.
- //Get a random point on the edge of a 2D circle of a specified radius (cVector2f)
- cMath_RandomCircleEdgePoint(2.0f);
- //radius (float)- the radius of the circle.
- //Get a random point on the surface of a sphere with the specified radius (cVector3f)
- cMath_RandomSphereSurfacePoint(2.0f);
- //radius (float)- the radius of the sphere.
- ///////////////////////////////////////////////////
- // All code written
- //////////////////////////////////////////////////
- bool OnCollide_Player_Trigger_1(const tString &in asParent, const tString &in asChild, int alState)
- {
- //asParent is the name of the object that has the callback
- //asChild is the name of the object that collided with the parent
- if(alState == 1){
- //This stuff will happen when the player enters the trigger area
- cLux_AddDebugMessage("Enabling players running");
- Player_SetCanRun(true);
- cMath_Randomize(1234);
- int randInt = cMath_RandRectl(1, 10);
- cLux_AddDebugMessage("Random int is: " + cString_ToString(randInt));
- float randFloat = cMath_RandRectf(1.0, 10.0);
- cLux_AddDebugMessage("Random float is: " + cString_ToString(randFloat));
- cColor randColor = cMath_RandRectColor(cColor(0.0, 0.0, 0.0), cColor(1.0, 1.0, 1.0));
- cLux_AddDebugMessage("Random colors are: " + cString_ToString(randColor.r) + " " + cString_ToString(randColor.g) + " " + cString_ToString(randColor.b));
- cVector2f randVec2 = cMath_RandRectVector2f(cVector2f(0.0, 0.0), cVector2f(10.0, 10.0));
- cLux_AddDebugMessage("Random vector2f is: " + cString_ToString(randVec2.x) + " " + cString_ToString(randVec2.y));
- cVector3f randVec3 = cMath_RandRectVector3f(cVector3f(0.0, 0.0, 0.0), cVector3f(10.0, 10.0, 10.0));
- cLux_AddDebugMessage("Random vector3f is: " + cString_ToString(randVec3.x) + " " + cString_ToString(randVec3.y) + " " + cString_ToString(randVec3.z));
- //cVector2f randCircleEdge = cMath_RandomCircleEdgePoint(5.0f);
- //cVector3f randSpherePoint = cMath_RandomSphereSurfacePoint(5.0f);
- //Seq_Test("");
- return false;
- }else{
- //This stuff will happen when the player leaves trigger area
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment