#include<iostream>
#include<time.h>
using namespace std;

int main(){
 srand(time(NULL));

 char *star = "*****"; // char str[6]="*****" 과 같다 //
 char *space = "     ";
 
 //*****
 //****
 //***
 //**
 //*
 for (int i = 0; i < 5; i++){
  cout << star + i << endl; // star의 주소의 0번째부터 
 }
 cout << endl;

 //*
 //**
 //***
 //****
 //*****
 //for (int i = 4; i >= 0; i--){
 // cout << star + i << endl; 
 //}
 for (int i = 0; i < 5; i++){
  cout << star + 4 - i << endl; // star의 주소의 4번째부터 
 }
 cout << endl;

 //*****
 // ****
 //  ***
 //   **
 //    *
 for (int i = 0; i < 5; i++){
  cout << space + 5 - i << star + i << endl;
 }
 cout << endl;

 //    *
 //   **
 //  ***
 // ****
 //*****
 for (int i = 0; i < 5; i++){
  cout << space + i +1 << star + 4 - i << endl;
 }

 return 0;
}

 

//ㅡㅡ 구동화면 ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ

일단 포인터는 주소값을 가지고 한다는 점을 알고 있기만 하고

star 라는 포인터 변수의 가지고 있는 "*****" 이 맨 앞의 별주소를 가지고 있고 1씩 증가할 때 마다

별의 갯수가 증가하는걸 볼 수 있는데 star + 1 을 했을 시 출력 결과는 "**" 가 되게 되고 값이

추가적으로 증가함으로써 아래 그림처럼 주소값의 증가로 별의 갯수를 추가적으로 찍을 수 있다.


 

'SGA 스터디 > C++ 코딩' 카테고리의 다른 글

카드 뒤집기  (0) 2015.08.14
월남뽕  (0) 2015.08.13
하이 로우 세븐 카드게임 ( High & Low 7 )  (0) 2015.08.11
슬롯머신 게임  (0) 2015.08.11
타일맵 그리기  (0) 2015.08.05

#include<iostream>

#include<time.h>

#include<conio.h>

#include<Windows.h>


using namespace std;


void startView(); // 시작화면

void cardShuffle(); // 카드를 섞어줄 함수

void gamePlay(); // 진행화면

void endPage(); // 종료화면



char *card[52] = {  "◆A", "◆2", "◆3", "◆4", "◆5", "◆6", "◆7", "◆8", "◆9", "◆10", "◆J", "◆Q", "◆K",

"♣A", "♣2", "♣3", "♣4", "♣5", "♣6", "♣7", "♣8", "♣9", "♣10", "♣J", "♣Q", "♣K",

"♠A", "♠2", "♠3", "♠4", "♠5", "♠6", "♠7", "♠8", "♠9", "♠10", "♠J", "♠Q", "♠K",

"♥A", "♥2", "♥3", "♥4", "♥5", "♥6", "♥7", "♥8", "♥9", "♥10", "♥J", "♥Q", "♥K" };

int cardResult[52];                  // 실질적인 하이 로우 세븐을 처리할 값을 저장할 배열

int money = 1000;          // 보유 금액

int remainCard = 0;  // 진행하며 남은 카드를 확인할 변수

int inputKey;  // 첫화면에서 Enter 키를 입력을 받아야 다음을 진행하기 위해 사용된 변수로 사용되고 이후 하이로우세븐을 지정할 변수 ( Num1키 49 , Num2키 50 , Num3키 51 , ESC키 27)

int stage = 0;  // 스테이지 진행 및 보여줄 카드 확인을 위한 변수

int bMoney = 0;  // 배팅 금액



void main() 

{

// 과제3 하이로우세븐

//   카드 52장  

//       하이 금액 * 2

//       로우 금액 * 2

//       세븐 금액 * 7

srand(time(NULL));


startView();

while(money > 0 && inputKey != 27){

cardShuffle();

gamePlay();

}

endPage();

}


void startView() {

cout << endl;

cout << " ┌──── HIGH & LOW 7 ────┐" << endl;

cout << " │                              │" << endl;

cout << " │                              │" << endl;

cout << " │                              │" << endl;

cout << " │                              │" << endl;

cout << " │      G A M E  S T A R T      │" << endl;

cout << " │                              │" << endl;

cout << " │  P r e s s  S p a c e B a r  │" << endl;

cout << " │                              │" << endl;

cout << " │                              │" << endl;

cout << " └───────────────┘" << endl;


while(1){

inputKey = getch();

if (inputKey == 32) break;

}

}

void cardShuffle() {

int nNum1, nNum2; // 랜덤 숫자를 받을 변수

if(remainCard == 0)

{

// 섞을 카드를 새로운 배열에 일단 초기화

// 아래 if문은 해당 하이로우세븐을 구분할 값을 배열에 초기화

for (int i = 0; i < 52; i++) {

if( i % 13 < 7)

{

cardResult[i] = 2;

}

else if (i % 13 == 7) {

cardResult[i] = 3;

}

else {

cardResult[i] = 1;

}

}

// 카드 섞기

for (int i = 0; i < 1000; i++){

nNum1 = rand() % 52;

nNum2 = rand() % 52;

swap(card[nNum1], card[nNum2]);

swap(cardResult[nNum1], cardResult[nNum2]);

}

remainCard = 51;

stage = 0;

}

}


void gamePlay() {

system("cls");

cout << endl;

cout << " ┌──── HIGH & LOW 7 ────┐" << endl;

if(remainCard > 9){

cout << " │  [  ?  ]       남은카드 : " << remainCard << " │" << endl;

}

else {

cout << " │  [  ?  ]       남은카드 :  " << remainCard << " │" << endl;

}

cout << " │                              │" << endl;


if (stage - 1 >= 0) {

cout << "     [ " << card[stage - 1] << " ]";

} else {

cout << "     [     ]";

}

if (stage - 2 >= 0) {

cout << "   [ " << card[stage - 2] << " ]";

} else {

cout << "   [     ]";

}

if (stage - 3 >= 0) {

cout << "   [ " << card[stage - 3] << " ]" << endl;

} else {

cout << "   [     ]" << endl;

}


cout << " │                              │" << endl;

if (stage - 4 >= 0) {

cout << "     [ " << card[stage - 4] << " ]";

}

else {

cout << "     [     ]";

}

if (stage - 5 >= 0) {

cout << "   [ " << card[stage - 5] << " ]";

}

else {

cout << "   [     ]";

}

if (stage - 6 >= 0) {

cout << "   [ " << card[stage - 6] << " ]" << endl;

}

else {

cout << "   [     ]" << endl;

}


cout << " │                              │" << endl;


if (stage - 7 >= 0) {

cout << "     [ " << card[stage - 7] << " ]";

}

else {

cout << "     [     ]";

}

if (stage - 8 >= 0) {

cout << "   [ " << card[stage - 8] << " ]";

}

else {

cout << "   [     ]";

}

if (stage - 9 >= 0) {

cout << "   [ " << card[stage - 9] << " ]" << endl;

}

else {

cout << "   [     ]" << endl;

}

cout << " │                              │" << endl;

cout << " │ 1. HIGH    2. LOW   3. SEVEN │" << endl;

cout << " └───────────────┘" << endl;

cout << " 배팅을 종료하시려면 ESC 키를 입력하세요" << endl;

cout << " HIGH, LOW, SEVEN 을 선택하세요 ( 1, 2, 3 )" << endl;

cout << " 보유 금액 : " << money << endl;

while (1)

{

inputKey = getch();

if (inputKey == 49 || inputKey == 50 || inputKey == 51 || inputKey == 27) break;

}

if (inputKey == 49 || inputKey == 50 || inputKey == 51)

{

cout << " 배팅금액을 입력하세요 : ";

cin >> bMoney;

while (money < bMoney && bMoney > 0) {

cout << " 배팅금액이 보유금액을 넘을 수 없습니다 " << endl;

cout << " 배팅금액을 입력하세요 : ";

cin >> bMoney;

}

int select = 0;  // 하이 로우 세븐 계산 변수


// 하이 로우 세븐 중 선택한 값을 선택

if (inputKey == 49) {

select = 1;

}

else if (inputKey == 50) {

select = 2;

}

else {

select = 3;

}


// 보유금액에서 배팅한 금액만큼 빼준다

money -= bMoney;


// 배팅에 성공 여부에 따른 계산 처리

if (cardResult[stage] == select) {

if (select == 1 || select == 2) {

money = money + (bMoney * 2);

}

else {

money = money + (bMoney * 7);

}

}

stage++;

remainCard--;

}

}

void endPage() {

if (money == 0) {

cout << " =========== 게임 종료 ===========" << endl;

cout << "          파산하였습니다." << endl;

}

else {

cout << " =========== 게임 종료 ===========" << endl;

cout << "      보유 금액 : " << money << endl;

}

}

//ㅡㅡ 구동화면 ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ

스페이스바를 누르면 게임이 시작됩니다.

룰은 ? 된 카드의 값이 7보다 높은지 낮은지 아니면 7인지를 선택해 

( Num1키 -> HIGH  /  Num2키 -> LOW  /  Num3키 -> SEVEN )

만약 맞추었다면 배팅한 금액에 따라 

HIGH & LOW 는 배팅 금액 2배

SEVEN 은 배팅 금액 7배

에 해당하는 금액을 받게 됩니다.

카드가 다 소모되면 카드를 초기화 시켜 계속 이어서 게임을 진행할 수 있고

금액을 다 소모하게되면

아래 그림과 같이 파산하게 되어 게임이 종료됩니다.

아니면 게임 진행 중에 종료하고 싶다면 ESC 키를 누르면 게임이 종료됩니다.


↓ 소스 파일 

HighLowSeven.cpp


'SGA 스터디 > C++ 코딩' 카테고리의 다른 글

월남뽕  (0) 2015.08.13
별찍기  (0) 2015.08.11
슬롯머신 게임  (0) 2015.08.11
타일맵 그리기  (0) 2015.08.05
채팅 대전액션  (0) 2015.08.04

#include<iostream>

#include<time.h>

#include<conio.h>

#include<Windows.h>


using namespace std;


void startView(); // 시작화면

void slotInput(); // 슬롯 숫자지정

void Display();         // 그려줄 화면

void gamePlay(); // 게임진행여부 확인

void slotCheck(); // 슬롯 체크


char *card[52] = {  "◆A", "◆2", "◆3", "◆4", "◆5", "◆6", "◆7", "◆8", "◆9", "◆10", "◆J", "◆Q", "◆K",

"♣A", "♣2", "♣3", "♣4", "♣5", "♣6", "♣7", "♣8", "♣9", "♣10", "♣J", "♣Q", "♣K",

"♠A", "♠2", "♠3", "♠4", "♠5", "♠6", "♠7", "♠8", "♠9", "♠10", "♠J", "♠Q", "♠K",

"♥A", "♥2", "♥3", "♥4", "♥5", "♥6", "♥7", "♥8", "♥9", "♥10", "♥J", "♥Q", "♥K" };

int money = 1000;  // 보유 금액

int bCount = 5;  // 배팅 기회

int slot1 = 0, slot2 = 0, slot3 = 0; // 슬롯1, 2, 3

int cSlot1 = 0, cSlot2 = 0, cSlot3 = 0; // 슬롯에 위치한 카드 확인

int inputKey = 49;  // 게임진행 및 종료를 입력받을 키 ( Num1키 아스키값 49 / Num2키 아스키값 50)


void main() 

{

// 슬롯머신

//       카드 52장 ◆ ♣ ♠ ♥ 1~10 J Q K

// 숫자트리플 777   -> 배팅금액 * 3

//       숫자더블   66   -> 배팅금액 * 2

//       문양트리플♥♥♥ -> 배팅기회 * 3

//       문양더블  ♠♠   -> 배팅기회 + 3

startView();


while(bCount > 0 && inputKey == 49)

{

slotInput();

gamePlay();

slotCheck();

Display();

}

}

void startView() {

cout << " 시작금액" << endl;

cout << " 배팅기회" << endl;

cout << "    ┌────슬롯머신────┐" << endl;

cout << "    │                        │" << endl;

cout << "\t  게임을 시작합니다" << endl;

cout << "    │                        │" << endl;

cout << "    ├────────────┤" << endl;

cout << "    │  게임진행 1    종료 2  │" << endl;

cout << "    └────────────┘" << endl;

cout << " 배팅기회는 5회가 주어지며 최대 20까지 증가합니다." << endl;

cout << " 게임진행 Num1 을 누르면 배팅이 진행됩니다. " << endl;

cout << " 게임진행 Num2 를 누르면 배팅이 종료됩니다. " << endl;

}

void slotInput() {

// 중복된 값이 나오지 않을 때까지 반복

srand(time(NULL));

do

{

slot1 = rand() % 52;

slot2 = rand() % 52;

slot3 = rand() % 52;

} while (slot1 == slot2 || slot1 == slot3 || slot2 == slot3);

}

void Display() {

system("cls");

cout << " 시작금액 : 1000원 / 현재금액 : " << money << "원" << endl;

cout << " 배팅기회 : " << bCount << " 회 남았습니다" << endl;

cout << "    ┌────슬롯머신────┐" << endl;

cout << "    │                        │" << endl;

cout << "\t  " << card[slot1] << " " << card[slot2] << "   " << card[slot3] << endl;

cout << "    │                        │" << endl;

cout << "    ├────────────┤" << endl;

cout << "    │  게임진행 1    종료 2  │" << endl;

cout << "    └────────────┘" << endl;


}


void gamePlay() {

while (1) {

inputKey = getch();

if (inputKey == 49 || inputKey == 50) break;

}

if (inputKey == 49) bCount--; // 배팅을 했으므로 기회 1 감소

if (inputKey == 50) exit(1);  // Num2 를 누르면 게임이 종료됨

}


void slotCheck() {

int pTriple = 0; // 문양트리플 체크

int pDouble = 0; // 문양더블 체크

cSlot1 = slot1 % 13;

cSlot2 = slot2 % 13;

cSlot3 = slot3 % 13;


// 숫자트리플 배팅금액 * 3

if (cSlot1 == cSlot2 && cSlot1 == cSlot3) { money *= 3; }

// 숫자더블 배팅금액 * 2

else if (cSlot1 == cSlot2) { money *= 2; }

else if (cSlot1 == cSlot2) { money *= 2; }

else if (cSlot2 == cSlot3) { money *= 2; }


cSlot1 = slot1 / 13;

cSlot2 = slot2 / 13;

cSlot3 = slot3 / 13;


// 문양트리플 배팅기회 * 3

if (cSlot1 == cSlot2 && cSlot1 == cSlot3) { bCount *= 3; }

// 문양더블 배팅기회 + 3

else if (cSlot1 == cSlot2) { bCount += 3; }

else if (cSlot1 == cSlot2) { bCount += 3; }

else if (cSlot2 == cSlot3) { bCount += 3; }


// 최대 배팅기회 20으로 제한

if (bCount > 20) { bCount = 20; }

}


//ㅡㅡㅡ 구동화면 ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ

기본 룰은 시작금액 1000원으로 고정

배팅기회를 기본 5회로 지정

Num1 키를 누르면 게임이 시작되고 

숫자 트리플 시  금액 3배

숫자 더블 시     금액 2배

문양 트리플 시  배팅기회 3배

문양 더블 시     배팅기회 +3

생각외로 문양 트리플이 많이나와 최대 배팅기회를 20으로 지정

Num2 키를 누르면 어느때고 게임이 종료됩니다.

↓ 소스 파일 

SlotMachine.cpp


'SGA 스터디 > C++ 코딩' 카테고리의 다른 글

별찍기  (0) 2015.08.11
하이 로우 세븐 카드게임 ( High & Low 7 )  (0) 2015.08.11
타일맵 그리기  (0) 2015.08.05
채팅 대전액션  (0) 2015.08.04
퍼즐 게임  (0) 2015.08.01

#include<iostream>

#include<Windows.h>

using namespace std;


int main() 

{

//tilemap 그리기

//

//10 x 10 크기의 타일 맵그리기

//

//vertical(세로)(열)

//□□□□□□□□□□ horizontal(가로)(행)

//□□□□□□□□□□

//□□□□□□□□□□

//□□□□□□□□□□

//□□□□□□□□□□

//□□□□□□□□□□

//□□□□□□□□□□

//□□□□□□★□□□ 7, 6

//□□□□□□□□□□

//□□□□□□□□□□


//타일 맵을 그린다.

//입력한 수만큰 그린다.

//10을 입력하면 10x10 타일이 그려진다.(□로 도배)

//숫자 를 입력하면 그 위치가 ★바뀐다.

//배열을 쓰지 않는다.

int tile; // 타일 크기 변수 tile x tile

int x, y; // ★로 바꿀 위치를 정할 변수

cout << "과제1 타일맵 그리기" << endl;

cout << "원하는 ? x ? 타일 크기를 지정하세요 : ";

cin >> tile;

for (int i = 0; i < tile; i++) {

for (int j = 0; j < tile; j++) {

cout << "□";

}

cout << endl;

}

do

{

cout << "★로 바꿀 타일의 위치를 지정하세요 ( " << tile << " x " << tile << " ) : ";

scanf("%d %d", &x, &y);

} while ((x < 1 || x > tile) || (y < 1 || y > tile));

//system("cls");

cout << "과제 1 타일맵 그리기" << endl;

for (int i = 1; i <= tile; i++) {

for (int j = 1; j <= tile; j++) {

if (i == x) { // 입력한 x값과 y값을 판별해

if (j == y) { // 해당 조건이 참이면 ★을 출력

cout << "★";

}

else {

cout << "□";

}

}

else {

cout << "□";

}

}

cout << endl;

}

 return 0;

}

ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ


'SGA 스터디 > C++ 코딩' 카테고리의 다른 글

하이 로우 세븐 카드게임 ( High & Low 7 )  (0) 2015.08.11
슬롯머신 게임  (0) 2015.08.11
채팅 대전액션  (0) 2015.08.04
퍼즐 게임  (0) 2015.08.01
야구 게임  (0) 2015.07.31

#include<iostream>

#include<conio.h>

#include<time.h>

#include <fstream>

#include <windows.h>

using namespace std;

int job_choice(); // 직업 선택 함수

void user_skill(int jobSkill); // 직업 스킬 

void player_info(int user);

void enemy_info(int monster);


struct all

{

char *job; // 캐릭터 직업

char *name; // 몬스터이름

int hp; // 체력

int mp; // 마나

char *skill1; // 스킬1

char *skill2; // 스킬2

char *skill3; // 스킬3

};

struct all ability; // 사용자 정보

struct all tribe; // 적 정보


int main(){

// 과제 

// 대전액션 ( 구조체 )

// 내턴, 컴터 턴 돌아가면서 스킬로 상대방 데미지 주기

// 스킬은 3개 ( 내꺼 적꺼 )

// 적은 램덤 스킬사용, 플레이어는 선택

// mp가 있어서 스킬마다 소모되는 mp가 있다.

  // 자체적으로 추가 ( 직업 선택, 몬스터 랜덤 ( 3마리 ), 직업별 스킬 )

srand(time(NULL));

int player, enemy, att, enemySkill;  // 문자 선택 변수, 3가지 적, 선택할 스킬 번호, 적 스킬 번호 

char *job; // 직업을 저장할 문자 변수

player = job_choice();

if (player == 1) { job = "전사"; }

else if (player == 2) { job = "궁수"; }

else { job = "마법사"; }


cout << "당신은 직업은 " << job << " 입니다." << endl;;

cout << "당신이 사용할 스킬은 다음과 같습니다" << endl;

user_skill(player);

player_info(player);

enemy = rand() % 3;

enemy_info(enemy);

cout << "ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ" << endl;

cout << "적이 나타났습니다." << endl;

cout << "상대는 " << tribe.name << " 입니다" << endl;

do 

{

do 

{

cout << ability.job << " HP : " << ability.hp << " / MP : " << ability.mp << endl;

cout << "공격할 스킬을 선택하세요 ( 1 ~ 3 ) : ";

cin >> att;

if (att == 1) { 

cout << tribe.name << "에게 기본 공격을 가했습니다" << endl;

if (ability.job == "전사") tribe.hp -= 50; // 직업별 공격력

if (ability.job == "궁수") tribe.hp -= 70;

if (ability.job == "마법사") tribe.hp -= 100;


if (tribe.hp < 0) tribe.hp = 0;

cout << tribe.name << " HP : " << tribe.hp << " / MP : " << tribe.mp << endl;

break

}else if (att == 2 && ability.mp >= 25) { 

cout << tribe.name << "에게 " << ability.skill2 << "을 가했습니다" << endl;

ability.mp -= 25;

if (ability.mp < 0) ability.mp = 0;

if (ability.job == "전사") tribe.hp -= 100; // 직업별 공격력

if (ability.job == "궁수") tribe.hp -= 150;

if (ability.job == "마법사") tribe.hp -= 200;

if (tribe.hp < 0) tribe.hp = 0;

cout << tribe.name << " HP : " << tribe.hp << " / MP : " << tribe.mp << endl;

break

}

else if (att == 3 && ability.mp >= 50) {

cout << tribe.name << "에게 " << ability.skill3 << "을 가했습니다" << endl;

ability.mp -= 50;

if (ability.mp < 0) ability.mp = 0;

if (ability.job == "전사") tribe.hp -= 200; // 직업별 공격력

if (ability.job == "궁수") tribe.hp -= 300;

if (ability.job == "마법사") tribe.hp -= 400;


if (tribe.hp < 0) tribe.hp = 0;

cout << tribe.name << " HP : " << tribe.hp << " / MP : " << tribe.mp << endl;

break

}

} while (1);


do {

enemySkill = rand() % 3 + 1;

if (enemySkill == 1) {

cout << tribe.name << "가 " << ability.job << "에게 " << tribe.skill1 << " 공격을 가했습니다." << endl;

ability.hp -= 30;

if (ability.hp < 0) ability.hp = 0;

break;

}

else if (enemySkill == 2 && tribe.mp >= 25) {

cout << tribe.name << "가 " << ability.job << "에게 " << tribe.skill2 << " 공격을 가했습니다." << endl;

tribe.mp -= 25;

if (tribe.mp < 0) tribe.mp = 0;

ability.hp -= 50;

if (ability.hp < 0) ability.hp = 0;

break;

}

else if (enemySkill == 3 && tribe.mp >= 50) {

cout << tribe.name << "가 " << ability.job << "에게 " << tribe.skill3 << " 공격을 가했습니다." << endl;

tribe.mp -= 50;

if (tribe.mp < 0) tribe.mp = 0;

ability.hp -= 70;

if (ability.hp < 0) ability.hp = 0;

break;

}


} while (1);

if (ability.hp == 0) break;

if (tribe.hp == 0) break;


} while (ability.hp > 0 || tribe.hp > 0);


if (ability.hp == 0) {

cout << endl;

cout << "ㅡㅡ게임종료ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ" << endl;

cout << ability.job << "가 사망하였습니다. 사냥에 실패하였습니다." << endl;

cout << "ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ" << endl;

}

else if (tribe.hp == 0) {

cout << endl;

cout << "ㅡㅡ게임종료ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ" << endl;

cout << ability.job << "가 " << tribe.name << "를 잡았습니다." << endl;

cout << ability.job << " HP : " << ability.hp << " / MP : " << ability.mp << endl;

cout << "ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ" << endl;

}


return 0;

}


int job_choice() { // 직업 선택 함수

int player; // 직업을 선택할 변수

cout << "대전액션 턴제 게임" << endl;

cout << "플레이할 직업을 선택하세요 ( 1. 전사 / 2. 궁수 / 3. 마법사 ) : ";

cin >> player;

while (player != 1 && player != 2 & player != 3) {

cout << "직업 선택이 잘못됐습니다 ( 1. 전사 / 2. 궁수 / 3. 마법사 ) : ";

cin >> player;

if (player == 1 || player == 2 || player == 3) break;

}

return player;

}


void user_skill(int jobSkill)

{

if (jobSkill == 1) {

cout << "1. 기본 공격 ( 마나 소모 없음 )" << endl;

cout << "2. 대지 강타 ( 마나 25 소모 )" << endl;

cout << "3. 소용돌이 ( 마나 50 소모 )" << endl;

}

else if (jobSkill == 2) {

cout << "1. 기본 공격 ( 마나 소모 없음 )" << endl;

cout << "2. 집중 사격 ( 마나 25 소모 )" << endl;

cout << "3. 달의 섬광 ( 마나 50 소모 )" << endl;

}

else {

cout << "1. 기본 공격 ( 마나 소모 없음 )" << endl;

cout << "2. 불기둥 ( 마나 25 소모 )" << endl;

cout << "3. 불사조 ( 마나 50 소모 )" << endl;

}

}

void player_info(int user) {

if(user == 1){

ability.job = "전사";

ability.hp = 500;

ability.mp = 100;

ability.skill1 = "기본 공격";

ability.skill2 = "대지 강타";

ability.skill3 = "소용돌이";

}

else if (user == 2) {

ability.job = "궁수";

ability.hp = 450;

ability.mp = 100;

ability.skill1 = "기본 공격";

ability.skill2 = "집중 사격";

ability.skill3 = "달의 섬광";

}

else {

ability.job = "마법사";

ability.hp = 400;

ability.mp = 100;

ability.skill1 = "기본 공격";

ability.skill2 = "불기둥";

ability.skill3 = "불사조";

}

}


void enemy_info(int monster) {

if (monster == 1) {

tribe.name = "도살자";

tribe.hp = 800;

tribe.mp = 100;

tribe.skill1 = "힘줄 끊기";

tribe.skill2 = "무자비한 돌진";

tribe.skill3 = "화로구이";

}

else if (monster == 2) {

tribe.name = "누더기";

tribe.hp = 900;

tribe.mp = 100;

tribe.skill1 = "갈고리";

tribe.skill2 = "지면 강타";

tribe.skill3 = "잡아먹기";

}else{

tribe.name = "디아블로";

tribe.hp = 1000;

tribe.mp = 100;

tribe.skill1 = "암흑의 돌진";

tribe.skill2 = "압도";

tribe.skill3 = "종말";

}

}

'SGA 스터디 > C++ 코딩' 카테고리의 다른 글

슬롯머신 게임  (0) 2015.08.11
타일맵 그리기  (0) 2015.08.05
퍼즐 게임  (0) 2015.08.01
야구 게임  (0) 2015.07.31
홀짝 게임  (0) 2015.07.30

+ Recent posts