In: Computer Science
PSEUDOCODE:
1. You are designing a 2 dimensional game where players shoot bullets hugs at each other. Define a pseudocode function to determine whether a hug successfully 'hit' a player at a particular moment.
Real parameter playerX : target player's x position
Real parameter playerY : target player's y position
Real parameter bulletX : x position of bullet
Real parameter bulletY : y position of bullet
Return Boolean : True if distance between target and player within
10 False if not You may need to look up the formula for distance
between points in 2d space. Do not use any library functions except
'pow' and 'sqrt' if you need them.
2.Define a pseudocode function that takes in an Integer and returns the absolute value of that integer. The solutions are notthe result of some programming trick but are more related to arithmetic and math and there are multiple solutions to this.
3.Define a function within a flow chart that has 2 Real parameters and returns the larger of them. If they are the same return either argument. DO NOT SUBMIT PSEUDOCODE FOR THIS.
4. The colors red, blue, and yellow are known as the primary colors because they cannot be made by mixing other colors. When you mix two primary colors, you get a secondary color, as shown here:
● When you mix red and blue, you get purple.
● When you mix red and yellow, you get orange. ● When you mix blue
and yellow, you get green.
Design a program in pseudocode that prompts the user to enter the names of two primary colors to mix. If the user enters anything other than “red,” “blue,” or “yellow,” the program should display an error message. Otherwise, the program should display the name of the secondary color that results.
Q1:#Used Euclidean Distance for calculating the
distance
boolean
Hit(Real_parameter_playerX,Real_parameter_playerY,Real_parameter_bulletX,Real_parameter_bulletY)
{
x_dist=pow(Real_parameter_playerX - Real_parameter_bulletX,
2)
y_dist=pow(Real_parameter_playerY - Real_parameter_bulletY,
2)
distance =pow(x_dist+y_dist,0.5)
if distance<=10
return True
else
return False
}
Q2:
int absolute(int number)
{
if number<0
return -number
else
return number
}
Q3:
float greater(float a ,float b)
{
if(a >b)
return a;
else
return b;
}
Q4:
colour1=input('Enter the first colour')
colour2=input('Enter the second colour')
if colour1!="red" or colour1!="blue" or colour1!="yellow" or
colour2!="red" or colour2!="blue" or colour2!="yellow"
{
print("Entered colour is not primary colour")
}
else
{
if colour1=="red" and colour2=="blue"
print("Purple")
else if colour1=="red" and colour2=="yellow"
print("Orange")
else if colour1=="yellow" and colour2=="blue"
print("Green")
}
NOTE:If you find the answer helpful,please like the answer. Thank You!