Computing Science CMPT 361 Spring 2019 Instructor: KangKang Yin Simon Fraser University
Programming Assignment #1 (20 marks) Due on: Friday, February 8, at 11:59 p.m.
Plagiarism is a serious academic offense: passing off someone elses work or ideas as your own in order to get a higher mark. Plagiarism is treated very seriously. The assignment you hand in must represent your own work. Submitting source code downloaded/copied from the WWW or your classmates solutions as your own is deemed cheating, and an F grade will be awarded. However, reading and studying code from the web and discussing ideas with your classmates is allowed, but you must acknowledge their help, and still do your own work. In the README file you submit with your source code, you must list all the open source code that you have studied, and all the peoples names with whom you have discussed your assignment.
Late Policy: Late submissions are possible, but they will be penalized. One day late: 10% penalty; Two days late: 20% penalty; Three days late: 40% penalty; Four days late: 60% penalty; Five days late: 80% penalty; Six or more days late: 100% penalty.
Problem 1 (20 marks): Tetris!
You are to implement a simplified version of the game Tetris as described below. Any visual flare that you wish to add to the appearance of your game will be judged by the grader and may be credited at his discretion. The game window consists of a 20 10 square grid of appropriate size, e.g., so that the window will fit in the screen comfortably. There are seven standard Tetris pieces (or tiles), as shown below, with pivot of rotation indicated by a black dot. You are advised to complete this problem in several steps.
(a) [6 marks] Tile and grid rendering and tile downward movement
Set up the game window with grid lines and randomly select Tetris tiles with distinguishing colors one at a time and drop them from the top of the game window. The starting position and orientation of the tile is chosen randomly. You can control the speed of the tile 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) [4 marks] Tile 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, as in the Tetris game you are familiar with.
(c) [6 marks] Key stroke interaction and tile movements
The four arrow keys will be used to move the tiles. A pressing of the up key rotates a tile counterclockwise about its pivot, 90 at a time. The left and right key presses result in lateral movements of a tile, one grid at a time. The down key accelerates the downward movement. At no time should you allow a tile piece to collide with any existing Tetris pieces or the border of the game window.
(d) [4 marks] Additional game logic
When the bottom row is completely filled, it is removed and the tile stack 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. Pressing any of the arrow keys should not slow down the downward movement of a tile.
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. No skeleton code is provided.
Submission: Please submit a zip file with student number and your name (i.e., 300000001_TerryFox.zip). The zip file contains an HTML, a JavaScript, and a README file. The README should acknowledge any help you have received and any discussion you have participated, and document any steps not completed, additional features, and any extra instructions for the TA to mark your assignment.
Reviews
There are no reviews yet.