Computer Science > STUDY GUIDE > Texas A&M University - CSCE 121main.cpp (All)

Texas A&M University - CSCE 121main.cpp

Document Content and Description Below

#include <iostream> #include <fstream> #include <string> #include "helper.h" using std::cin, std::cout, std::endl, std::string, std::ifstream; /** * Creates internal representation of dungeon ma... p. * @param fileName File name of dungeon map representation. * @param width Width of dungeon map. * @param height Height of dungeon map. * @param currX Player's starting x-position on dungeon map. * @param currY Player's starting y-position on dungeon map. * @return 2D dynamic array representation of dungeon map with player's location. */ // STEP 1: Write code for createMap(...) function here. int** createMap(const string fileName,int& width,int& height,int& currX,int& currY){ // create array std::ifstream ifs(fileName); if (!ifs.is_open()) { cout << "ERROR: unable to open: " << fileName << endl; ifs.close(); return nullptr; }else{ int temp; ifs >> width; ifs >> height; ifs >> currX; ifs >> currY; int** array = new int*[height]; for( int i = 0; i < width; i++){ array[i] = new int[width]; } for( int i = 0; i < width; i++){ for(int j = 0; j < height; j++){ ifs >> temp; array[j][i] = temp; if ( j == currX && i == currY){ array[j][i] = TILE_PLAYER; } } [Show More]

Last updated: 2 years ago

Preview 1 out of 4 pages

Buy Now

Instant download

We Accept:

We Accept
document-preview

Buy this document to get the full access instantly

Instant Download Access after purchase

Buy Now

Instant download

We Accept:

We Accept

Reviews( 0 )

$7.00

Buy Now

We Accept:

We Accept

Instant download

Can't find what you want? Try our AI powered Search

82
0

Document information


Connected school, study & course


About the document


Uploaded On

Apr 04, 2021

Number of pages

4

Written in

Seller


seller-icon
Expert Tutor

Member since 4 years

58 Documents Sold

Reviews Received
6
2
0
0
3
Additional information

This document has been written for:

Uploaded

Apr 04, 2021

Downloads

 0

Views

 82

Document Keyword Tags

Recommended For You

Get more on STUDY GUIDE »

$7.00
What is Scholarfriends

In Scholarfriends, a student can earn by offering help to other student. Students can help other students with materials by upploading their notes and earn money.

We are here to help

We're available through e-mail, Twitter, Facebook, and live chat.
 FAQ
 Questions? Leave a message!

Follow us on
 Twitter

Copyright © Scholarfriends · High quality services·