CAB202 Assignment 1

CAB202 Assignment 1, Semester 2 2019
Assessment Weight: 30%
Context
You are tasked with bringing to life the classic characters of Tom and Jerry in a terminal based
game. Tom is a cat with the simple agenda of catching the mouse, Jerry, running rampant in his
house. Tom runs around the room Jerry is in, dropping mousetraps periodically, and constantly
changing his direction to move toward Jerry. Jerry just wants cheese, and is faster than Tom, but
after he has consumed enough cheese, and taken the chase to the second room of the day, he likes to
have a bit of fun by introducing some weapons of his own to direct at Tom.
Level 1 Specifications
Task 1 - File IO, String Parsing and General Game Initialisation (6 Marks)
a) File IO: Initialisation from Input Maps
The game should expect a text file as a command line parameter. The general format of this

代写CAB202留学生作业、代做C/C++编程语言作业、代写c/c++实验作业
text file is given in the appendix. You must be able to parse text files of any length, with any
number of walls, traps and treasure encoded. You may assume the file will only ever contain
one set of coordinates each for Tom and Jerry.
Please note: The coordinates given in the text file are all relative to the screen size. You will
need to convert these coordinates to screen coordinates when parsing the text file. Your
game needs to adapt to the current terminal size, which could be any size greater than
80x24 (80 columns, 24 rows).
b) Other Game Setup: Status Bar
A status bar should be drawn across the top 3 rows of the screen, the first row (screen row 0)
should display in order;
i. Your student number
ii. The current game score (initially 0),
iii. The current lives of the active player (initially 5),
iv. The active player (‘J’ for Jerry, ‘T’ for Tom, Default: ‘J’),
v. The time elapsed since game start in minutes and seconds format MM:SS (initially
00:00).
The third row (screen row 2), should display in order;
vi. The number of cheese currently on the screen (initially 0),
vii. The number of mousetraps currently on the screen (initially 0),
viii. The number of weapons currently on the screen (initially 0, see level 2 for details).
Task 2 – Tom and Jerry Movement (5 Marks)
a) Jerry: User Controlled Movement
By default, the user should be able to control Jerry using the ‘w’, ‘a’, ‘s’, ‘d’ keys for up,
left, down and right movement respectively. Jerry should move one pixel for each keypress,
in the corresponding direction. Players should not be able to cross the status bar (the top 3
rows of the screen).
b) Pause Mode
The game should be able to be paused by pressing the ‘p’ key. In pause mode, all automatic
game dynamics should be frozen including the timer, but the user should still be able to
move the player, collect treasure and lose lives. The game should NOT start in pause
mode.
c) Tom: Automatic Movement
Tom aims to find and catch Jerry, while dropping mouse traps randomly throughout his
journey. Tom changes speed and direction randomly whenever he collides with a wall.
Marks will be also be awarded for this criterion if advanced movement is correctly
implemented as specified in 5b(ii). Players should never cross the status bar (the top 3 rows
of the screen).
d) Basic Collision Detection
Tom and Jerry can’t walk through walls, nor can they leave the bounds of the room they’re
currently in (they must be confined within the borders of the screen and visible). You must
implement collision detection such that Jerry will not move any further if the next step will
cross a wall, screen border or the status bar. Tom should also not cross walls, screen
borders, or the status bar, but he must automatically change speed and direction upon
collision with any of these game elements. Collision detection must be present between all
implemented elements of Tom, Jerry, Walls, Cheese, Traps, Weapons, Borders and the
Status Bar. Behaviours exhibited upon collision are described in the relevant subsections of
Task 3 and 4.
Task 3 – Traps and Treasure (5 Marks)
a) Cheese Appearance
After the start of gameplay, cheese should appear in random locations at 2 second intervals
until a maximum of 5 cheese are displayed on the screen. Cheese should only appear in clear
locations on the screen; there should be no overlap with existing game elements. Cheese
should never appear in the status bar (the top 3 rows of the screen).
b) Cheese Interactions
Jerry is happiest when full of cheese. He will eat any cheese he crosses, without limit, but is
happy to start exploring the next room once he has consumed 5 pieces of cheese in the
current room. Each cheese he eats adds 1 to his score. The cheese will keep appearing at 2
second intervals after Jerry is full, but the door will unlock as soon as 5 cheese have been
consumed (5 points accrued). Jerry does not enter the next room until he moves to the door,
but the door must appear in the room and remain visible once 5 points have been accrued.
Tom can collide with cheese and continue on his path without effect.
c) Mousetrap Appearance and Interactions
Tom will randomly drop mousetraps as he moves around the screen, at 3 second intervals.
He only has 5 traps, so cannot lay more than 5 in the room, but he does automatically regain
his traps once Jerry has been caught by them. See life source management (3f) for Jerry
collision details. Mousetraps should only appear in clear locations on the screen; there
should be no overlap with existing game elements. Tom can collide with mousetraps and
continue on his path without effect. Traps should never appear in the status bar (the top 3
rows of the screen).
d) Door Appearance: Advance or Win
Once Jerry has had sufficient cheese (5 pieces), a door must appear somewhere on the
screen. This door should be denoted by an ‘X’ character (capital X), and should not appear
anywhere that overlaps any current elements of the room (i.e. it must appear in a free space,
where there is no overlap with cheese, walls, characters, traps, status bar, etc.). When Jerry
collides with this door, he should advance to the next level in the second room (if level 2 has
been implemented), or he should win the game and the game over screen should appear.
Door appearance is based purely on cheese consumption, not points accrued, in the current
room.
e) Life Source Management
Jerry loses a life each time he collides with a mousetrap, and each time he is caught by Tom.
If Tom catches Jerry, in addition to losing a life, Tom and Jerry both reset to their initial
locations. All other elements of the game remain the same. If the player’s lives reach 0 at
any point during gameplay, the game over screen should appear.
f) Game Over Screen
If the player wins or loses the game, a game over screen should appear and the user should
be offered the option to either Restart or Quit. Restart must reset all game play states to the
initial state as read from the text file. Quit must return immediately to the terminal.
Level 2 Specifications
PRE-REQUISITES: A decent implementation of level 1 must be demonstrated before marks can be
achieved for level 2. You must have implemented the ability to complete level 1 and advance to level
2 through the door, as described in the level 1 specifications. You must also implement a shortcut
where the user is able to cycle through levels by pressing the ‘l’ key to qualify for level 2 marks.
Task 4 – Infinite Levels and Weaponisation (7 marks)
a) Additional Text File Argument
To implement level 2, you must pass at least one additional text file argument via command
line. This second argument will be read to initialise level 2. All further task 4 and 5
behaviours should be demonstrated in level 2 (and further levels if implemented).
b) Jerry’s Turn: Weapons
Give Jerry the ability to fire a weapon, such as a firework, by pressing the ‘f’ key. This
firework should always shoot toward Tom, and for full marks, your firework should
constantly update its angle toward Tom’s current location as he moves around. If the weapon
collides with a wall or goes off the screen before reaching Tom, the firework must disappear
and the number of weapons currently on the screen should be updated accordingly. If the
firework hits Tom, it should disappear and his location should reset to the initial position
given in the text file for the current level. The firework can pass cheese and mousetraps
without collision. Jerry gains 1 point for each firework that hits Tom. Weapons should never
cross the status bar (top 3 rows of the screen).
c) Infinite Levels
The game should accept an arbitrary number of text files as command line arguments. Each
text file provides the structure for a new level of the game. Each file should provide a
different room structure, and should be accessible as with all levels; through a door which
appears after 5 cheese have been consumed in the current level. The overall total points
should still reflect points accumulated across all levels, including points accrued through
weapons. 10 text files have been provided for you to use during testing, and you are
encouraged to create more of your own by carefully following the same structure as the
example files. To achieve full marks for this feature, you must also have implemented
correct playability with arbitrary walls.
Task 5 – Demonstrate Mastery (7 marks)
a) Arbitrary Walls
Once Tom and Jerry enter the second room of the game, we find that the walls are less
orderly. Many of them are diagonal, but both Tom and Jerry will continue to exhibit the
same behaviours with these new walls. This will involve writing an updated, creative
solution to collision detection that will work for walls of any diagonal or straight
configuration.
b) Player Enhancement and Fluidity
The user should be able to press the ‘z’ key to switch character, and players should have
enhanced abilities. The character which is not currently in play should demonstrate an
appropriate movement. This movement should be in keeping with the theme that Tom seeks
Jerry, and Jerry attempts to evade Tom while collecting cheese. This will involve;
i. Implementing an intelligent ‘evasion’ movement mode for automated Jerry to avoid
user-controlled Tom while ‘seeking’ cheese,
ii. Implementing a ‘seeking’ movement mode for automated Tom to seek usercontrolled
Jerry,
iii. Allowing manual placement of cheese to lure automated Jerry closer to usercontrolled
Tom by pressing the ‘c’ key (up to a maximum of 5 on screen at once),
iv. Allowing manual placement of mousetraps at the current location of user-controlled
Tom by pressing the ‘m’ key (up to a maximum of 5 on screen at once),
v. A lives system for Tom (initially 5 lives, decrements by 1 per firework hit),
vi. Automation of Jerry’s weapons (1 firework should fire per 5 seconds),
vii. A points system for Tom, such that he gains;
1 point each time Jerry gets caught by a mousetrap,
5 points if he catches Jerry.
viii. The ability to advance to the next room after Tom has accrued 5 points in the current
room. This should still adhere to the door specifications given in specification 3d.
c) Other Approved Extension
Through consultation with your tutor, you may also demonstrate mastery through an
approved equivalent alternative approach.
General Expectations – Penalties Up To 5 Marks Apply If Violated
A statement of completeness is required. A penalty of 2 marks will be applied if you do not
submit a statement of completeness, or include misleading or falsated statements.
Penalties up to 3 marks will be applied if the code is not implemented with an acceptable
level of comprehension and maintainability, or exhibits any general defects or undesirable
behaviour not otherwise covered in this document. This includes but is not limited to such
things as:
Errors in object motion, such as objects jumping more than one character position per
frame;
Objects moving outside their permitted area;
Failure to clear the screen appropriately between updates;
Collisions involving invisible or non-existent objects;
Disturbing or flashing display;
Sluggish response times, excessively fast response times, or other performance defects
which render the simulation difficult to operate according to specification.
? Gratuitous errors in program structure and organisation, including but not limited to:
inappropriate use of recursion; use of inappropriate data structures such as linked lists or
binary search trees; using #include to insert the contents of source files rather than
header files; uploading of multiple versions of the same source file.
General readability and maintainability errors, including but not limited to: functions
exceeding 25 executable C language instructions, where comma separated expressions
with side effects will be classified as separate executable instructions; functions which
are substantially identical to any other function; limited or no attempt to implement
suitable documentation comments; failing to adhere to professional and consistent
formatting; excessive use of global variables.
Appendix – Text File Example and Explanation
You will be provided with some example text files, but will need to be able to parse any text file of
the same general structure. There are three different characters which will be used as identifiers at
the start of each line, these being ‘W’, ‘T’, and ‘J’. These characters are indicators as to what the
remaining digits on the line are representative of, where;
‘W’ indicates the line will include the relative end point coordinates (x1, y1) and (x2,y1) for
a wall, formatted as follows;
W x1 y1 x2 y2
‘T’ indicates the line will include the relative starting coordinates (x, y) for Tom, formatted
as follows;
T x y
‘J’ indicates the line will include the relative starting coordinates (x, y) for Jerry, formatted
as follows;
J x y
All coordinates will be presented relative to the screen size, meaning they will all range from 0 to 1.
You must interpret these coordinates by multiplying by (screen_width()-1) or (screen_height()-1)
accordingly.

因为专业,所以值得信赖。如有需要,请加QQ:99515681 或邮箱:[email protected]

微信:codehelp

原文地址:https://www.cnblogs.com/comp163/p/11443386.html

时间: 2024-11-07 20:41:56

CAB202 Assignment 1的相关文章

Algorithm Part I:Programming Assignment(2)

问题描述: Programming Assignment 2: Randomized Queues and Deques Write a generic data type for a deque and a randomized queue. The goal of this assignment is to implement elementary data structures using arrays and linked lists, and to introduce you to g

RailsCast26 Hackers Love Mass Assignment rails中按params创建、更新model时存在的安全隐患

Mass assignment是rails中常用的将表单数据存储起来的一种方式.不幸的是,它的简洁性成了黑客攻击的目标.下面将解释为什么及如何解决. 上述表单为一个简单的注册表单.当用户填入name,点击提交时,一个新用户被创建.用户模型被如下定义: ruby create_table :users do |t| t.string :name t.boolean :admin, :default => false, :null => false end 当用户点击提交时,如下的action被执

hdu4781 Assignment For Princess(构造)

题目链接:hdu4781 Assignment For Princess 题意:n个点m条边,每条有向边的权值分别是1,2,3…m,一个点能到达任意一个点,没有重边和自环,没有任何两条边的权值相同,任意一个有向环的权值和必须是3的倍数,现在需要把这个图输出来. 题解:注意到题目给出的范围m >= n+3,所以一定是可以构造出一个1~n的回路使得权值和为3的倍数的,可以让前n-1条边权值为1~n-1,第n条边(n->1)可以为n, n+1, n+2从而满足题意,后面再连任意两条不相邻的边时,边权

<Effective C++>读书笔记--Ctors、Dtors and Assignment Operators

<Item 5> Know what functions C++ silently writes and calls 1.If you don't declare them yourself, compilers will declare their own versions of a copy constructor, a copy assignment operator, and a destructor. Furthermore, if you declare no constructo

POJ 3189 Steady Cow Assignment(最大流)

POJ 3189 Steady Cow Assignment 题目链接 题意:一些牛,每个牛心目中都有一个牛棚排名,然后给定每个牛棚容量,要求分配这些牛给牛棚,使得所有牛对牛棚的排名差距尽量小 思路:这种题的标准解法都是二分一个差值,枚举下界确定上界,然后建图判断,这题就利用最大流进行判断,值得一提的是dinic的效率加了减枝还是是卡着时间过的,这题理论上用sap或者二分图多重匹配会更好 代码: #include <cstdio> #include <cstring> #inclu

hdu 1845 Jimmy’s Assignment (二分图)

Jimmy's Assignment Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others) Total Submission(s): 896    Accepted Submission(s): 379 Problem Description Jimmy is studying Advanced Graph Algorithms at his university. His most

FreeRTOS的application assignment

Please follow the steps precisely in order to complete the objectives of the assignment. If you use the C++ FreeRTOS framework, it should make the assignment significantly easy. Create a producer task that takes 1 light sensor value every 1ms. Collec

用户无法进入SDSF,报NO GROUP ASSIGNMENT错误

注:命令行小写部分表出需要根据自己的情况改变!! a)激活SDSF资源类 SETROPTS CLASSACT(SDSF) b)查看SDSF资源类的PROFILE RLIST SDSF * c)如果不存在GROUP.ISFUSER.servername的PROFILE,则需要定义, RDEFINE SDSF (GROUP.ISFUSER.servername) OWNER(userid or group name) UACC(READ) 这样,所有用户都可以有读取权限,就都可以访问SDSF了 附1

遇到local variable &#39;e&#39; referenced before assignment这样的问题应该如何解决

问题:程序报错:local variable 'e' referenced before assignment 解决:遇到这样的问题,说明你在声明变量e之前就已经对其进行了调用,定位到错误的地方,对变量进行重新的声明 通常这样的问题对于python的程序员来说都是因为习惯了python2的语法,转移到python3中时,出现的错误.在Python3中,异常对象无法在异常块作用域外访问.(原因是在垃圾收集器运行且从内存中清理引用之前会在内存栈帧中保存一个引用周期)通常参考下面这个例子来做异常处理: