Pierre Angelo

Generation

generate functionWed, 29 Mar 2023

A scene must be created in Unity that contains: or a cannon that automatically moves up and down on the left side from the screen. This cannon will shoot balls every second. The balls will bounce against the ground and will be destroyed when colliding with the character o The throwing force of these balls will be between 0 and 500. We will have different options to calculate this value. We will create the following functions for it: a) float P01FuerzaFija(): Impulse with fixed value (500) b) float P02RandomRange(): Random impulse in a range of values defined[200, 500] c) float P03RandomDosDados(float faces): Let the sum of two values random, such that its value is in the range [0, 500] d) float P04RandomVariousDice(int dice, float faces): Let the sum of several dice (this will be a variable that we can modify). so that the value of the sum is in the range [0, 500] e) float P05maxDice(int dice, float faces): Several dice are thrown and gets the biggest of them f) float P06discardMinDice(int dice, float faces): The value of the impulse will be the sum of n dice. n+1 dice will be rolled and the lowest one is discarded from them g) float P07discardMinAndReturnToRoll(int dice, float heads): The value of the impulse will be the sum of n dice. n dice will be rolled, the minor and this one will be thrown again h) float P08discardMaxAndReturnToRoll(int dice, float heads): The value of the impulse will be the sum of n dice. n+1 dice will be rolled and the greatest of them i) float P09PossibleBonus(float force, float bonus, float probability): will add a boost boost with a 20% chance of this happen o The value with which each ball is driven will be shown on the screen

#include <stdlib.h> #include <time.h> // Return random number between 0 and 500 float P02RandomRange() { return rand() % 500; } // Return random number between 0 and 500 float P03RandomDosDados(float faces) { return (rand() % faces) + (rand() % faces); } // Return random number between 0 and 500 float P04RandomVariousDice(int dice, float faces) { float result = 0; for(int i = 0; i < dice; i++) { result += rand() % faces; } return result; } // Return random number between 0 and 500 float P06discardMinDice(int dice, float faces) { int min = 0; float result = 0; for(int i = 0; i < dice + 1; i++) { int r = rand() % faces; if(i == 0) { min = r; } else if(

Questions about programming?Chat with your personal AI assistant