Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <functional>
- #include <vector>
- //super secret propreitary software (c) copyright Caesura Software
- using namespace std;
- //Elk: The game of fast-paced action-packed boredom.
- /* --- VARIABLES --- */
- struct bounds { //board size
- const int x = 20;
- const int y = 20;
- };
- /* --- END VARIABLES --- */
- //vector code
- typedef vector<vector<int>> i2d;
- function<i2d(int,int)> retVec = [](int x, int y) -> i2d {
- i2d vec;
- vec.resize(x);
- for(int a = 0; a < x; ++a){
- vec[a].resize(y);
- }
- return vec;
- };
- class Vec2D {
- public:
- i2d vec;
- Vec2D(int x, int y) {
- vec = retVec(x,y);
- };
- inline int& at(int x, int y) {
- return vec[x][y];
- }
- };
- //end vector code
- //print the board
- function<int(i2d)> show = [](i2d board) -> int {
- bounds po;
- for (int a = 0; a < po.x; ++a) {
- for (int b = 0; b < po.y; ++b) {
- if (a == 0 or b == 0 or a == po.x-1 or b == po.y-1) {
- cout << "*" ;
- }
- else if (board[a][b] == 0) {
- cout << ".";
- }
- else if (board[a][b] == 1) {
- cout << "@";
- }
- else {
- cout << board[a][b];
- }
- cout << " ";
- }
- cout << endl;
- }
- return 0;
- };
- //end printing the board
- //player stuff
- class player {
- public:
- int x;
- int y;
- int hp = 10;
- player (int xPos, int yPos) {
- x = xPos;
- y = yPos;
- };
- };
- function<int(i2d&)> movep = [](i2d& board) -> int {
- player pl(5,2);
- bounds po;
- board[pl.x][pl.y] = 1;
- int temp = 0;
- string input;
- function<int(int,int)> plmov = [&](int xPos, int yPos) -> int {
- /*string bmsg = "Bounds checking enabled.";
- if ((pl.x == 0 or pl.y == 0) and (xPos > 0 or yPos > 0)) {
- cout << bmsg << endl;
- }
- else if ((pl.x == po.x-1 or pl.y == po.y-1) and (xPos == 0 or yPos == 0)) {
- cout << bmsg << endl;
- }
- else {
- board[pl.x][pl.y] = temp;
- temp = board[pl.x+xPos][pl.y+yPos];
- board[pl.x+xPos][pl.y+yPos] = 1;
- pl.x += xPos;
- pl.y += yPos;
- show(board);
- }*/
- board[pl.x][pl.y] = temp;
- temp = board[pl.x+xPos][pl.y+yPos];
- board[pl.x+xPos][pl.y+yPos] = 1;
- pl.x += xPos;
- pl.y += yPos;
- show(board);
- return 0;
- };
- show(board);
- show(board); //eh
- for(;;){
- cout << "> ";
- cin >> input;
- if(input == "left") {
- plmov(0, -1);
- }
- else if(input == "right") {
- plmov(0, 1);
- }
- else if(input == "up") {
- plmov(-1, 0);
- }
- else if(input == "down") {
- plmov(1, 0);
- }
- else if(input == "end") {
- cout << "Thanks for listening." << endl;
- break;
- }
- else {
- cout << "CAN'T LET YOU DO THAT STARFOX" << endl;
- }
- }
- return 0;
- };
- //end player stuff
- int main(int argc, char **argv){
- bounds co;
- Vec2D vec(co.x, co.y);
- vec.at(2,3) = 7;
- vec.at(2,4) = 8;
- vec.at(2,5) = 9;
- vec.at(2,7) = 4;
- movep(vec.vec);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement