Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Stage 1 . 2 - Validate Player Spawn Now that you got the player onto the map, lets restrict where they could spawn at .

Stage 1.2- Validate Player Spawn
Now that you got the player onto the map, lets restrict where they could spawn at. It would
make more sense if they start from the edge of the map, so now the player's starting position
will need to be error checked so that it is within the spawn boundary.
HINT The span boundary are the edge tiles of the map i.e., tiles whose row must either be
0 or
or
col
must either be
0 or
or MAX_COL -1.
must either be
Remember that array indicies start at 0.
Here is a diagram with the spawn boundary highlighted in blue. Stage 1
Stage 1.1- Spawn player
To ease you into this assignment, your first task is to spawn the player onto the map!
Currently, the provided starter code creates a 2D array of
s and initialises
them with the initialise_map() function that is included.
Your program will need to scan in the player's starting position. This will be given as a pair of
integers which denotes the row and column (in that order). You will need to then use the
provided
function to print the map with the player.
HINT Unsure how to call the
function? Here is an example that you can copy
to your main function.
Notice how we only need to provide the
variable, no square brackets are required!
This will print your current map with the player spawning at (5,7). How could you modify this
to use the position that you scanned in?
Here is a diagram of the map where the player is spawned at (5,7). The player is represented
on the map as P. Assignment Structure
This assignment will test your ability to create, use and manipulate 2D arrays and structs to solve
problems. This will be done through the in-game map that has been implemented as a 2D array of
tiles. Each of these tiles are represented by a
, which is outlined below:
struct tile
Purpose:
To store information about the tiles of the map.
Contains:
enum tile_type type
The type of the map tile.
All tile types are found in the enum tile_type definition.
struct flower flower
Represents the enemy flower at this location (if one exists).
struct flower
Purpose:
To store information about a particular enemy flower.
Contains:
enum flower_state state
Represents the state that the enemy flower is in.
The provided enums are quite extensive. Definitions of each are provided below:
enum tile_type
Purpose:
Represent the possible types of a tile.
Possible values:
Represents an empty space.Assumptions / Restrictions / Clarifications
The row and column input will always be integer values.
A valid position will eventually be scanned in.
Examples
Example 1.2.1: One Invalid Position
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data, Mining, And Analytics Components Of Strategic Decision Making

Authors: Stephan Kudyba

1st Edition

1466568704, 9781466568709

More Books

Students also viewed these Databases questions