waaronmorris / CS162_Group_15_Project_1

0 stars 1 forks source link

Just a place to start #8

Closed troelze closed 6 years ago

troelze commented 6 years ago

Simply makes the 2d board array (this can be accomplished in our Game class if we want to but I did it here to keep it simple for now. If you compile this with Critter.cpp on flip you get a print out of our board with 0s and 1s wherever **.placeCritter(x,y) has been called.

troelze commented 6 years ago

Hmm ok well looks like William already has a lot going here so we can ignore my idea. I wasn't even going to have a Space/Board class with all that functionality. It looks good to me though! Mine is much simpler haha.....

`#ifndef CRITTER_HPP

define CRITTER_HPP

class Critter { private:

    static int board[20][20];
    int x;
    int y;
    int name;
public:
    void placeCritter(int, int);    
    Critter();
    void printBoard();
    ~Critter(); 

};

endif

//Critter.cpp

include "Critter.hpp"

include

Critter::Critter() { }

int Critter::board[20][20] = {{0}};

void Critter::placeCritter(int x, int y) { board[x][y] = 1; }

void Critter::printBoard() { for (int i = 0; i < 20; i++) { for (int j = 0; j < 20; j++) { std::cout << board[i][j]; } std::cout << std::endl; } }

Critter::~Critter() { }'

waaronmorris commented 6 years ago

Yeh....I did this same pattern for the Langston Ants. I am just porting the Space and Board classes over from there.