10/05/2019 Assignment 3 — CSSE1001 Semester 1, 2019file:///Users/ben/university/tutoring/CSSE1001/2019s1/a3/2019s1a3/spec/dist/index.html 1/11NinedraftAssignment 3CSSE1001/7030Semester 1, 2019Version 1.0.020 marksDue Friday 31 May, 2019, 20:301. IntroductionThis assignment provides you the opportunity to apply concepts taught throughout the courseto extend the functionality of a basic 2d sandbox game, in the style of Minecraft & Terraria.The main concepts involved are Graphical User Interfaces (GUIs) and object-orientedprogramming. The assignment tasks are to add features to the game, as described in therequirements below.You are encouraged to review some similar games, to better understand how this type of gameis played, and for inspiration on advanced features. It is better to do this after reading throughthis document in its entirety.Because this assignment deals with multiple files, while not required, you may wish toinvestigate a more sophisticated IDE. A popular option is PyCharm, which is free for students.VS Code, which is also free, is another common option. Please note that these tools havesignificantly more complex user-interfaces than IDLE, so you may find them a littleoverwhelming if you are only familiar with IDLE.2. Overview2.1. Getting StartedThe archive contains all the necessary files to start this assignment. Asignificant amount of support code has been supplied so that you begin with a simpleapplication that is almost working.The main assignment file is , which contains an incomplete implementation of, the top-level GUI application class. The other files are support code whichmust not be edited. Initially, you do not need to understand much of this code, but as yousta3_files.zipapp.pyNinedraftApp10/05/2019 Assignment 3 — CSSE1001 Semester 1, 2019file:///Users/ben/university/tutoring/CSSE1001/2019s1/a3/2019s1a3/spec/dist/index.html 2/11progress through the tasks, you will need to understand more of this code. You should addcode to and modify to implement the necessary functionality.You are permitted to create additional files to simplify the separation of tasks (i.e. task1.py,task2.py, etc.), although this is not required. If you do this, must be the entry point toyour application. One way to achieve this is to move to a separate file, suchas . Regardless of how you structure your files, the code must always be able to bedemonstrated by running .2.2. Pymunk LibraryPhysics is implemented in the game using the Pymunk library. You will need to install thislibrary in order to implement your tasks for this assignment. Pymunk can be installed byrunning the included .3. Assignment Tasks3.1. Task OverviewThis assignment is broken down into three main tasks:1. The first task involves adding lines of code to clearly marked sections within the mainassignment file.2. The second task involves extending the design to add more interesting functionality to thegame.3. And the third task involves adding sophisticated functionality to further improve thegameplay experience.For CSSE7030 students only, there is an extra task that involves doing independentresearch.In general, as the tasks progress, they are less clearly prescribed and increase in difficulty.3.2. Task BreakdownCSSE1001 students will be marked out of 20 & CSSE7030 students will be marked out of 26based on the following breakdown. Tasks may be attempted in any order, but it isrecommended to follow this breakdown, top-down, completing as much as possible of eachtask before moving on to the next.Sub–Task MarksTask 1Basic Features9 marksapp.py NinedraftAppapp.pyNinedraftAppbase.pyapp.pysetup.py10/05/2019 Assignment 3 — CSSE1001 Semester 1, 2019file:///Users/ben/university/tutoring/CSSE1001/2019s1/a3/2019s1a3/spec/dist/index.html 3/11Sub–Task MarksApp Class 1 markMouse Controls 2 marksStatusView Class 2 marksBasic Items 2 marksKeyboard Controls 1 markFile Menu & Dialogs 1 markTask 2Intermediate Features7 marksMore Items 2 markCrafting 3 marksCraftingTableBlock 2 marksTask 3Advanced Features4 marksBees 1.5 marksFurnace 2.5 marksPost-Graduate TaskIndependent Research6 marksArrow Movement 4 marksInteraction with Blocks 2 marks3.3. Mark BreakdownFor each task, marks will scaled according to the following breakdown.Description Marks10/05/2019 Assignment 3 — CSSE1001 Semester 1, 2019file:///Users/ben/university/tutoring/CSSE1001/2019s1/a3/2019s1a3/spec/dist/index.html 4/11Description MarksCode QualityCode is readable. Appropriate and meaningful identifier nameshave been used. Simple and clear code structure. Repeated codehas been avoided.15%Code has been simplified where appropriate and is not overlyconvoluted.10%Documented clearly and concisely, without excessive or extraneouscomments.15%FunctionalityComponents are functional, without major bugs or unhandledexceptions.Assessed through user testing/playing, not automated testing.60%4. Task 1 – Basic GUI10/05/2019 Assignment 3 — CSSE1001 Semester 1, 2019file:///Users/ben/university/tutoring/CSSE1001/2019s1/a3/2019s1a3/spec/dist/index.html 5/11There are a significant number of comments in intended to help you complete thistask.4.1. App ClassWrite a function that launches the GUI. Call this function insidean block.Modify so that the title of the window is set to something appropriate (i.e.Ninedraft, etc.).4.2. Mouse ControlsAllow the user to attack the target by clicking the left mouse button. While their mouse is beingmoved the game window ( ), show the target cursor over the block position theyhave moused over. If the mouse is out of range or leaves the window ( ), hide thetarget cursor.Allow the user to use the currently selected item by clicking the right mouse button. When theuser is holding a block (dirt, stone, etc.) and right clicks on empty space, which is in range, theblock is placed at that location. If the user is instead holding a Item (tool, weapon, bare hand,etc.), then right clicking on the target will attempt to use that item on the target.See the , and methods in .4.3. StatusView ClassDefine a class named which inherits from . This class is used todisplay information to the user about their status in the game. The s widgetsmust:1. be updated whenever necessary (i.e. when gaining or losing health or food – see comments)2. be laid out approximately according to Basic GUI Example3. contain the following widgets:Health (first row; left) A label to display the amount of health the player hasremaining, with an image of a heart to the left. The health must be rounded to thenearest 0.5 (i.e. half or whole).Food (first row; right) A label to display the amount of food the player hasremaining, with an image of a drumstick to the left. The food must be rounded to theBasic GUI Exampleapp.pymain NinedraftApp mainif __name__ == ...NinedraftAppGameViewGameView_left_click _right_click _mouse_move NinedraftAppStatusView tk.FrameStatusViewTask1.3 (Status View): Update ...10/05/2019 Assignment 3 — CSSE1001 Semester 1, 2019file:///Users/ben/university/tutoring/CSSE1001/2019s1/a3/2019s1a3/spec/dist/index.html 6/11nearest 0.5 (i.e. half or whole).Note: For convenience, you should have a setter method for each of the relevant widgets. i.e., etc.The class should be added to the application in a frame below the .4.4. Basic ItemsModify the function so that it can generate wood & stone. These should beinstances of the class, which drops a block form of itself when placed. E.g.4.5. Keyboard Controls4.5.1. MovementWhen the player presses the space bar, they should jump into the air. This can be achieved bymodifying their velocity.Set the velocity to something reasonable, that meets the following requirements:The y-component must be negative (because computer graphics are drawn with thepositive y-axis facing down)The x-component must not be zero, but should be different to what it was (i.e. if the userwas moving left, when they jump, they should also keep moving left, but at a differentspeed)Double/triple/etc. jumping is allowed, so you do not need to check that the player is on theground before jumping4.5.2. HotbarWhen the user presses a number key (1-9, 0), the corresponding item in the hotbar should beselected. If the corresponding item is already selected, it should instead be deselected. Notethat 1 corresponds to the first (leftmost) item in the hotbar, and 0 to the last (rightmost), etc.4.6. File Menu & DialogsImplement a menu bar, with a menu. The File menu should have the following entries:: Restarts the game: Exits the applicationset_health(health)StatusView GameViewcreate_itemBlockItem>>> wood = create_item(wood)>>> wood # Is an object of BlockItem(wood)>>> wood.place(...) # Returns an object of ResourceBlock(wood)FileNew代写CSSE1001作业、代做Python课程设计作业、代写Python程序设计作业、GUIs留学生作业代做 代做留学生 GameExit10/05/2019 Assignment 3 — CSSE1001 Semester 1, 2019file:///Users/ben/university/tutoring/CSSE1001/2019s1/a3/2019s1a3/spec/dist/index.html 7/11When the player attempts to exit the application, either by the file menu or otherwise, theyshould first be prompted with a dialog to confirm that they indeed want to quit the application.Further, if the player dies, they should be informed of this with a dialog, and asked if they wantto restart the game.Note: On Mac OS X (and similar), the file menu should appear in the global menu bar (top ofthe screen).5. Task 2 – Intermediate FeaturesFor any subclasses you implement, in addition to the required methods listed, you will alsoneed to override any relevant methods from the super class that would raise. You will also need to modify the relevant functions toallow your new things/items to be created.5.1. More ItemsImplement the following subclasses of the class and add them to the game:5.1.1. FoodItemImplement a class called which inherits from . When aobject is instantiated, it needs to be given an item identifier and a strength. Theclass must have the following method:get_strength() -> Returns the amount of food/health the item recovers the player by whenused.Add a stack of 4 of these to the starting hotbar, and modify the function so thatleaf blocks can drop apples (a food item with 2-strength)5.1.2. ToolItemImplement a class called which inherits from . When equipped, the toolsdamage certain blocks faster than the hands, and are able to mine materials that the handscannot (such as stone from stone blocks). A tool is depleted when its durability reaches zero.When a object is instantiated, it needs to begiven an item identifier, the type of tool it will be and the tools durability. The class must havethe following methods:get_type() -> Returns the tools type.get_durability() -> Returns the tools remaining durability.can_attack() -> Returns True iff the tool is not depleted.NotImplementedError create_*ItemFoodItem Item FoodItem(item_id,strength)create_itemToolItem ItemToolItem(item_id, tool_type, durability)10/05/2019 Assignment 3 — CSSE1001 Semester 1, 2019file:///Users/ben/university/tutoring/CSSE1001/2019s1/a3/2019s1a3/spec/dist/index.html 8/11attack(successful) -> Attacks with the tool; if the attack was not successful, the toolsdurability should be reduced by one.Note: For tools made of a material, such as the stone axe, the should be, according to the break tables inFor example5.2. CraftingThe process of turning items into new items is called Crafting. The user can craft items andreorder their inventory/hotbar in a crafting screen. When the user presses the e key, the basiccrafting screen should toggle (switch between showing in a new window & hiding).Allow the user to reorder items in their inventory/hotbar by calling & hooking into the relevantmethods on the class. Further, allow the user to move items to and from thesimple crafter to craft new items.5.3. CraftingTableBlockImplement a class called which inherits from . Whenused, this block should trigger the crafting table screen. From the blocks perspective, this canbe achieved by returning an effect from the method.Lastly, extend the method to open the crafting screen.6. Task 3 – Advanced Features6.1. MobsMobs are non-player-characters in the game. They are living (have health) and can movearound. Some mobs can harm the player.item_id{material}_{tool_type} item.py>>> diamond_axe = ToolItem(diamond_axe, axe, 1337)>>> diamond_axe.get_type() # => axe>>> diamond_axe.get_max_stack() # => 1>>> for _ in range(995):... diamond_axe.attack(False)>>> diamond_axe.get_durability() # => 42InventoryViewCraftingTableBlock ResourceBlockuse>>> table = CraftingTableBlock()>>> table.use() # => (crafting, crafting_table)>>> table.get_drops(0, True) # => [(item, (crafting_table,))]NinedraftApp._trigger_crafting10/05/2019 Assignment 3 — CSSE1001 Semester 1, 2019file:///Users/ben/university/tutoring/CSSE1001/2019s1/a3/2019s1a3/spec/dist/index.html 9/11To complete this sub-task, in addition to subclassing , you will need to add additionalblocks & items to the game, including the relevant function, and drawing method(s)to the class.6.1.1. SheepImplement a class called which inherits from .Sheep move around randomly and do not damage the player.When attacked, a sheep should drop wool ( ), without taking damage.6.1.2. BeesImplement a class called which inherits from .Bees swarm the player, and individually cause a small amount of damage. They move slightlyquicker than the player, and swarm toward the player in a semi-random fashion. If there is ahoney block ( ) nearby (within 10 blocks), they willinstead swarm to the honey.The player can attack bees, and with simple tools they should individually be destroyed in onehit.When the player mines a hive block ( ), 5 bees should spawnand begin to swarm toward the player.6.2. FurnaceThe furnace allows the player access to another form of crafting, called smelting (also knownas cooking, baking, melting, drying, or burning). This process involves two items, a fuel sourceand the item to be heated. For example, the player can cook grain on wood to produce bread.See details on furnaces & smelting.Implement the class which inherits from . Connect it to your code,such that the player can craft a furnace on their crafting table using a ring of stone (a ring is a3x3 grid, with nothing in the centre). This should yield an item that can be placed as a furnaceblock, which when used opens the smelting screen.Ensure that the smelting screen shows some sort of icon to represent the smelting — you mayuse a simple canvas shape in place of the flame shown above.7. CSSE7030 Task – Independent Research7.1. Advanced FeatureMobcreate_*WorldViewRouterSheep Mobwool = Item(wool)Bee Mobhoney = ResourceBlock(honey, ...)hive = HiveBlock(hive)FurnaceCrafter Crafter10/05/2019 Assignment 3 — CSSE1001 Semester 1, 2019file:///Users/ben/university/tutoring/CSSE1001/2019s1/a3/2019s1a3/spec/dist/index.html 10/11This task involves adding a bow & arrow tool to the game. Add it to the players startinginventory.When attacking, the bow should fire a flaming arrow at a trajectory matching the mousesposition relative to the player. For example, if the player is centred at , and thecursor is at , the bow should fire at a 45 degree angle to the left. The further themouse is from the player, the stronger the arrow should fire, up to some maximum (i.e. 4blocks away).It is intended that gravity should cause the arrow to drop, and not necessarily pass through theposition on the cursor. Further, the bow should always fire, regardless of whether the target isin range.Physics in Ninedraft is implemented in the class using the pymunk library, so tosuccessfully complete this task, you will need to research this library and subclass .Further, to achieve full marks for this task, the flaming arrow must immediately destroy certainblocks on contact:Wood is instantly destroyed and drops nothingHive blocks are instantly destroyed, and drop honey ( ) withoutspawning any bees.8. Assignment SubmissionNote: There will not be a practical interview for the third assignment.Your assignment must be submitted via the assignment three submission link on Blackboard.You must submit a zip file, , containing and all the files required to run yourapplication (including images). Your zip file must include all the support code.Late submission of the assignment will not be accepted. Do not wait until the last minute tosubmit your assignment, as the time to upload it may make it late. Multiple submissions areallowed, so ensure that you have submitted an almost complete version of the assignment wellbefore the submission deadline. Your latest, on time, submission will be marked. Ensure thatyou submit the correct version of your assignment. An incorrect version that does not work willbe marked as your final submission.In the event of exceptional circumstances, you may submit a request for an extension. See thecourse profile for details of how to apply for an extension. Requests for extensions must bemade no later than 48 hours prior to the submission deadline. The expectation is that with lessthan 48 hours before an assignment is due it should be substantially completed andsubmittable. Applications for extension, and any supporting documentation (e.g. medicalcertificate), must be submitted via my.UQ. You must retain the original documentation for aminimum period of six months to provide as verification should you be requested to do so.(200, 200)(100, 100)WorldWorldBlockItem(honey)a3.zip app.py10/05/2019 Assignment 3 — CSSE1001 Semester 1, 2019file:///Users/ben/university/tutoring/CSSE1001/2019s1/a3/2019s1a3/spec/dist/index.html 11/11Change LogAny changes to this document will be listed here.转自:http://www.7daixie.com/2019051813954932.html
网友评论