Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //LaNeta.h
- #pragma once
- #include "Nave.h"
- class CLaNeta :
- public CNave
- {
- public:
- CLaNeta();
- void Mostrar();
- void Ocultar();
- ~CLaNeta();
- };
- //LaNeta.cpp
- #include "stdafx.h"
- CLaNeta::CLaNeta()
- {
- x = 10;
- y = 10;
- dx = 2;
- color = 11;
- ancho = 13;
- alto = 3;
- }
- void CLaNeta::Mostrar()
- {
- Console::ForegroundColor = (ConsoleColor)color;
- Console::SetCursorPosition(x, y);
- cout << " __!__ ";
- Console::SetCursorPosition(x, y+1);
- cout << "_____(_)_____";
- Console::SetCursorPosition(x, y+2);
- cout << " ! ! ! ";
- }
- void CLaNeta::Ocultar()
- {
- Console::ForegroundColor = (ConsoleColor)color;
- Console::SetCursorPosition(x, y);
- cout << " ";
- Console::SetCursorPosition(x, y + 1);
- cout << " ";
- Console::SetCursorPosition(x, y + 2);
- cout << " ";
- }
- CLaNeta::~CLaNeta()
- {
- }
- //Avion.h
- #pragma once
- #include "stdafx.h"
- class CAvion :public CNave
- {
- public:
- CAvion(int px, int py);
- void Mostrar();
- void Ocultar();
- ~CAvion();
- };
- //CAvion.cpp
- #include "stdafx.h"
- CAvion::CAvion(int px, int py):CNave()
- {
- x = px;
- y = py;
- ancho = 11;
- alto = 3;
- color = 10;
- }
- void CAvion::Mostrar()
- {
- Console::ForegroundColor = (ConsoleColor)color;
- Console::SetCursorPosition(x, y);
- cout << "-----------";
- Console::SetCursorPosition(x, y + 1);
- cout << "_/__(_)__\\_";
- Console::SetCursorPosition(x, y + 2);
- cout << " ./ \\. ";
- }
- void CAvion::Ocultar()
- {
- Console::SetCursorPosition(x, y);
- cout << " ";
- Console::SetCursorPosition(x, y + 1);
- cout << " ";
- Console::SetCursorPosition(x, y + 2);
- cout << " ";
- }
- CAvion::~CAvion()
- {
- }
- //Nave.h
- #pragma once
- class CNave
- {
- protected:
- int x, y, ancho, alto, dx, dy, color;
- public:
- CNave();
- void Mover();
- ~CNave();
- };
- //Nave.cpp
- #include "stdafx.h"
- CNave::CNave()
- {
- dx = 1;
- dy = 0;
- }
- void CNave::Mover()
- {
- if (x + dx < 0 || x + dx + ancho>79)
- {
- dx *= -1;
- }
- x += dx;
- }
- CNave::~CNave()
- {
- }
- //
- stadfx.h
- // stdafx.h : include file for standard system include files,
- // or project specific include files that are used frequently, but
- // are changed infrequently
- //
- #pragma once
- #include <iostream>
- #include <conio.h>
- #include <string>
- #include "Nave.h"
- #include "Avion.h"
- #include "LaNeta.h"
- using namespace System;
- using namespace std;
- // TODO: reference additional headers your program requires here
- //MAIN
- // ConsoleApplication1.cpp : main project file.
- #include "stdafx.h"
- int main()
- {
- CAvion*obj = new CAvion(15,15);
- CLaNeta*obj2 = new CLaNeta();
- while (1)
- {
- obj->Mostrar();
- obj2->Mostrar();
- _sleep(50);
- obj->Ocultar();
- obj2->Ocultar();
- obj->Mover();
- obj2->Mover();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment