Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Actual Lab Task for this lab First: for each bullet point, make sure you try to test your code before moving on to the

image text in transcribed

The Actual Lab Task for this lab First: for each bullet point, make sure you try to test your code before moving on to the next instruction. t will be impossible to debug your code if you try to write it all and then figure out your mistakes. - Make a 2D array of characters representing the game grid. Do this in the main method. This grid should be the width and height values you input in the earlier section. - You should also make a new "position" struct that consists of two unsigned integers. - Write a function printGrid that takes the 2D char grid and the grid size (a position can store the maximum width and height of the grid). This function simply uses printf statements to output all the grid characters. - Make an array of positions where each position represents an enemy. These enemies won't move just yet. Each enemy can be positioned anywhere on the grid. - Make a position variable for storing the player position. This position will move. - Write a function updateGrid that takes the 2D array, the grid size, the player position and the array of enemy positions (plus the size of that array) as input. Change the values in the 2D array to match where the players and enemies are now. - Write a function userAction that takes a player position, the grid size, a character array buffer (to put what the user types into), and the size of that character array. Update the player's position appropriately if the correct command is written. For example, a user may write u3 which would move the player character Up 3 positions. The character's position cannot go outside the grid bounds. If it would go outside those bounds, make the position as close to the desired position as you can while still being valid. - Write a function gameloop that calls printGrid, userAction, and updateGrid in a loop. The loop will stop when the user types q or Q instead of a new player instruction (so the q would be in the character buffer you keep using for user input). - Now you should be able to run your "game", move around your character and see the character position change. Make sure you test a variety of scenarios and make sure your program stops when you type q or

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

Step: 3

blur-text-image

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2018 Dublin Ireland September 10 14 2018 Proceedings Part 1 Lnai 11051

Authors: Michele Berlingerio ,Francesco Bonchi ,Thomas Gartner ,Neil Hurley ,Georgiana Ifrim

1st Edition

3030109240, 978-3030109240

More Books

Students also viewed these Databases questions