CS案例:H5 Bug Buster game program Summer 201
当前位置:以往案例 > >CS案例:H5 Bug Buster game program Summer 201
2018-07-08

Homework 5 Bug Buster Summer 2018

Due: July 26, 6pm

In this homework, you are to design a catch-bug game program where a user tries to predict the bug position on a 4 x 4 grid.


The initial position of the bug is fixed at (3, 3). The bug may move to any cell surrounding it, bounded by the 4 x 4 grid. Users have 5 chances to catch the bug, or the bug wins. Whenever the bug wins or is killed, the program changes the bug picture to show the result and ends the game.


During the game, the program shows the remaining moves and the user score. The user score starts from 100, and every unsuccessful catch reduces it by 20. Your program should also show meaningful messages to let users know what they should do next.


Three bug pictures are given, with filenames (“bug.gif”, “bug_win.gif”, and “bug_die.gif”). We have also given you a simple example code showing the basic program structure.


Here are some sample game pictures.


1. Users capture the bug in 4 moves
image.png

Fig. 1: Initial displayFig. Fig. 2: Show user's click




image.png image.png

Fig. 3: The bug moves but still alive Fig. 4: The bug is caught


2. If it is not caught in 5 moves, the bug wins. The program shows the happy bug. The user should click it again to stop the program.

image.png

Here are possible error messages.

1) If the user click is outside of the grid, a message should ask the user to click inside again.

2) If the click is not next to the bug, an invalid message appears and the user should retry without penalty.



In this homework, you should design and use the following two functions:


def move(x, y):

# It returns a new, valid position for the bug.

# You should use “random.randint(-1,1)” to randomly move the bug on both x and y positions.

# You should check if the bug stays inside of the grid. If not, do it again.



def showClick(Win):

# It returns the position the user has just clicked.

# The cell should be highlighted briefly to let the user see where it is.

Submission:

The submission deadline is 6pm, July 26 (Thursday).

· Grading Criteria (out of 100 points):

o Programs submitted with no syntax error (10 points)

o Create an initial window with grid and messages (10 points)

o Show bug pictures correctly (20 points)

o Move bugs randomly after user’s clicks (20 points)

o Make the bug capture decision correctly (20 points)

o Show all messages and game logic correctly (20 points)


1513067809116994.png


在线提交订单