Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- #include <fstream>
- #include<ctime>
- #include<cstdlib>
- #define FILAS 24
- #define COLUMNAS 80
- using namespace std;
- using namespace System;
- int dir = 1;
- int lvl2[FILAS][COLUMNAS] = {
- { 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 },
- { 4,4,4,4,4,4,4,4,1,1,1,4,4,4,4,4,4,4,4,4,4,4,4,4,1,1,1,4,4,4,4,4,4,4,4,4,4,4,4,1,1,1,1,4,4,4,4,4,4,4,4,4,4,4,4,1,1,1,4,4,4,4,4,4,4,4,4,4,4,4,4,1,1,1,4,4,4,4,4,4 },
- { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
- { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
- { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
- { 1,1,1,1,1,1,1,1,1,1,10,10,10,10,10,10,10,1,1,1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,4,4,4,4,4,4,4,4,4 }
- };
- void dibujo2() {
- for (int cf = 0; cf < FILAS; cf++)
- {
- for (int cc = 0; cc < COLUMNAS; cc++)
- {
- Console::SetCursorPosition(cc, cf);
- switch (lvl2[cf][cc])
- {
- case 1:Console::ForegroundColor = ConsoleColor::Cyan; cout << (char)219; break;
- case 2:Console::ForegroundColor = ConsoleColor::DarkGray; cout << (char)219; break;
- case 3:Console::ForegroundColor = ConsoleColor::Gray; cout << (char)219; break;
- case 4:Console::ForegroundColor = ConsoleColor::DarkGreen; cout << (char)219; break;
- case 5:Console::ForegroundColor = ConsoleColor::Green; cout << (char)219; break;
- case 6:Console::ForegroundColor = ConsoleColor::DarkBlue; cout << (char)219; break;
- case 7:Console::ForegroundColor = ConsoleColor::White; cout << (char)219; break;
- case 9:Console::ForegroundColor = ConsoleColor::Red; cout << (char)219; break;
- case 10:Console::ForegroundColor = ConsoleColor::DarkRed; cout << (char)219; break;
- case 12:Console::ForegroundColor = ConsoleColor::DarkRed; cout << (char)219; break;
- case 13:Console::ForegroundColor = ConsoleColor::DarkRed; cout << (char)219; break;
- case 14:Console::ForegroundColor = ConsoleColor::DarkRed; cout << (char)219; break;
- case 11:Console::ForegroundColor = ConsoleColor::Magenta; cout << (char)219; break;
- case 0:Console::ForegroundColor = ConsoleColor::Yellow; cout << (char)219; break;
- }
- }
- cout << endl;
- }
- }
- void pintar(int x, int y) {
- Console::SetCursorPosition(x , y); Console::ForegroundColor = ConsoleColor::DarkRed; cout << (char)219 << (char)219 << (char)219 << (char)219 << (char)219 << (char)219 << (char)219;
- }
- void borrar(int x, int y) {
- Console::SetCursorPosition(x, y);
- Console::BackgroundColor = ConsoleColor::Cyan; cout << " ";
- }
- void buscaPersonaje(int n[FILAS][COLUMNAS],int *x,int *y,int p) {
- for (int f = 0; f < FILAS; f++)
- {
- for (int c = 0; c < COLUMNAS; c++)
- {
- if (n[f][c]==p)
- {
- *x = f;
- *y = c;
- break;
- }
- }
- }
- }
- void moverPersonaje(int n[FILAS][COLUMNAS],short d, int x, int y) {
- switch (d)
- {
- case 1://derecha
- if (n[x][y+1]==4 )
- {
- n[x][y + 1] = 0;
- n[x][y] = 4;
- }; break;
- case 2://izquierda
- if (n[x][y-1] == 4)
- {
- n[x][y - 1] = 0;
- n[x][y] = 4;
- }; break;
- case 3:
- if (n[x-1][y] == 4)
- {
- n[x-1][y] = 0;
- n[x][y] = 4;
- }; break;
- case 4:
- if (n[x+1][y] == 4)
- {
- n[x+1][y] = 0;
- n[x][y] = 4;
- }; break;
- }
- }
- //void moviTRo(int n[FILAS][COLUMNAS],int *x,int *y,int num) {
- //
- //
- // buscaPersonaje(lvl2, x, y, num);
- // if (n[*x][*y + 1] == num && n[*x][*y + 7] == 1)
- // {
- // if (dir==1) {
- // for (int i = 1; i < 7; i++) {
- // n[*x][*y + i] = num;
- // }
- // n[*x][*y] = 1;
- // }
- // else {
- // for (int i = 7; i >1; i--) {
- // n[*x][*y + i] = num;
- // }
- // n[*x][*y] = 1;
- // }
- //
- //
- // }
- // if (n[*x][*y + 7] != 1) {
- // dir = 2;
- // }
- //
- //
- //
- //}
- void moverTronco(int n[FILAS][COLUMNAS]) {
- int x, y;
- /*moviTRo(n,&x, &y, 10);
- moviTRo(n, &x, &y, 12);
- moviTRo(n, &x,&y, 13);
- moviTRo(n, &x, &y, 14);*/
- dibujo2();
- }
- int main() {
- //repite:
- int x = 0;
- int tecla;
- int y = 0;
- int n;
- dibujo2();
- while (true)
- {
- if (kbhit())
- {
- buscaPersonaje(lvl2, &x, &y,0);
- tecla = _getch();
- switch (tecla)
- {
- case 97:moverPersonaje(lvl2, 2, x, y); break;
- case 100:moverPersonaje(lvl2, 1, x, y); break;
- case 119:moverPersonaje(lvl2, 3, x, y); break;
- case 115:moverPersonaje(lvl2, 4, x, y); break;
- }
- dibujo2();
- }
- n = rand() % 500;
- if (n<100)
- {
- moverTronco(lvl2);
- }
- }
- //A=7
- //D=100
- //W=119
- //S=115
- /*while (i<72)
- {
- _sleep(50);
- borrar(x , y);
- pintar(x+1 , y);
- if (i<64)
- {
- borrar(w, y);
- pintar(w + 1, y);
- w++;
- }
- if (i<57)
- {
- borrar(z, y);
- pintar(z + 1, y);
- z++;
- }
- x++;
- ++i;
- }
- goto repite;*/
- cin.get();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement