Create a short obstacle-avoidance collection style game

Assignment Help Python Programming
Reference no: EM131862111

Computer Science Software Development for Games Assignment: Sprites and Libraries

Overview - Create a short obstacle-avoidance, collection style game. You will integrate all the things you've practiced so far into a single cohesive whole. There will be sound, graphics, player movement, points, a title screen, a credits screen, and collision detection (handled by pygame Sprites).

Role: Sound / Art Engineer

Find appropriate sounds and graphics for the game.

Assure that licenses are being followed (credit screen, licenses included somewhere, etc).

Create a Music class that includes the following methods:

  • play_once(String id) - Plays a previously loaded song referenced by id
  • play_repeat(String id) - Plays a previously loaded song referenced by id on repeat
  • stop_repeat(String id) - Stops a previously playing song referenced by id
  • init(String level) - Loads all sounds and music for a specified level

Create an Art class that includes the following methods:

  • init(String level) - Loads all graphics associated with a level (Note: It may be a good idea to clear out any old level graphics as well)
  • get_image(String id) - Retrieve an image referenced by id

Create an TitleLevel class

  • Simple scene giving the title of your game and the authors. Indicate that the player should press one key to see the credits and one key to start the game.
  • Note: There should only be one copy of the "pygame template" code.
  • This might mean that you need to create a parent class called Level and decide what pieces are duplicated between the TitleLevel, CreditsLevel, and main game. Remember, DRY (Don't Repeat Yourself!)

Create an CreditsLevel class

  • Simple scene giving the title of your game and the authors. Indicate that the player should press one key to see the credits and one key to start the game.

Each of these classes should be in a separate file!

Role: Gameplay Engineer

This role is based heavily on lab 13 and 14 in the book (you'll notice a large portion of the text taken word for word) Just because this role has more text doesn't make it more or less difficult. The instructions are just broken down into smaller pieces than the other roles.

Start with the program.

Update the comments at the beginning to reflect that it is now your program, not the author's.

Modify it so the player moves with the keyboard rather than the mouse.

Out of this file, you will need to grab the Player class and move it to your own program. Do not get rid of the Block class. You will have both the Block and Player class in your program.

Right now, your player is an instance of Block. You will need to change it so that you create an instance of Player. Note that the constructor for Player takes different parameters than Block.

Update your event loop so that it responds to keyboard input like this new example does.

Remove the code that moves the player with the mouse.

Make the player blue.

Make sure there is exactly one call to all_sprites_list.update() in your main program loop. This will call the update() method in every sprite.

Test and make sure it works now.

Create both good sprites and bad sprites

Good Sprites

  • Where you create 50 blocks now, instead of adding them to a list called block_list, add them to a list called good_block_list.
  • Make the blocks green.
  • Where you check for block collisions in the main loop, update the check so it uses good_block_list.

Bad Sprites

  • Duplicate this code and add 50 more blocks to a new list called bad_block_list.
  • Make sure your program only creates one all_sprites_list.
  • Don't recreate the list right before you add bad blocks or the player.
  • Make the blocks red.
  • Duplicate that code and check against bad_block_list. Decrease the score instead of increasing it.
  • Test and make sure it is working.

Adding Flair

  • Call the Art/Sound Engineer's code to use graphics to signify good/bad sprites. If the Engineer isn't done yet, just use rectangles.
  • Make sure you replace the "blue block" player with an image from the Art Engineer
  • Rather than simply use print to display the score on the console, display the score on the graphics window. Go back to the end of Chapter 5 and look up the section on drawing text.
  • Call the Art/Sound Engineer's code to add sound effects when the user hits good blocks, or bad blocks. If the Engineer isn't done yet, just output some text to the console.
  • Add a check and make sure the player doesn't slide off the end of the screen. This check should go in the update method of the Player class. There should be four if statement checks, one for each border. If the player's x and y get outside the bounds of the screen, reset the player back inside the screen. Do not modify change_x or change_y. That doesn't work for player-controlled objects. Don't forget to check the right and bottom borders, they are easy to get wrong.
  • Also play a sound using the Art/Sound Engineer's code if the user tries to slide off the screen.
  • Check to make sure the bump sound doesn't continually play when the user is at the edge of the screen. If it does, the program is checking the edge incorrectly.

Creating Libraries

  • Next, you'll want to create libraries out of your code.
  • Move the Block class into a new file. Many people get confused between the name of the library file, the name of the class, and the variable that points to the instance of the object. Library files should be all lower case. I'd recommend calling your new file that you put the Block class into block_library.py.
  • Make sure your program runs like before. Adjust import statements as needed. Remember that you prepend the library name to the class, not the variable that points to the instance of the class. For example: my_dog = dog_library.Dog() and NOT dog_library.my_dog = Dog() because Dog is what is in the library, not my_dog.
  • Define a GoodBlock class in a new file, and inherit from your Block class. I'd recommend using the file name goodblock_library.py to keep with the pattern we set up before. Remember, define the class. Don't create an instance of it. Your for loop that creates the instances does not move.
  • Add a new update method. (You probably don't need a new __init__ method.) Make the good block randomly move up, down, left or right each update. (Change self.rect.x and self.rect.y randomly each time the update function is called. Not to a completely new number, but add a random number from -3 to 3 or so. Remember that random.randrange(-3,3) does not generate a random number from -3 to 3.)
  • Change your for loop so that it creates instances of the GoodBlock class and not your old regular Block class.
  • Call update on the list of all the sprites you have. Do this in the main program loop so the blocks keep moving, not just once at the start of the program.
  • Test and make sure it works.
  • It is ok if the sprites move off the screen, but a common mistake results in the sprites all moving up and to the left off the screen. If that happens go back four steps and check your random range.
  • Double check, make sure GoodBlock inherits from the Block class. If done correctly, GoodBlock won't need an __init__ method because it will get this method from Block.
  • Create a BadBlock class in a new file and inherit from the Block class.
  • Make an update function and have the bad block sprites move down the screen. Reset the block to the top when it falls off the screen. You may instead use a different type of movement. Take a look at the examples in the book for some ideas.
  • Test, make sure it works.
  • Double check to make sure each class is in its own file.
  • Again, make sure you only have one copy of the "pygame template" code. This may require you to create a class called GameLevel and a separate Main that controls Level swapping.
  • If you have extra time, you can look at the sprite examples section on the website and see how to get sprites to bounce or move in circles.

Role: File Management Engineer (Only in three person groups)

In a three-person group, rather than hard-coding the image and art location information into the classes, it should be stored in a file. The File Management Engineer's job is to create a File class in charge of loading these files from disk for use by the art and sound engineer.

A comma separated example might be:

objects.txt

player,Mario.png,0

good_block,mushroom.png,2

really_good_block,star.png,5

bad_block,goomba.png,-2

The third element is the number of points associated with collecting the item. This feature must be included in a three-person team.

You can also use JSON, YAML, pickle, or any other file format you feel is appropriate. I'm open to creativity and learning new things here.

They are also in charge of the contents of the files. There should also be a file for sounds in the game.

Note: The book does not talk about loading and saving files in Python.

Attachment:- Assignment File.rar

Reference no: EM131862111

Questions Cloud

Forward contract instead of a future : When would you use a Forward contract instead of a Future? When would you use a bond option rather than an interest rate forward contract?
Why a stronger dollar could enlarge the australian balance : a. Explain why a stronger dollar could enlarge the Australian balance of trade deficit. Explain why a weaker dollar could affect the Australian balance of tra
Write about scenario in citigroup as a hr manager : Explain a scenario whereby you might use the financial information found in the balance sheet or income statement of a company
Determine an operational definition used by the researchers : Identify whether the research study is a quantitative or qualitative design. Explain your answer.What were the findings of the study?
Create a short obstacle-avoidance collection style game : Computer Science 313 - Software Development for Games Assignment: Sprites and Libraries. Create a short obstacle-avoidance, collection style game
How much net working capital does the firm need to fund : JohnBoy Industries has a cash balance of $54,000, accounts payable of $134,000, inventory of $184,000, accounts receivable of $219,000, notes payable
Write a summary on origin of the 14th amendment : Write a 2 - 3 page Paper/Summary on origin of the 14th Amendment (Equal Protection Clause).
Calculate yield to maturity in excel : Calculate Yield to Maturity in Excel using above Information. Provide excel formula
What is the expected value of the game : 1. You play a game where if the flip of a fair coin results in heads, you get $10,000; and nothing if it comes up tails. Answer each of the following questions:

Reviews

len1862111

2/14/2018 2:40:05 AM

Detailed Question: Python Programming. Hello dear, I have an assignment for class Software Development for Games. The assignment includes three persons each person has different part one got part (Role: Sound / Art Engineer) and other got a part (Role: Gameplay Engineer) and [[[My part is (Role: File Management Engineer)]]] see the file and read first (Overview) to understand We use in this class python (import pygame). You should work on my computer by TeamViewer to show you our work on Github.

len1862111

2/14/2018 2:39:59 AM

Rubric - Two Person Team Title Screen is present and contains the name of the game with instructions to go to the credits screen or start the game (9 points) You can press a key to go to the credits screen, You can press a different key to start the game, You can press a different key to quit the game entirely. Credits screen includes any necessary licensing information, along with author names and roles and instructions on how to play the game (9 points). Classes in separate libraries include: GoodBlock, BadBlock, Player, Block, Music, Art, Level, CreditsLevel, TitleLevel, Main, GameLevel (33 points)

len1862111

2/14/2018 2:39:53 AM

If you choose not to include a class from this list, you must include an indication of why in your final submission. GoodBlocks and BadBlocks must move in slightly different ways. (3 points). GoodBlocks, BadBlocks, and Player should have different images (3 points). There should be a sound effect when the Player collides with a GoodBlock and a different sound when colliding with a BadBlock (3 points). There should be background music playing. (3 points). The background music should be different between the Game and the Title/Credits screen. (3 points). The background music should repeat after playing once. (3 points). The player should not be able to scroll off the screen. (3 points). When the player hits the border of the screen, a sound effect should play (and should only play once). (3 points). Current score should be displayed on screen while playing the game. (3 points). The player can press a key to quit the game and return to the title screen. (3 points). Uses descriptive variable names (3 points)

len1862111

2/14/2018 2:39:46 AM

In your blackboard submission include: The URL of your Git Repository, your final version should be in master - 1 point, An explanation of why you did not include a particular class as described above (must indicate how your design is better and provides more flexibility / readability). A two-person team will have their score multiplied by (100/85) to make it worth the same number of points as the three-person team score. Three Person Team All of the above PLUS… - Includes a class called File that loads files from disk indicating the art and sound assets in the game. (6 points) - Includes a file for Block object assets (3 points) - Includes a file for sound assets (3 point) - Adds the ability for GoodBlocks and BadBlocks to give differing number of points depending on the object information in the file. (3 points)

Write a Review

Python Programming Questions & Answers

  Grade that will calculate and return a student''s exam

Write a function overall Grade that will calculate and return a student's 2316 exam average. It will accept five parameters, which correspond to exam1,2,3,4 and the Final grade. It should replace the lowest exam grade with the 2nd lowest exam grade

  Implement the sieve of eratosthenes

Implement the Sieve of Eratosthenes and use it to find all prime numbers less than or equal to one million. Use the result to prove Goldbach's Conjecture for all even integers between four and one million, inclusive.

  Write a program that asks the user for a letter

Write a program that asks the user for a letter. The program should then determine if the letter is a vowel or not

  The function should return the day name (''su'',''mo''..etc)

Write the function day(d,m) where m is an integer from 1 through 12 expressing a month, and d is an integer from 1 through 31 expressing the day part of a date in 2014.

  Write a question class to hold the data for trivia question

To create this program, write a Question class to hold the data for a trivia question. You write a short description of what the program will do.

  Modify the caesar cipher program you completed

In this project, you will be modifying the Caesar Cipher program you completed earlier in the semester.

  Write a function rmduplic(l), where l is any list

Write a function rmDuplic(L), where L is any list. The function should return a list M that contains the same items as L, except that repetitions (duplicates) have been removed: only the first occurrence of each entry is kept (i.e., order is prese..

  Create a python program to decide a small election

Create a Python program to decide a small election for the mythical country of Nerdvana. The method being used to decide that election was.

  Arithmetic progression is a sequence of numbers

An arithmetic progression is a sequence of numbers in which the distance (or difference) between any two successive numbers if the same.

  Write a program in python to draw a blue triangle

Write a program in Python to draw a blue triangle in a drawing window. Write a program in Python that moves the triangle in an animated movement. Write a program in Python to draw a simplified face.

  Write a non-fruitful function drawequitriangle

Write a non-fruitful function drawEquitriangle(someturtle, somesize) which calls drawPoly from the previous question to have its turtle draw a equilateral triangle

  Write program that creates an object of productionwork class

Write a program that creates an object of the ProductionWorker class and prompts the user to enter data for each of the object's data attributes.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd