biquadris / main.cc
main.cc
Raw
/*
    FINAL PROJECT CS246 - BIQUADRIS
    e6ryan, nsuprapt, welbert

    Biquadris is a two player game similar to Tetris where players rotate and
    drop block onto the board, clearing line(s) as they play. However, Biquadris
    is not timed and special levels and actions affect the gameplay.

    User -> Controller -> Model -> View -> User
*/

#include <string> 
#include <memory>
#include "controller.h"
#include "model.h"
#include "view.h"

using namespace std;

const int BOARD_WIDTH = 11;
const int BOARD_HEIGHT = 18;

const int PLAYER_COUNT = 2;

int main(int argc, char *argv[]) {
    string s1 = "sequence1.txt";
    string s2 = "sequence2.txt";
    int seed = 1;
    int level = 0;
    bool graphics = true;
    for (int i = 1; i < argc; ++i) {
        if (string(argv[i]) == "-text") {
            graphics = false;
        } else if (string(argv[i]) == "-seed") {
            seed = stoi(argv[++i]);
        } else if (string(argv[i]) == "-scriptfile1") {
            s1 = argv[++i];
        } else if (string(argv[i]) == "-scriptfile2") {
            s2 = argv[++i];
        } else if (string(argv[i]) == "-startlevel") {
            level = stoi(argv[++i]);
        }
    }

    unique_ptr<View> theView = make_unique<View>(graphics, BOARD_WIDTH, BOARD_HEIGHT);
    unique_ptr<Controller> theCtr = make_unique<Controller>(*(theView.get()), &cin);
    unique_ptr<BiquadrisModel> theModel = make_unique<BiquadrisModel>(
        theCtr.get(), theView.get(), s1, s2, PLAYER_COUNT, BOARD_WIDTH, BOARD_HEIGHT, seed, level
    );
    theModel->attach(theView.get());
    theCtr->addModel(theModel.get());
    theCtr->getCommandInput(); // continuously reads command line input
}