elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Recuerda que debes registrarte en el foro para poder participar (preguntar y responder)


  Mostrar Mensajes
Páginas: [1]
1  Programación / Programación C/C++ / Re: Necesito ayuda en el juego del cross the road en: 12 Junio 2019, 18:07 pm
Gracias. Voy a intentarlo hacer.
2  Programación / Programación C/C++ / Re: Necesito ayuda en el juego del cross the road en: 12 Junio 2019, 15:39 pm
Gracias. Voy a intentarlo.
3  Programación / Programación C/C++ / Re: Necesito ayuda en el juego del cross the road en: 12 Junio 2019, 07:04 am
 :D Esta bien gracias la verdad me ayudarias muchisimo.
4  Programación / Programación C/C++ / Re: Necesito ayuda en el juego del cross the road en: 12 Junio 2019, 06:45 am
Gracias. Si nomas le falta eso que al chocar salga de la partida y tambien que tenga que pasar la carretera.
5  Programación / Programación C/C++ / Re: Necesito ayuda en el juego del cross the road en: 12 Junio 2019, 06:30 am
Gracias. Voy a buscar en google
6  Programación / Programación C/C++ / Necesito ayuda en el juego del cross the road en: 12 Junio 2019, 06:09 am
Necesito ayuda sobre una parte del juego de que tengo que hacer es que el personaje que lo tengo llamado como SKIN y los carros CAR es que al chocar el personaje y el carro o carro al personaje pierda y se regrese al menu y si pasa del limite pasa al siguite nivel.
Ayuda Porfavor y es en c++.

#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <conio.h>
#include <windows.h>
#include <time.h>

using namespace std;

#define der 77
#define izq 75
#define arr 72
#define abj 50

void menu();
int iniciar();
int letra;
int mover;
int i;
int nivel=1;
bool quitar=false;
bool seguir;
void instruccion();
void salir();

void gotoxy(int x, int y){
HANDLE hCon;
hCon= GetStdHandle(STD_OUTPUT_HANDLE);

COORD dwPos;
dwPos.X = x;
dwPos.Y = y;
SetConsoleCursorPosition(hCon,dwPos);
}

main(){
    menu();
}

void menu(){
    int opciones;

    while(opciones!=4){
        system("cls");
        cout << "\t\t\t\t\t\t  Crossy"<<endl<< "\t\t\t\t\t\t   Road"<<endl<<endl;
        cout<< "\t\t\t\t\t\t 1- Iniciar"<<endl;
        cout<< "\t\t\t\t\t\t 2- Intrucciones"<<endl;
        cout<< "\t\t\t\t\t\t 3- Salir"<<endl;
        cin>>opciones;

        switch(opciones){
    case 1:
        iniciar();
        break;
    case 2:
        instruccion();
        break;
    case 3:
        salir();
        break;
    default:
        system("cls");
        cout<< "Opcion no valida"<<endl;
        system("pause");
        break;
        }
    }
}

bool cuadro(){
      for(int x=1; x<=80; x++){
        gotoxy(x,1);
        cout<< ".";
        gotoxy(x,10);
        cout<< ".";
        if(x<=10){
            gotoxy(1,x);
            cout<< ".";
            gotoxy(80,x);
            cout<< ".";
        }
    }

}
class SKIN{
    int x=40, y=9;
public:
    SKIN(int personaje) {x= personaje/40; y=9;}
    SKIN(int _x, int _y): x(_x),y(_y){}
    void pintar();
    void mover();
};

    void SKIN::pintar(){
       gotoxy(x,y); cout<< "@";
    }
    void SKIN::mover(){
    if(kbhit()){
    char tecla=getch();
        gotoxy(x,y); cout<< " ";
        if(tecla == 'a' && x>3)x--;
        if(tecla == 'd' && x+1 < 79)x++;
        if(tecla == 'w' && y>2)y--;
        if(tecla == 's' && y+1 < 10)y++;
        gotoxy(x,y); cout<< "@";
  }
}
class CAR{
    int x,y;
public:
    CAR(int cars) {x,y;}
    CAR(int _x, int _y):x(_x),y(_y){}
    void pintar();
    void mover();
};

void CAR::pintar(){
    gotoxy(x,y); cout<< "O";
}

void CAR::mover(){
    gotoxy(x,y); cout<< " ";
    x++;
    if(x>79){
        x=rand()%74 + 1;
        x = 1;
    }
    pintar();
}

int iniciar(){

    system("cls");

     gotoxy (70,0); cout<< "Nivel: "<<nivel<<endl;
Código
  1.  

    cuadro();
    SKIN N(40,9);
    N.pintar();

    CAR car(15,8),car1(68,7),car2(38,7),car3(24,5),car4(47,4),car5(2,4),car6(34,4),car7(71,3),car8(18,3);

    bool game_over=false;
    while(!game_over){

        car.mover();
        car1.mover();
        car2.mover();
        car3.mover();
        car4.mover();
        car5.mover();
        car6.mover();
        car7.mover();
        car8.mover();
        car8.mover();

        srand(time(NULL));
        N.mover();
        Sleep(60);
    }

    system  ("pause");
}

void instruccion(){
    system("cls");

    gotoxy(15,15); cout<< "Crossy Road es un juego en el cual se controla a un personaje";
    gotoxy(15,16); cout<< "el cual intenta cruzar un camino mientras esquivas los obstaculos,";
    gotoxy(15,17); cout<< "los cuales cuentan con movimiento en formas aleatorias y tener mucho cuidado";
    gotoxy(15,18); cout<< "con los obstaculos porque al ser tocados son eliminados."<<endl;
    gotoxy(45,19); cout<< "CONTROLES";
    gotoxy(45,20); cout<< "Arriba > W";
    gotoxy(45,21); cout<< "Abajo > S";
    gotoxy(45,22); cout<< "Izquierda > A";
    gotoxy(45,23); cout<< "Derecha > D" <<endl;
    gotoxy(80,19); cout<< "Personaje: "<< "@"<<endl;
    gotoxy(80,20); cout<< "Carros: "<< "O"<<endl;

    system("Pause");
}
void salir(){

    exit(0);
}
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines