CSC1002编程设计 写作、 辅导Python,Java程序

” CSC1002编程设计 写作、 辅导Python,Java程序CSC1002 Computational LaboratoryCSC1002 2021 Winter By Kinley LamSnake 2021OVERVIEWIn this assignment, you are going to design and develop a Snake game. The game is composed of 3objects: a snake, a monster and food items represented by a set of numbers from 1 to 9. In the figureshown above, the snake is represented by a sequence of squares where its head and its body aredisplayed in red and black colors respectively, while the monster by a purple square. The numbers arefood items to be consumed by the snake.The goal of the game is to maneuver the snake within the game area in four directions (up, down, leftand right), trying to consume all the food items while avoiding head-on collision with the monster. Aseach food item is consumed, the snake grows with its body lengthened in size equal to the value of thenumber being passed. While directing the movement of the snake you should avoid contact with themonster. Furthermore the monster is also programmed to be motioned in the direction towards thehead of the snake at a variable speed.CSC1002 Computational LaboratoryCSC1002 2021 Winter By Kinley LamThe following screens show the first Display of the game (left) and the start of the game (right) after amouse click:The following 2 screens show the snake With its extended tail after consumption of food items (4 6),while the monster actively chasing after the snake:CSC1002 Computational LaboratoryCSC1002 2021 Winter By Kinley LamThe following screen shows the ending of the game after the snake has consumed all the food; shownon the status area are the number of contacts with the monster and the total elapsed game time inseconds:The following screen shows the ending of the game where the snake collided head-on with the monsterand where some food items left unconsumed:CSC1002 Computational LaboratoryCSC1002 2021 Winter By Kinley LamSCOPE Design the snake game using the standard module turtle, including the following components:a. Game Area (status and motion area)b. A Snakec. A Monsterd. Food Itemse. Game Statusf. Controlsg. Motion Game Areaa. The game area is composed of an upper area for statuses and a motion area where thesnake and monster are moved around, Surrounded by a fixed margin along the foursides, with the following dimensions:i. Upper status area = 500 (w) x 80 (h)ii. Lower motion area = 500 (w) x 500 (w)iii. Margins = 80 pixels aroundb. Draw a border for both the status area and motion area. Food Itemsa. Represented as numbers from 1 to 9, displayed within the motion area in randomlocations. These numbers will be kept visible all time until they are consumed by thesnake. When the head of the snake crosses one of these numbers, the number beingcrossed is considered consumed And it will be removed from the game areapermanently. So, any one food item can be consumed once. Snakea. The snake is composed of a head with a tail which extends as it consumes any fooditems.b. Use only simple, built-in shape square for both head and tail, default size.CSC1002 Computational LaboratoryCSC1002 2021 Winter By Kinley Lamc. Use different colors for the head (ex: red) and the tail (ex: black with blue border color);choose a border color for the tail so that the length of the tail can be counted easily.d. The tail extends as the snake moves, not at the point when the food item beingconsumed; in other words, at the moment the snake crosses a food item, the snakedoesnt change in size; as the snake moves the tail extends in the direction of themovement as if the end of the tail sticks onto the screen. The tail extension ends whenthe length of the snake has grown in size equal to the value of the number beingcrossed. The following figure shows the sequence of moves of the snake crossing a fooditem.e. As the tail is being extended, the movement of the snake will slow down. See Timerbelow.f. At the start of the game, the length of the tail is set to 5. One square shape counts asone unit length, so the tail will be composed of 5 square shapes when fully extended. Monstera. A fixed size object to be programmed to move towards the snake, trying to make ahead-on collision.b. On startup, place the monster on a random position with a fair distance from the snake.c. The monster should move at a Random rate, a rate that is slightly faster or slower thanthat of the snake. See Timer below.d. Use only simple, built-in shape square for the monster, default size.e. Use a different color such as purple. Game Statusa. Show the motion of the snake (Left, Right, Up, Down, Paused), in other words, the lastmotion key pressed (including the space bar), regardless of whether the snake is inmotion or being blocked.b. Show the total count of body contact of the snake with the monster. The count shouldbe based on the motion of the monster timer. Each time the monster is re-positioned, itshould then check if it overlaps with any part of the snake.c. Keep track of the total elapsed game time in seconds. The time counter starts as soonas the game starts and will stop only when game is over. In other words, the counterwill not be stopped when the snake is being paused.CSC1002 Computational LaboratoryCSC1002 2021 Winter By Kinley Lam Motion via Timera. Timer controls the frequency that a specific event to take place at a regular interval, inthis case the event is the movement of either the snake or the monster.b. Use separate timers to manually refresh the movement of both snake and the monsteri. Turn off the built-in automatic screen refreshc. Keep the timer rate no Faster than 0.2 second.d. On each timer event, always advance the snake or the monster in a distance equivalentto the length of the turtle shape (square). If the squares dimension is 20×20 (pixels),then your logic should advance the turtle object 20 pixels at a time.e. Both snake and monster move in four directions, left, right, up or down, NOT diagonally.f. Design the timers in such a way:i. the monster should move in a random time range slightly above or lower thanthat of the snake, while snake always move at a fixed rate.ii. when the snake crosses a food item (a number) slow down its movement byincreasing its timer rate until its tail is fully extended, that is, the snake willmotion slower while the tail being extendediii. furthermore, you dont want the snake to move too fast that the monster willnever catch up with the snake, or vice versa. That is, you dont want themonster moves so quickly that it always catch the snake before it has a chanceto consume all the food items. Controlsa. Use the four arrow keys (Up, Down, Left, Right) to maneuver the snake in Up, Down,Left and Right motion respectively.b. The motion will continue in the direction of the last arrow key pressed. For an example,If Left key is pressed, the snake will continuously move in the left direction until adifferent arrow key is pressed.c. Use Space Bar to toggle (Pause and un-pause) snake motion (note: monster neverpause). While in motion, pressing the spacebar will pause the snake (not the monster).While paused, pressing the space bar the snake will resume motion in the direction ofthe last arrow key pressed. Furthermore, while paused, pressing any of the four arrowkeys will un-pause the snake motion and move in the direction of the arrow key beingpressed.d. Snake cannot move beyond the motion area; when the head of the snake is movedagainst any of the 4 sides, the snake will be stopped and it will remain blocked until itsheading is changed away from the edges.e. Snake can cross its body, left to right, up to down or vice versa.CSC1002 Computational LaboratoryCSC1002 2021 Winter By Kinley Lam Game Terminationa. The game ends when the snake consumes all the food items and its body is fullyextended, in this case Winner or the monster caught the snake, in this case GameOver. Game Startupa. On startup, show (1) the game area with a brief introduction to describe the gameobjective and control, (2) the snake (in red) positioned at center and (3) the monster(purple) at a random position far enough from the snake.;CSC1002 Computational LaboratoryCSC1002 2021 Winter By Kinley Lamb. User mouse-click anywhere on the Screen to start the game, all the food items will beshown subsequently, user then moves the snake around using the 4 arrow keys Coding Stylesa. Ensure that your program follows the proper layout structure as discussed in class.b. You might declare many global variables used for this assignment, ensure that aconsistent naming convention is in place to differentiate various variable scopes.NOTE: Keep your entire source code in ONE SINGLE file. Use only standard python modules In your design stick ONLY to functions, in other words, no class objects of your own.CSC1002 Computational LaboratoryCSC1002 2021 Winter By Kinley LamSTARTUP OPTIONSNot applicableSKILLSIn this assignment, you will be trained on the use of the followings: Use built-in turtle module to design the snake program as per scope Use standard objects (strings, Numbers lists) GUI interaction Variable Scope Functions for program structure and decompositionDELIVERABLES1. Design documentation (A1_School_StudentID_Design.doc/pdf)2. Program source code (A1_School_StudentID_Source.py)where School is SSE, SME, HSS, FE or LHS and StudentID is your 9-digit student ID.Zip all files above in a Single file (A1_School_StudentID.zip) and submit the zip file by due date to thecorresponding assignment folder under Assignment (submission)For instances, a SME student with student ID 119010001: A2_SME_119010001.zip:o A2_SME_119010001_Design.doc/pdfo A2_SME_119010001_Source.py5% will be deducted if any files are incorrectly named!!!For the design document kindly refer to section Design Documentation for details.CSC1002 Computational LaboratoryCSC1002 2021 Winter By Kinley LamDESIGN DOCUMENTATIONFor the design document provide write-up for the following sections:1. Designa. Overviewb. Data Modeli. describe core data objects called Data Model (such as list, string, dictionary andso on) that you used to develop your program for the following items:1. snake including the tail2. food itemsc. Program Structure (your thoughts and overall approach)i. describe the breakdown of your logic into various functions and how thesefunctions are organized (basically the structure of your program)d. Processing Logici. Describe the logic used to motion the snake and monster.ii. Describe the logic used to expand the snake tailiii. Describe the logic Used to detect body contact between the snake and themonster2. Function Specificationsa. Describe usage of all your own defined functions, including details of parameter(s) andoutput if any.3. Outputa. Show samples of output (including status) from your program, includingi. Winnerii. Game overiii. 2 others showing various stages of the game:1. With 0 food item consumed2. With 3 food items consumedCSC1002 Computational LaboratoryCSC1002 2021 Winter By Kinley LamTIPS HINTS Follow the layout structure as mentioned in class (import, declarations, functions, mainprocess). Clearly name and comment your global variables. Refer to python website for program styles and naming convention (PEP 8). Use Turtle() as objects for the snake, monster and all food items. Use the shape() function to set the shape for your objects, or pass the shape as string to theTurtle(). Note: use simple, built-in shape such as square for your snake and monster objects.Complex shapes will Slow down the screen refresh!!!! Use stamp() to make copy of the turtle shape at its current position; use clearstamp(idx) toremove a specific stamp copy or clearstamps() to clear one or more stamp copies. Use stampItems of the Turtle object to return the list of turtle stamps Use write() to display a text on the screen. Remember to set the pen in up position to avoid line drawing. Use ontimer() to motion your snake and monster. Use Screen() to configure the game area and use onclick() to capture mouse-click event. Use tracer(0) to disable auto screen refresh and call update() to manually refresh the game area. Refer to httpss://docs.python.org/3/library/turtle.html for more information on Turtle Graphics.SAMPLE OUTPUTRefer to the Overview session.CSC1002 Computational LaboratoryCSC1002 2021 Winter By Kinley LamMARKING CRITERIA Coding Styles overall program structure including layout, comments, white spaces, namingconvention, variables, indentation, functions with appropriate parameters and return. Design Documentation Program Correctness whether or the program works 100% as per Scope. User Interaction how informative and accurate information is exchanged between yourprogram and the player. Readability counts Programs that are well structured and easy-to-follow using functions tobreakdown complex problems into smaller cleaner generalized functions are preferred over afunction embracing a complex logic with nested conditions and sub-functions! In other words, adesign with clean architecture with high readability is the predilection for the course objectivesover efficiency. KISS approach Keep It Simple and Straightforward. Balance approach you are not required to come up with a very optimized solution. However,take a balance between readability and efficiency with good use of program constructs.ITEMS PERCENTAGE REMARKSDESIGN DOC 10%-15%CODING STYLES 20%-25% 0% IF PROGRAM DOESNT RUNUSER INTERFACE 15%-20% 0% IF PROGRAM DOESNT RUNFUNCTIONALITY 40% REFER TO SCOPEDUE DATEApril 25th, 2021, 11:59:59PMCSC1002 Computational LaboratoryCSC1002 2021 Winter By Kinley LamAPPENDIX – TEMPLATEDesign DocOVERVIEW Write one or two paragraphs to describe in high-level what your program does. See sectionOverview.DATA MODEL Describe the type(s) of data that you used to model your core objects in your program. In thiscase, it will be the snake, food items and monster, plus any other objects that you think ofessential to mention.PROGRAM STRUCTURE Describe the structure of your program, specifically how you organized your thoughts in termsof functions and how these functions are organized. In general, you might breakdown your logicinto many functions organized by functional components, each of which performs specific role. For each component, describe the role and list out the function(s) in high level description, leavethe details to be included in section Functional Specifications.PROCESSING LOGIC (SPECIFIC) Main processing logic – describe how you piece together various components and data model toimplement your program for the following items:o the logic used to motion the snake and monster.o the logic used to expand the snake tailo the logic used to detect body contact between the snake and the monsterFUNCTIONAL SPEC Describe usage of all of your own defined functions including an overview description, detaileddescription of parameters, as well as output if any.SAMPLE OUTPUT Include a few samples of Outputs from your program.CSC1002 Computational LaboratoryCSC1002 2021 Winter By Kinley LamOTHER IDEAS:If you feel that you have the passion for programming, heres list of other ideas that you could furtherenhance your program by refactoring your existing logic.1. Implement multiple monsters; start with one monster initially and then another one on everyfixed time interval, up to some numbers, say 3 (be cautious not to have too many monsterssuddenly). You need to ensure that use a different timer logic to for each monster chasing afterthe snake. Otherwise all monsters will merge into each other eventually and moved altogether.2. Randomly hide and unhide any food items.3. Randomly shift any food items; shift food items in random direction (left, right, up or down), nottoo much a shift, yet enough to confuse the player4. Do not allow the snake to cross its body; block its movement5. Implement surprise items; you can have reward or penalty items on screen for snake toconsume:a. Reward: Increase game time limit (20 seconds)b. Reward: Freeze motion of all monsters for a few seconds (10 seconds)c. Penalty: generate another food itemd. Penalty: Hide all food items for a few seconds (10 seconds)6. Add sound effect (motion, body contact, food consumption, surprise items and so on).7. Set aside the top portion of the game area for better status display (with larger text size anddifferent colors)8. Set a time limit; player must finish the game within the time limit9. Add prompt for a new gameFurther challenges: After you Submit your assignment, leave the program alone and wait until the end ofthe school year, around end July, then start the development. You will see the value of refactoring anddecomposition. Share me your experiences on your development.NOTE: Please DO NOT IMPLEMENT ANY OF THESE FEATURES with your assignment, do itseparately. No extra credit will be given Remember to show your game objectives, or include a readme.txt file Share your program to me by email if you want If you come up with other ideas share them with me as well Enjoy programming请加QQ:99515681 或邮箱:99515681@qq.com WX:codehelp

添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导