Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Your Task Now make the following updates to the program code: 1. The start up code shows the former programmer was a bit lazy {jokingl}

image text in transcribedimage text in transcribedimage text in transcribed
Your Task Now make the following updates to the program code: 1. The start up code shows the former programmer was a bit lazy {jokingl} in creating the player... please put them in the centre of the screen (not slightly offset as they are). For this step you will need to update the code in new _player. - The problem is that the player x, y are based on the top left of the player. One way to solvethis is to use the screen width and sprite width functions. The correct left side for the player should be the screen width - the sprite width all divided by 2. - Hint: To call sprite_width you will need to pass it the sprite to get the width of. If you look at the program's structs you can see that the player_data has a player_sprite field. This will contain thesprite you want to get the width of. In this case the result variable is your player_data, so result.player_sprite will be the sprite you need to access. 2. The former program seems missed one of the ships... pressing 1, 2, or 3 should switch the player ship. - Please fix this so a switch between the different ships can be achieved. - Hint: Start at handle_input and step through the code yoursetf. Where are these changing? Whyare they not all working? 3. There are some power up images in the resources folder {I've listed them below). We will use the Fuel power-up and I want you to pick another 5 of these - as I don't think we want all of them - and start to add them into the game. Note: We will start by getting these showing up as things for the player to collect. Then we can work on effects of these later. The power up images include: shield, power, potion, fuel, drops, diamond, star , cash, nos, level, bullet, coin, battery, heart, muscle, and time. They are already loaded, so you can access them by name straight away. Please add code to manage these in the project. This will involve: o Create a new power_up.cpp file, and a new power_up.h header file, to manage the power up related code. Hint: Remember to add the header guard to the header file. Just as you did in the earliertasks. o Create an enum in the header le to represent these different kinds of power up. We can use this to represent the different power-ups within the code. o Create a function to convert an power-up enum values to an image. Hint: You will need a switch based on the passed in parameter, then you can return the bitmap you get back from calling bitmap_named. eg. case SHIELD : return bi tmap_na.med ( " shield") ,- . Have a look at the names in the Iost_in_space.b(t bundle le. o Create a struct in the header le to represent a power-up. Each power-up needs to have: - The kind of power-up it is - A sprite for their visual representation a Add functions and procedures to work with power-ups: initialise a power-up (call it new_power_up} draw_power_up and update _power_up. Include these in the header and implement in the source le. _ ImnlnmnJ an... nnu.n \"n nmnl-lnn "n n...... u Ant.- n..." nun". ..l'.l..I-.I.. v I Randomly pick a power_up kind using static cast(md.(6)) - Use the enum values to pick its bitmap. For example. you can assign result.pouer up sprite I create sprite( power up bitmapltkind} ); - Position the power_up at the indicated x,y location {using the value passed to the related parameters) - Start power_ups with a small random velocity. Hint: You can do this by calling sprite_set_dx - pass in your sprite and a small value for the \"change in x". eg: sprite_set_d.x (result.power_up_sprite, md.() * 4 2) ; Here the rnd () call will return a random value between 0 and 1. Multiplying this by 4 gives 0 - 4. Subtracting 2 gives -2 to 2. - The draw _power_up procedure will accept a power_up_data value (by constant reference} and can call draw_sprite on the power_up_spri'te. - Similarly, update _power_up will also accept a power_up_data value (this time by reference} and will call update_sprite on the power_up_spri'te. This will move the power_up based on the velocity above. 0 Add a power-up into main - start it near the player - Make sure to include the new power-up header - Remove the rectangle - it was just there so we could see the camera moving. - Use new_power_up(. ..} to initialise your power-up - pass in any value for x and y just make it something that will appear on screen. - Update the game loop so that it will update and draw the power-up. 4. Improve the heads up display (HUD) - which currently just displays the score and location as text. You can adjust the aspect ratio of the window if you want - it doesn't need to remain the size it is. o Create a procedure to draw this, in the programcpp le. a Design your own HUD to display the following: - Use an image or some shapes to define the area of your HUD. Make it look good if you can (though we will focus on the code}. - Location of the player - Score of the player - A fuel gauge - using one of the bars from the resources {see below} - Then add at least two other features yourself. Think of something that links to your selected power-u ps. Important: When you implement the code for the HUD you will need to use option to screen so that the coordinates don't move with the camera. Have a look at the article on using the SplashKit camera. 5. Implement the code to draw the background of your HUD. 6. Add the code to show the player's location in your HUD. 7. Add a fuel _pc1 field to the player struct, and initialise this to 0.75 when the player is created. Then add the code to draw the fuel gauge on the HUD. This will visually show how much fuel is u. "urns-In...\" un- uuuu av hum-l un- unusualu..."- u. Jan... I nunr. 6. Add the code to show the player's location in your HUD. 7. Add a fuel _pc1 eld to the player struct, and initialise this to 0.?5 when the player is created. Then add the code to draw the fuel gauge on the HUD. This will visually show how much fuel is remaining as a partly full bar. There are some \"bar\" images in the Resources. You can use these to show how much fuel is remains {and maybe for some of your own features on the HUD). 0 Add the bars you want to the resource bundle so they are loaded when the program loads. a Draw one of the empty bars to the screen as part of the HUD - or embed it in your background. a lOver the top of this, draw part of one of the full bar bitmaps {your choice which) Use draw bitmap with option part bitmap to- draw half of the "full" bar. Set the part to start at the 0.0 of the image {top left) use all of its height and 25% {0.25) of its width. Later we can dynamically change this percent. and it should have the effect of making the bar appear to red uceil ncrease. Note: You need to combine the part option with the to screen option for example: draw_bitmap(\"'full", bar_)(, bar _y, option _part_bmp{0, 0, part_wid'lh, bibnap_height{\"full\"), option_to_screen{)}); 3. Add two additional visual component relating to your power-up(s). with relevant data values player data added to the struct. Ideally the two features should have different visual representations. You could use a bar, show a value, or show something as ontoff (greyicoloured). Be creative. Below are some examples for your reference. Note, here you aim to demonstrate that you are able to store useful data, link them to the corresponding entity, and dispiay them via your program/code with structures. Some graphicai assets are already avaiiabie in the resourceszip for your usage as introduced in the eiaboration video. Creating new graphics/assets is not the focus in this step, uniess you are interested in doing so and you are preparing necessary assets for your coming Custom Program. Exampie 2 3', Low u. a...\

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions