TechOFreak

Episode 38 Functions

Apr 13th, 2021
1,175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.40 KB | None | 0 0
  1. //From my Amnesia Rebirth Tutorial Series
  2. //Episode 38 Randomness Pt.1!
  3. //https://www.youtube.com/playlist?list=PL4KkjlmOwLwwMVqedCNpi6caUxhgyf8Qr
  4. //-----------------------------------------------------------
  5.  
  6. ///////////////////////////////////////////////////
  7. // Functions used in today's episode
  8. //////////////////////////////////////////////////
  9.  
  10. //Set a seed where random values will originate from
  11. cMath_Randomize(1234);
  12. //seed (int)- the seed that should be used to generate all randomness.
  13.  
  14. //Generate random float between 2 numbers (including the 2 numbers)
  15. cMath_RandRectf(0.0, 10.0);
  16. //minValue (float)- bottom value that the random number will start being randomized.
  17. //maxValue (float)- top value that the random number will end being randomized.
  18.  
  19. //Generate random int between 2 numbers (including the 2 numbers)
  20. cMath_RandRectl(0, 10);
  21. //minValue (int)- bottom value that the random number will start being randomized.
  22. //maxValue (int)- top value that the random number will end being randomized.
  23.  
  24. //Generate random color between 2 color values
  25. cMath_RandRectColor(cColor(0.0, 0.0, 0.0), cColor(1.0, 1.0, 1.0));
  26. //minColorValue (cColor)- bottom color values that the random number will start being randomized.
  27. //maxColorValue (cColor)- top color values that the random number will end being randomized.
  28.  
  29. //Generate random X Y vector between 2 2D vector values
  30. cMath_RandRectVector2f(cVector2f(0.0, 0.0), cVector2f(10.0, 10.0))
  31. //minVectorValue (cVector2f)- bottom vector values that the random number will start being randomized.
  32. //maxVectorValue (cVector2f)- top vector values that the random number will end being randomized.
  33.  
  34. //Generate random X Y Z vector between 2 3D vector values
  35. cMath_RandRectVector3f(cVector3f(0.0, 0.0, 0.0), cVector3f(10.0, 10.0, 10.0));
  36. //minVectorValue (cVector3f)- bottom vector values that the random number will start being randomized.
  37. //maxVectorValue (cVector3f)- top vector values that the random number will end being randomized.
  38.  
  39. //Get a random point on the edge of a 2D circle of a specified radius (cVector2f)
  40. cMath_RandomCircleEdgePoint(2.0f);
  41. //radius (float)- the radius of the circle.
  42.  
  43.  
  44. //Get a random point on the surface of a sphere with the specified radius (cVector3f)
  45. cMath_RandomSphereSurfacePoint(2.0f);
  46. //radius (float)- the radius of the sphere.
  47.  
  48. ///////////////////////////////////////////////////
  49. // All code written
  50. //////////////////////////////////////////////////
  51.  
  52. bool OnCollide_Player_Trigger_1(const tString &in asParent, const tString &in asChild, int alState)
  53.     {
  54.         //asParent is the name of the object that has the callback
  55.         //asChild is the name of the object that collided with the parent
  56.         if(alState == 1){
  57.             //This stuff will happen when the player enters the trigger area
  58.             cLux_AddDebugMessage("Enabling players running");
  59.             Player_SetCanRun(true);
  60.            
  61.             cMath_Randomize(1234);
  62.            
  63.             int randInt = cMath_RandRectl(1, 10);
  64.             cLux_AddDebugMessage("Random int is: " + cString_ToString(randInt));
  65.            
  66.             float randFloat = cMath_RandRectf(1.0, 10.0);
  67.             cLux_AddDebugMessage("Random float is: " + cString_ToString(randFloat));
  68.            
  69.             cColor randColor = cMath_RandRectColor(cColor(0.0, 0.0, 0.0), cColor(1.0, 1.0, 1.0));
  70.             cLux_AddDebugMessage("Random colors are: " + cString_ToString(randColor.r) + " " + cString_ToString(randColor.g) + " " + cString_ToString(randColor.b));
  71.            
  72.             cVector2f randVec2 = cMath_RandRectVector2f(cVector2f(0.0, 0.0), cVector2f(10.0, 10.0));
  73.             cLux_AddDebugMessage("Random vector2f is: " + cString_ToString(randVec2.x) + " " + cString_ToString(randVec2.y));
  74.            
  75.             cVector3f randVec3 = cMath_RandRectVector3f(cVector3f(0.0, 0.0, 0.0), cVector3f(10.0, 10.0, 10.0));
  76.             cLux_AddDebugMessage("Random vector3f is: " + cString_ToString(randVec3.x) + " " + cString_ToString(randVec3.y) + " " + cString_ToString(randVec3.z));
  77.            
  78.             //cVector2f randCircleEdge = cMath_RandomCircleEdgePoint(5.0f);
  79.            
  80.             //cVector3f randSpherePoint = cMath_RandomSphereSurfacePoint(5.0f);
  81.            
  82.             //Seq_Test("");
  83.             return false;
  84.         }else{
  85.             //This stuff will happen when the player leaves trigger area
  86.             return false;
  87.         }
  88.     }
Advertisement
Add Comment
Please, Sign In to add comment