首页 > > 详细

辅导data、讲解C++设计、Canvas留学生辅导、讲解c/c++编程辅导R语言程序|调试Matlab程序

Your task is to start with the Snake game shown in class and add the following features. You
must start with the file “lab03a_snake_game_features_lecture.cpp” on Canvas and add to it.
And you must use C/C++ and SDL. The features are:
(i) Snap snake movement to grid
(ii) Detect collision with snake itself
(iii) Collide message text: separate the collide wall/boundary and collide with itself cases.
- Currently in the code, we call the same function for both cases. Separate them into two cases,
and display an appropriate error text message in each case. You may put the text over the big
red square that is currently displayed.
(iv) Draw some objects (e.g. apple from “snake_parts.bmp” file on Canvas) in some grid cells
that the snake can collect. Detect collision of the snake with the object (so it can collect them).
Add score text to indicate the number of objects collected.
- You may just draw a few such objects randomly in the grid at the start.
(v) Draw the snake with the given image of snake parts (“snake_parts.bmp” file) to make the
snake look nice.
- You may separate the “snake_parts.bmp” file into smaller files for each part of the snake, or
use code to read only the parts that are needed for each part.
Grading
20% for each feature above
Submission on Canvas
Submit your files to the “Assignment 1” submission page.
Submit your cpp file(s), exe file, and bmp files for the snake images if you separated the larger
“snake_parts.bmp” file into smaller files. Make sure that your cpp file(s) can compile and run
without modification, when the appropriate snake bmp file(s) is/are placed in the same folder.
No written report is needed. However, if one or more of your features does not work or only
partially works, you should put comments in the cpp file(s) and at least explain what you tried
to do, so you may get partial marks.
Deadline is Friday, 9 October, at 5pm
Below I give answers to some common questions, and also some hints.
Snap snake movement to grid and Detect collision with snake itself:
-You can use the 2D array that's commented out in the given code, but you don't have to.
-To snap the snake, you only allow the snake to turn when it is at position of, for example, 100, 125, 150, 175, 200,
225, etc. (at multiples of 25), when it will be aligned with the given blue grid.
For the snake:
-The snake naturally extends its length, so there is no need to add length to it after eating an apple, even though
this happens in some versions of the game.
-In the snake parts bmp file, each snake part has black corners (at the outer boundary) which are okay, so you can
leave that as they are.
-You may still have to scale each part from the bmp file, if you directly draw that on top of the given blue grid.
For drawing text:
-The most recent class/lecture material has the functions for doing this.
-If you use the ttf libary, you may need to put the zlib1.dll file in the Debug folder.
-You can find this dll file in the C:\SDL210\lib\x86 folder if you originally put the ttf lib files there.
Compiling/Building your code:
-Make sure that you can compile/build your submitted code with no errors.
-If you are really worried about this, you can capture a video of your final game and submit the video file there.
-But this is not required as long as your game code compiles and works.

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!