CSE102 Assignment 6-A mini game for 2 players Solved

30.00 $

Category: Tags: , , , , , , ,
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: zip solution files instantly, after Payment

Securely Powered by: Secure Checkout

Description

5/5 - (1 vote)

In this assignment, you are asked to write a mini game for 2 players. The game is described below.

In this game, there are two seperate roads for the players. The player who will start first will be chosen by tossing the dice. Likewise, the players move along their way (clockwise) by tossing the dice. If a player ends up their movement on a penalty point (indicated by X) they should take 2 steps backward. Whoever ends up on (or beyond) the finish line (indicated by _) wins the game.

• • • •

The dots are used to draw a path for the players. You may use different characters such as “|” and “-”.

-> indicates the position of the player 1. -> indicates the position of the player 2. -> indicates the finish line.

-> indicates the penalty points.

Page 1 of 2

CSE102 – Spring 2022 Homework #6 How to program the game?

– – –

– – – –

– –

→ → → → → →

Before starting to code, please watch the video which shows the playing of the game.
The whole game area should be saved in a 2D array with 15 rows and 30 columns.
Each item in the game; such as the positions of the players, finish line etc. should be the elements of the array.
There should be 3 penalty points for Player 1 and 6 penalty points for Player 2. The positions of the penalty points:

o For Player 1 -> (1, 14), (7, 28) and (13, 14)

o For Player 2 -> (3, 10), (3, 18), (5, 26), (10, 26), (11, 10) and (11, 18)
The position of the finish lines should be (2,1) for Player 1 and (4,3) for Player2.
The positions of the players at the beginning are (1,1) for Player 1 and (3,3) for Player 2.
The size of the game area and the positions are constant.
When the game starts, the positions of the players will change repeatedly. The program should update their positions in the array.
According to the position of a player when they toss, the player’s position may change by its row and/or column index. Be careful at the corners of the road.
Using pointers are not allowed, use a practical way to repeat the steps.
Dice tossing should be handled by generating a random integer by using the following function.

o rand () -> returns a positive integer or 0. Do not remember that you need a random integer in a range of [1,6].

o Add srand(time(NULL)); in your main function. Otherwise the rand() function will return the same integers regardless of a rerun of the program.

o Include stdlib.h and time.h libraries to use these functions.
You can write and use your own functions for a clean coding, but the followings are necessary:

o void printMap () -> prints the game area, use the parameters you will need if any.
o int dice () -> returns a random integer in a range of [1,6]
o intstartGame()->decides(accordingtodicenumbers)andreturnsthe#oftheplayer

who will start the game.
Use the parameters you need (if any) as the inputs of the functions.
Use different colors when you print the array as shown above.
When a player steps backward because of a penalty, print this information. Using libraries other than stdio.h and the ones specified above is not allowed. Add comments to your code and hand in a .c file only.
See the attached video for a visual example of the game.

Page 2 of 2

  • assignment-6-wckc0q.zip