Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <time.h>
- #include <conio.h>
- #include "Header.hpp"
- using namespace std;
- using namespace System;
- #define COL 80
- #define FIL 24
- #define DERECHA 77
- #define IZQUIERDA 75
- #define ARRIBA 72
- #define ABAJO 80
- void DibujarMapa()
- {
- for (int f = 0; f < FIL; f++)
- {
- for (int c = 0; c < COL; c++)
- {
- Console::SetCursorPosition(c, f);
- switch (matriz[f][c])
- {
- case 0: Console::ForegroundColor = ConsoleColor::Red; break;
- case 1: Console::ForegroundColor = ConsoleColor::DarkCyan; break;
- case 2: Console::ForegroundColor = ConsoleColor::Cyan; break;
- case 3: Console::ForegroundColor = ConsoleColor::DarkYellow; break;
- case 4: Console::ForegroundColor = ConsoleColor::White; break;
- case 5: Console::ForegroundColor = ConsoleColor::Green; break;
- case 6: Console::ForegroundColor = ConsoleColor::Magenta; break;
- case 7: Console::ForegroundColor = ConsoleColor::Yellow; break;
- case 8: Console::ForegroundColor = ConsoleColor::DarkGreen; break;
- }
- cout << char(219);
- }
- }
- }
- class Caña
- {
- int x, y;
- int kilos;
- public:
- Caña(int _x, int _y, int _kilos) :x(_x), y(_y), kilos(_kilos) {}
- void pintar();
- void mover();
- void contadorkilos();
- };
- void Caña::pintar()
- {
- Console::SetCursorPosition(x, y);
- cout << char(190);
- }
- void Caña::mover()
- {
- if (_kbhit())
- {
- char t = _getch();
- Console::SetCursorPosition(x, y);
- Console::ForegroundColor = ConsoleColor::DarkCyan;
- cout << char(219);
- if (t == DERECHA && matriz[y][x + 1] != 3 && matriz[y][x + 1] != 2)
- {
- x++;
- }
- if (t == IZQUIERDA && matriz[y][x - 1] != 3 && matriz[y][x - 1] != 2)
- {
- x--;
- }
- if (t == ARRIBA && matriz[y - 1][x] != 3 && matriz[y - 1][x] != 2)
- {
- y--;
- }
- if (t == ABAJO && matriz[y + 1][x] != 3 && matriz[y + 1][x] != 2)
- {
- y++;
- }
- if (t == 'x')
- {
- kilos ++;
- }
- pintar();
- contadorkilos();
- }
- }
- void Caña::contadorkilos()
- {
- Console::SetCursorPosition(35, 2);
- cout << "kilos:";
- Console::SetCursorPosition(42, 2);
- cout << kilos;
- }
- class Tiburon
- {
- int x, y;
- int d = 1;
- public:
- Tiburon(int _x, int _y) :x(_x), y(_y) {}
- void pintar();
- void mover();
- };
- void Tiburon::pintar()
- {
- Console::SetCursorPosition(x, y);
- cout << char(178);
- }
- void Tiburon::mover()
- {
- Console::SetCursorPosition(x, y);
- Console::ForegroundColor = ConsoleColor::DarkCyan;
- cout << char(219);
- x += d;
- if (x > 68) d *= -1;
- if (x < 11) d *= -1;
- pintar();
- }
- class Peces
- {
- int x, y;
- int d = 1;
- public:
- Peces(int _x, int _y) :x(_x), y(_y) {}
- void pintar();
- void mover();
- };
- void Peces::pintar()
- {
- Console::SetCursorPosition(x, y);
- cout << char(62);
- }
- void Peces::mover()
- {
- Console::SetCursorPosition(x, y);
- Console::ForegroundColor = ConsoleColor::DarkCyan;
- cout << char(219);
- x += d;
- if (x > 68) d *= -1;
- if (x < 11) d *= -1;
- pintar();
- }
- void main()
- {
- Console::SetWindowSize(COL, FIL);
- Console::CursorVisible = false;
- int m = 0;
- char t;
- DibujarMapa();
- Caña Caña(11, 8, 0);
- Caña.contadorkilos();
- Tiburon Tiburon1(15, 8), Tiburon2(15, 9);
- Peces peces1(15, 11), peces2(20, 16), peces3(17, 20), peces4(40, 14), peces5(43, 18), peces6(36, 22);
- while (1)
- {
- Caña.mover();
- peces1.mover();
- peces2.mover();
- peces3.mover();
- peces4.mover();
- peces5.mover();
- peces6.mover();
- m++;
- if (m % 2 == 0)
- {
- Tiburon1.mover();
- Tiburon2.mover();
- }
- _sleep(50);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement