Open ghostbody opened 9 years ago
这个作业是同时向计科和软件开放的?还有图形库不限?
---- Ye Jiaqi编写 ----
Now, we are going to do a small project named a small plane game.
We need to know what roles at the game and the rules as well. The question is what rules we need.
In this project, we are going to build the small plane game. We have the following roles:
#ifndef GAME_H
#define GAME_H
typedef struct point {
int x;
int y;
} point;
typedef enum objects {BLANK = 0, PLANE = 1, OBSTACLE = 2} OBJ;
typedef enum operations {UP = 0, DOWN = 1, LEFT = 2, RIGHT = 3} OP;
#define GAME_ROW 2
#define GAME_COL 16
typedef struct gamePane {
// the game pane, 0 for blank, 1 for plane and 2 for obstacle
OBJ pane[GAME_ROW][GAME_COL];
point cursor;
int gameOver;
} gamePane;
typedef struct plane {
point position;
} plane;
typedef struct obstacle {
point position;
} obstacle;
// function list
void init(gamePane * thePane, plane * thePlane, obstacle * theObstacle1, obstacle * theObstacle2);
void setCursor(gamePane * thePane, const int x, const int y);
void setplane(gamePane * thePane, plane * plane);
void setobstacle(gamePane * thePane, obstacle * obstacle);
void removeOBJ(gamePane * thePane, const point p);
void gameOver();
void printPane(const gamePane thePane);
void movePlane(gamePane * thePane, plane * thePlane, OP op);
void moveObstacle(gamePane * thePane, obstacle * theObstacle);
#endif // GAME_H
void init(gamePane * thePane, plane * thePlane, obstacle * theObstacle1, obstacle * theObstacle2) {
thePlane->position.x = 0;
thePlane->position.y = 0;
theObstacle1->position.x = 0;
theObstacle1->position.y = GAME_COL-1;
theObstacle2->position.x = 1;
theObstacle2->position.y = GAME_COL-3;
int i, j;
for(i = 0; i < GAME_ROW; i++) {
for(j = 0; j < GAME_COL; j++) {
thePane->pane[i][j] = BLANK;
}
}
setplane(thePane, thePlane);
setobstacle(thePane, theObstacle1);
setobstacle(thePane, theObstacle2);
thePane->gameOver = 0;
thePane->cursor.x = 0;
thePane->cursor.y = 0;
}
// basic operation for game pane
void setCursor(gamePane * thePane, const int x, const int y) {
thePane->cursor.x = x;
thePane->cursor.y = y;
}
void setplane(gamePane * thePane, plane * plane) {
if(thePane->pane[plane->position.x][plane->position.y] == OBSTACLE) {
thePane->gameOver = 1;
gameOver();
return;
}
thePane->pane[plane->position.x][plane->position.y] = PLANE;
}
void setobstacle(gamePane * thePane, obstacle * obstacle) {
if(thePane->pane[obstacle->position.x][obstacle->position.y] == PLANE) {
thePane->gameOver = 1;
gameOver();
return;
}
thePane->pane[obstacle->position.x][obstacle->position.y] = OBSTACLE;
}
void removeOBJ(gamePane * thePane, const point p) {
thePane->pane[p.x][p.y] = BLANK;
}
void gameOver() {
printf("GameOver\n");
}
void printPane(const gamePane thePane) {
int i, j;
for(i = 0; i < GAME_ROW; i++) {
for(j = 0; j < GAME_COL; j++) {
printf("%d", thePane.pane[i][j]);
}
printf("\n\n");
}
}
// operation for plane
void movePlane(gamePane * thePane, plane * thePlane, OP op) {
removeOBJ(thePane, thePlane->position);
switch(op) {
case 0 :
if(thePlane->position.x > 0) {
thePlane->position.x--;
}
break;
case 1 :
if(thePlane->position.x < GAME_ROW - 1) {
thePlane->position.x++;
}
break;
case 2:
if(thePlane->position.y > 0) {
thePlane->position.y--;
}
break;
case 3:
if(thePlane->position.y < GAME_COL - 1) {
thePlane->position.y++;
}
break;
}
setplane(thePane, thePlane);
}
//operations for obstacle
void moveObstacle(gamePane * thePane, obstacle * theObstacle) {
removeOBJ(thePane, theObstacle->position);
if(theObstacle->position.y <= 0) {
theObstacle->position.y = GAME_COL - 1;
}
theObstacle->position.y--;
setobstacle(thePane, theObstacle);
}
You do not need to write this part to your report. Please use markdown to write your report.
As you play the game, the interface of the game is very ugly. And also the game is not a game at all. Your job is to modify the game using your idea.
Some advice:
(55pts) Your personal runable game. (25pts) Your Document about your game elucidatio. And your algorithm to get to your idea game. (20pts) The Style of your source code. Besides google style check, you should have good indent in the source code and you are supposed to write good comments(充分的代码注释) for you game.
Notice that, you should upload you game project to your github repository and write the documentation using markdown and named it "Readme.md".
You will get bonus in the final grade.
just send me your github address.
2015 12.15 18:00
Reply to this email directly or view it on GitHub: https://github.com/wujr5/c-and-cpp-language-learning/issues/31
@Icenowy 对软件班的,计科班的还没出。
哦。属于加分作业?
---- Ye Jiaqi编写 ----
@Icenowy 对软件班的,计科班的还没出。
Reply to this email directly or view it on GitHub: https://github.com/wujr5/c-and-cpp-language-learning/issues/31#issuecomment-159147620
@Icenowy 是
Description
Now, we are going to do a small project named a small plane game.
Requirements
Let's build a game!
We need to know what roles at the game and the rules as well. The question is what rules we need.
In this project, we are going to build the small plane game. We have the following roles:
Actions:
Game Structure Code
Game Source Code
Assignment 0
You do not need to write this part to your report.
Assignment 1
As you play the game, the interface of the game is very ugly. And also the game is not a game at all. Your job is to modify the game using your idea.
Some advice:
Grade
(55pts) Your personal runable game. (25pts) Your Document about your game elucidatio. And your algorithm to get to your idea game. (20pts) The Style of your source code. Besides google style check, you should have good indent in the source code and you are supposed to write good comments(充分的代码注释) for you game.
Notice that, you should upload you game project to your github repository and write the documentation using markdown and named it "Readme.md".
You will get bonus in the final grade.
Submit
just send me your github address.
Deadline
2015 12.15 18:00