Question: Lab 9 : Implement the program in the picture to the right. A video has also been provided showing how this program is supposed to

Lab9: Implement the program in the picture to the right. A video has also been provided showing how this program is supposed to work while in action. Note the following:
General Info:
o The screens size is 500x500.
Files:
o The 3 images needed are provided.
o The 3 sound files needed are provided.
Images:
o All images files are either 300x300 or 400x400.
o You must scale the images down to 100x100 before using them as buttons.
o The laser images center is at the exact center of the
screen.
o Both the on and the off button are aligned horizontally with the laser button.
o The on buttons right border is 20 pixels away from the laser buttons left border.
o The off buttons left border is 20 pixels away from the laser buttons right border.
Button Font:
o This refers to all the Font objects rendered under the buttons.
o All of these Font objects use the default Pygame font, and are size 32.
o All of these font Surfaces are vertically aligned with their respective buttons.
o All of these font Surfaces top border are 20 pixels down from their respective buttons bottom border.
Status Font
o This refers to the Font object right above the laser button.
o This Font object uses the default Pygame font, and is size 64.
o This fonts Surface is vertically aligned with the center of the screen.
o This fonts Surface center is 80 pixels above the center of the screen.
Sounds:
o Only one sound can be playing at a time.
Functionality:
o While the laser is Off, the Shoot and Power Down button do nothing.
o Upon pressing the Power Up button, play the power up sound and change the status to Charging.
o When the power up sound finishes playing, change the status to Ready.
o While the laser is Ready, the Power Up button does nothing.
o While the laser is Ready, pressing the Shoot button plays the shoot sound and changes the status to Shooting.
o When the shooting sound is done playing, change the status back to Ready.
o While the laser is Ready, pressing the Power Down button plays the power down sound and changes the status to Discharging.
o When the power down sound finishes playing, change the status to Off.
o While the laser is Charging,Discharging, or Shooting, none of the buttons do anything.
Hint: You should use a couple of extra Boolean variables to keep track of when the laser is charged and when the laser is busy doing something.
extra info:
Transform Module: This module contains several different functions to apply transformations to your image, such as rotation, flipping, and scaling. Notice that most of these methods are destructive, meaning that information on the original image will be lost. When applying a transformation, always save the result onto a different variable; never save it back into the original variable.
original = pygame.image.load(filename.png).convert()
flip_horizontally = True
flip_vertically = True
flipped_image = pygame.transform.flip(original, flip_horizontally, flip_vertically)
new_width =50
new_height =50
scaled_image = pygame.transform.scale(original,(new_width, new_height))
new_angle =40
rotated_image = pygame.transform.rotate(original, new_angle)
Flip: Flips the image, either horizontally, vertically, or both. Takes in 3 parameters: the Surface to be flipped, and two Booleans. Returns a Surface.
Scale: Resizes the image. Takes in 2 parameters: the Surface to be scaled, and the dimensions of the scaled Surface. Returns a Surface.
Rotate: Rotates a Surface. Takes in 2 paramters: the Surface being rotated, and the angle of rotation. Positive numbers rotate counterclockwise, while negative numbers rotate clockwise. Returns a Surface.
Mixer Module: This module allows for the creation of Sound objects, which can then be played. You can create a Sound object as follows:
sound = pygame.mixer.Sound(filename)
Once you have a sound object, you can use the following methods:
sound.play() # plays the sound
sound.stop() # stops playing the sound
sound.set_volume(volume) # sets the volume of the sound
sound.get_volume() # returns the current volume of the sound
Notice that the sound volume must be a number between 0 and 1 inclusive, with 0 being not making any sound, 1 being the sound at its loudest, and 0.5 being midway between the two.
Its worth noticing that you can check if the Mixer is currently playing a Sound using the method below, which returns a Boolean:
pygame.mixer.get_busy()
Font Module: This module allows the creation of Font objects, which can be used to write things to the Display Surface. First, you must create a Font object:
font_object = pygame.font.Font("font_file", 32)
The Font constructor takes in 2 parameters: The name of the file holding the font, and the size you want the font to be. Notice that you can pass a None as your first parameter, making Pygame use its default font. Once the Font object has been created
 Lab9: Implement the program in the picture to the right. A

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!