联系方式

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

您当前位置:首页 >> C/C++编程C/C++编程

日期:2018-07-26 09:39


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


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

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.

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)


版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp