首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
讲解R语言编程|讲解SPSS|辅导Web开发|讲解留学生Prolog
项目预算:
开发周期:
发布时间:
要求地区:
Snake – 2021
OVERVIEW
In this assignment, you are going to design and develop a Snake game. The game is composed of 3 objects: a snake, a monster and food items represented by a set of numbers from 1 to 9. In the figure shown above, the snake is represented by a sequence of squares where its head and its body are displayed in red and black colors respectively, while the monster by a purple square. The numbers are food 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, left and right), trying to consume all the food items while avoiding head-on collision with the monster. As each food item is consumed, the snake grows with its body lengthened in size equal to the value of the number being passed. While directing the movement of the snake you should avoid contact with the monster. Furthermore the monster is also programmed to be motioned in the direction towards the head of the snake at a variable speed.
The following screens show the first display of the game (left) and the start of the game (right) after a mouse click:
The following screens show the first display of the game (left) and the start of the game (right) after a mouse click:
The following screen shows the ending of the game where the snake collided head-on with the monster and where some food items left unconsumed:
SCOPE
• Design the snake game using the standard module “turtle”, including the following components:
1.Game Area (status and motion area)
2.A Snake
3.A Monster
4.Food Items
5.Game Status
6.Controls
7.Motion
• Game Area
1.The game area is composed of an upper area for statuses and a motion area where the snake and monster are moved around, surrounded by a fixed margin along the four sides, 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 around
2.Draw a border for both the status area and motion area.
• Food Items
a. Represented as numbers from 1 to 9, displayed within the motion area in random
locations. These numbers will be kept visible all time until they are consumed by the. snake. When the head of the snake crosses one of these numbers, the number being crossed is considered consumed and it will be removed from the game area permanently. So, any one food item can be consumed once.
• Snake
1.The snake is composed of a head with a tail which extends as it consumes any food
items.
2.Use only simple, built-in shape “square” for both head and tail, default size.
3. 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.
4.The tail extends as the snake moves, not at the point when the food item being consumed; in other words, at the moment the snake crosses a food item, the snake doesn’t change in size; as the snake moves the tail extends in the direction of the movement as if the end of the tail sticks onto the screen. The tail extension ends when the length of the snake has grown in size equal to the value of the number being crossed. The following figure shows the sequence of moves of the snake crossing a food item.
5.As the tail is being extended, the movement of the snake will slow down. See “Timer” below.
6.At the start of the game, the length of the tail is set to 5. One square shape counts as one unit length, so the tail will be composed of 5 square shapes when fully extended.
• Monster
1.A fixed size object to be programmed to move towards the snake, trying to make a
head-on collision.
2.On startup, place the monster on a random position with a fair distance from the snake.
3.The monster should move at a random rate, a rate that is slightly faster or slower than
that of the snake. See “Timer” below.
4.Use only simple, built-in shape “square” for the monster, default size.
5.Use a different color such as purple.
• Game status
1.Show the motion of the snake (Left, Right, Up, Down, Paused), in other words, the last
motion key pressed (including the space bar), regardless of whether the snake is in
motion or being blocked.
2.Show the total count of body contact of the snake with the monster. The count should
be based on the motion of the monster timer. Each time the monster is re-positioned, it
should then check if it overlaps with any part of the snake.
3.Keep track of the total elapsed game time in seconds. The time counter starts as soon
as the game starts and will stop only when game is over. In other words, the counter will not be stopped when the snake is being paused.
• Motion via Timer
1.“Timer” controls the frequency that a specific event to take place at a regular interval, in
this case the event is the movement of either the snake or the monster.
2.Use separate timers to manually refresh the movement of both snake and the monster
i. Turn off the built-in automatic screen refresh c. Keep the timer rate no faster than 0.2 second.
4.On each timer event, always advance the snake or the monster in a distance equivalent
to the length of the turtle shape (square). If the square’s dimension is 20x20 (pixels),
then your logic should advance the turtle object 20 pixels at a time.
5.Both snake and monster move in four directions, left, right, up or down, NOT diagonally.
6.Design the timers in such a way:
i.the monster should move in a random time range slightly above or lower than that 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 by increasing its timer rate until its tail is fully extended, that is, the snake will motion slower while the tail being extended
iii.furthermore, you don’t want the snake to move too fast that the monster will never catch up with the snake, or vice versa. That is, you don’t want the monster moves so quickly that it always catch the snake before it has a chance to consume all the food items.
• Controls
1.Use the four arrow keys (Up, Down, Left, Right) to maneuver the snake in Up, Down,
Left and Right motion respectively.
2.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 a
different arrow key is pressed.
3.Use “Space Bar” to toggle (pause and un-pause) snake motion (note: monster never
pause). 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 of the last arrow key pressed. Furthermore, while paused, pressing any of the four arrow keys will un-pause the snake motion and move in the direction of the arrow key being pressed.
4.Snake cannot move beyond the motion area; when the head of the snake is moved against any of the 4 sides, the snake will be stopped and it will remain blocked until its heading is changed away from the edges.
5.Snake can cross its body, left to right, up to down or vice versa.
• Game Termination
a. The game ends when the snake consumes all the food items and its body is fully
extended, in this case “Winner” or the monster caught the snake, in this case “Game Over”.
• Game Startup
a. On startup, show (1) the game area with a brief introduction to describe the game
objective and control, (2) the snake (in red) positioned at center and (3) the monster (purple) at a random position far enough from the snake.
;
b. User mouse-click anywhere on the screen to start the game, all the food items will be shown subsequently, user then moves the snake around using the 4 arrow keys
• Coding Styles
1.Ensure that your program follows the proper layout structure as discussed in class.
2.You might declare many global variables used for this assignment, ensure that a
consistent 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.
STARTUP OPTIONS Not applicable
SKILLS
In 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 decomposition
TIPS & HINTS
Follow the layout structure as mentioned in class (import, declarations, functions, main process).
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 the
Turtle(). 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) to
remove 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 https://docs.python.org/3/library/turtle.html for more information on Turtle Graphics.
SAMPLE OUTPUT Refer to the Overview session.
MARKING CRITERIA
Coding Styles – overall program structure including layout, comments, white spaces, naming convention, 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 your
program and the player.
Readability counts – programs that are well structured and easy-to-follow using functions to
breakdown complex problems into smaller cleaner generalized functions are preferred over a function embracing a complex logic with nested conditions and sub-functions! In other words, a design with clean architecture with high readability is the predilection for the course objectives over 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.
DUE DATE th
April25 ,2021,11:59:59PM
OTHER IDEAS:
If you feel that you have the passion for programming, here’s list of other ideas that you could further
enhance your program by refactoring your existing logic.
1.Implement multiple monsters; start with one monster initially and then another one on every fixed time interval, up to some numbers, say 3 (be cautious not to have too many monsters suddenly). You need to ensure that use a different timer logic to for each monster chasing after the 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), not
too much a shift, yet enough to confuse the player
4.Do not allow the snake to cross its body; block its movement
5.Implement surprise items; you can have reward or penalty items on screen for snake to
consume:
1.Reward: Increase game time limit (20 seconds)
2.Reward: Freeze motion of all monsters for a few seconds (10 seconds)
3.Penalty: generate another food item
4.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 and
different colors)
8.Set a time limit; player must finish the game within the time limit
9.Add prompt for a new game
Further challenges: After you submit your assignment, leave the program alone and wait until the end of the school year, around end July, then start the development. You will see the value of refactoring and decomposition. Share me your experiences on your development.
NOTE:
Please DO NOT IMPLEMENT ANY OF THESE FEATURES with your assignment, do it separately.
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
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代做ceng0013 design of a pro...
2024-11-13
代做mech4880 refrigeration a...
2024-11-13
代做mcd1350: media studies a...
2024-11-13
代写fint b338f (autumn 2024)...
2024-11-13
代做engd3000 design of tunab...
2024-11-13
代做n1611 financial economet...
2024-11-13
代做econ 2331: economic and ...
2024-11-13
代做cs770/870 assignment 8代...
2024-11-13
代写amath 481/581 autumn qua...
2024-11-13
代做ccc8013 the process of s...
2024-11-13
代写csit040 – modern comput...
2024-11-13
代写econ 2070: introduc2on t...
2024-11-13
代写cct260, project 2 person...
2024-11-13
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!