首页 >
> 详细

Computing Science CMPT 361 Fall 2019

Assignment #1 (20 marks)

Due October 9, Wednesday, at 11:59 pm.

Problem 1 (16 marks): Tetris meets Falling Fruits

Using OpenGL, you will implement a simple interactive game that combines some features

from Tetris and some from Falling Fruits. Any visual flair that you wish to add to the

appearance of your game will be judged by the grader and may be credited at their discretion.

(The Falling Fruits game is similar to Tetris. A web search will find you several versions of it.)

Your game window consists of a 20x10 square grid of appropriate size, e.g., so that the window

will fit in the screen comfortably. Different fruits are represented by squares of different colors.

You program should have five different fruits with color coding specified in figure (b). Each

time, four fruits (chosen randomly with repetitions from the five types of fruit) fall from the

top of the screen. As indicated in the figure (c), these fruits are arranged in a I, S, L, or T

shaped Tetris tile, which has a pivot of rotation indicated by a black dot (always on the fruit

indicated by the letter c). The T shape is not pictured but has squares (0,0), (-1, 0), (1, 0), and

(0, -1) with a pivot center at (0,0). Also, the L and S shapes should come in left- and righthanded

versions (left-hand versions are shown—flip horizontally to get the right-hand

versions). We will not use the 2x2 square Tetris tile.

Grape Apple Banana Pear Orange

Purple Red Yellow Green Orange

(b) Use squares of different colors to represent

different fruits. This table shows the color coding of

fruits.

(a) The screen of the falling fruit game.

Computing Science CMPT 361 Fall 2019

(c) The first column shows the “base” I, S, and L shapes; the other columns show the shapes when

rotated.

You are advised to complete this problem in several steps:

(a) [4 marks] Tile and grid rendering and tile downward movement

Set up the game window with grid lines. At each time, randomly select a Tetris tile consisting

of four fruits and drop it from the top of the game window. The starting position and

orientation are chosen randomly. You can control the speed of its movement to suit your

game playing. Movement of the tiles will be aligned with the grids and at uniform speed. For

this step, the tiles can drop straight through the bottom. After one tile disappears, a new tile

is dropped.

(b) [2 marks] Stack-up

In this step, the tiles will stack up on top of each other and the bottom of the game window

will offer ground support. When any square of a falling tile is stopped, the entire tile stops

(this is the Tetris rule for stacking, not the Falling Fruits one).

(c) [6 marks] Key stroke interaction and tile movements

The four arrow keys will be used to move the dropping fruit array. A pressing of the “up” key

rotates the tile counterclockwise about its pivot, 90° at a time. The “left” and “right” key

presses result in lateral movements of the array, one grid square at a time. The “down” key

accelerates the downward movement. Pressing any of the arrow keys should not slow the

downward movement of a tile.

At no time should you allow a tile to collide with any existing tiles or the border of the game

window.

(d) [4 marks] Additional game logic

1) When three of the same fruit are consecutive in a row, column, or diagonal, they will be

removed and the fruit directly above them will be moved down one row for each tile removed.

2) When a row is completely filled, it is removed and the tiles above it will be moved one row

down.

Game terminates when a new tile piece cannot be fit within the game window. Press ‘q’ to

quit and ‘r’ to restart.

Computing Science CMPT 361 Fall 2019

Instructor: Tom Shermer Simon Fraser University

Note that the above steps build on top of each other, in order. You need not submit individual

programs to correspond to these steps. If you can implement all the required parts, a single,

complete program is sufficient.

Although the marks have all been alloted for functionality above, the grader may also deduct

marks for sloppy or confusing code, or for failure to follow laboratory procedure (e.g. not

handing in the files specified).

If you’d like to extend this mini-project, here are some suggestions:

• Add extra keyboard commands, such as ‘p’ to toggle ‘pause mode’.

• Make each fruit have its own shape. This could be a simple iconic shape chosen from

a 3x3 or 4x4 subgrid, or a complex shape derived from an image file. Make the shapes

as visually distinct as possible.

• Add a fancy border around the playing grid, possibly with a name for the game written

above or below.

• Implement a method of scoring based on the fruits eliminated. Display the score.

• Keep a list of high scores that is displayed when the game finishes.

• Have the game speed up as the score gets higher.

• etc.

You may earn full marks without implementing any of these or other extensions.

Problem 2 (4 marks): Rigid-body transformations

Place your answers to the following, along with your work, in a pdf file named matrix.pdf.

Suppose you are given a 3D transformation Φ specified by a matrix M of the following form.

where the upper 3 by 3 submatrix 𝑅 of 𝑀 is orthonormal, i.e., 𝑅𝑇 = 𝑅−1.

1. [1 mark] What is the inverse of M? Note that you should not use brute force or a

package such as Maple or Matlab to answer this question.

2. [1 mark] Let V = P2 - P1 be a vector in 3-dimensional real (Euclidean) space, where P1

and P2 are points in that space. Is it the case that Φ is linear in 3D? In other words,

does Φ(P2 - P1) = Φ(P2) - Φ(P1) ?

3. [2 marks] Prove that the transformation Φ preserves lengths, angles, and the area of

triangles in 3D.

Computing Science CMPT 361 Fall 2019

Submission: In a zip file, include:

• All source code,

• a Makefile to make the executable called FruitTetris (the make command should be

simply “make”),

• a README file that documents any steps not completed, additional features, and any

extra instructions for your TA,

• and your matrix.pdf

and submit this zip file via CourSys.

联系我们

- QQ：99515681
- 邮箱：99515681@qq.com
- 工作时间：8:00-23:00
- 微信：codinghelp

- 4Cosc001w作业代做、Python程序语言作业调试、Python课程作 2019-11-20
- 代写csc 230作业、代做ascii留学生作业、Python，Java程序 2019-11-20
- Cmpt 361作业代写、代做system留学生作业、Java，C++编程语 2019-11-20
- 代做cs5783留学生作业、代写machine Learning作业、代写c 2019-11-20
- B365留学生作业代做、代写iris Data作业、代做r程序语言作业、代写 2019-11-20
- Inft 3033作业代做、代写c/C++编程语言作业、代做c++课程设计作 2019-11-20
- Cs610-101作业代写、Programming课程作业代做、C/C++, 2019-11-20
- Econ 385作业代做、R程序设计作业代写、代做r课程设计作业、Ols留学 2019-11-20
- Engg1330作业代做、代写programming作业、代写java编程语 2019-11-20
- 代写csv File作业、Dataset留学生作业代做、代写java，C++ 2019-11-20
- Web Scraping作业代做、代写media Website作业、Web 2019-11-19
- 代写module留学生作业、代写java课程设计作业、Java程序语言作业调 2019-11-19
- Cs 344留学生作业代做、C++编程作业调试、C++课程设计作业代写、代做 2019-11-19
- 代做econ 493作业、Data留学生作业代写、代做r实验作业、R编程设计 2019-11-19
- 代写cmpt 361作业、代做system留学生作业、代做python，C+ 2019-11-19
- Isa 414作业代写、R程序语言作业调试、R课程设计作业代做、代写canv 2019-11-19
- Mat 4378作业代做、代写categorical Data作业、代做r编 2019-11-19
- Stat 429作业代做、代写mathematics课程作业、代做r编程语言 2019-11-18
- 代做431 Quiz 2作业、R编程设计作业调试、R语言作业代写、代做dat 2019-11-18
- 代写mt5761留学生作业、代做statistical Modelling作 2019-11-18