#include "stdafx.h"
#include <stdio.h>
#include "myfunc.h"
#include <random>
using namespace std;
#define MAX 20
int main()
{
// 랜덤수 출력 함수
random_device rn;
mt19937_64 rnd(rn());
uniform_int_distribution<int> range(1, MAX); // 1부터 MAX사이에서 출력한다.
int board[20];
int count = 0;
int bat = 0;
int jackpot = range(rn);
int money = 10000;
int batmoney = 0;
int startflag = 0;
int round = 2;
int vspeed = 0, ballspeed = 0;
for (int i = 0; i < MAX; i++) {
board[i] = i + 1;
}
while (1) {
system("cls");
printf("\n");
setColor(BLACK, YELLOW);
printf(" GOLD : %d", money);
setColor(BLACK, RED);
printf(" R O U L E T T E \n\n");
for (int i = 0; i < MAX; i++) {
if (i % 2 == 0) setColor(RED, WHITE);
else setColor(BLACK, WHITE);
printf(" %02d ", board[i]);
}
printf(" \n");
count++;
if (count >= 20) {
count = 0;
round++;
}
for (int i = 0; i < count; i++) {
printf(" ");
}
printf(" ●");
vspeed++;
ballspeed += vspeed;
Sleep(ballspeed);
if (round == 2) {
if (startflag == 0) {
if (bat == jackpot % 2) {
setColor(BLACK, BLACK);
printf("\n\n ");
setColor(RED, YELLOW);
printf("축하합니다.");
money = money + batmoney;
startflag = 0;
vspeed = 0;
}
else {
setColor(BLACK, BLACK);
printf("\n\n ");
setColor(BLACK, BLUE);
printf("꽝.");
money = money - batmoney;
startflag = 0;
vspeed = 0;
}
setColor(BLACK, WHITE);
printf("\n\n\n\n얼마를 배팅하시겠습니까 ? : ");
scanf_s("%d", &batmoney);
printf("\n\n\n어떤 색에 배팅하시겠습니까 ? (1번 : 빨강색, 2번 : 검정색) : ");
scanf_s("%d", &bat);
startflag = 1;
round = 0;
}
startflag = 0;
}
}
return 0;
}
// 내가 만든 소스
==========================================================================
// 교수님이 만든 소스
#include "pch.h"
#include "myFunc.h"
#include <random>
#define MAX 20
using namespace std;
int main()
{
random_device rn;
mt19937_64 rnd(rn());
uniform_int_distribution<int> range(350, 550);
int board[MAX], loc = 0, ani_color = 0;
int startFlag = 0;
int gold = 10000, bet = 0, color = 0;
int ballSpeed = 0, vspeed = 0;
for (int i = 0; i < MAX; i++) board[i] = i + 1;
while (1)
{
ani_color++;
if (ani_color > 15) ani_color = 0;
system("cls");
printf("\n");
printf("\t\t\t\t\t\t\t\t\t\t\t\t\t GOLD : ");
setColor(BLACK, YELLOW);
printf("%d\n", gold);
setColor(BLACK, ani_color);
printf("\t\t\t\t\t\tR O U L E T T E\n\n");
setColor(BLACK, WHITE);
for (int i = 0; i < MAX; i++)
{
if (i % 2 == 0) setColor(RED, WHITE);
else setColor(BLACK, WHITE);
printf(" %02d ", board[i]);
}
setColor(BLACK, WHITE);
printf("\n\n");
// 怨듦뎬由ш린
loc++;
if (loc >= MAX) loc = 0;
for (int i = 0; i < loc; i++) printf(" ");
printf(" �뿈\n");
printf(" \n\n Ball Speed : %d\n", ballSpeed);
// 踰좏똿 臾쇱뼱蹂닿린
if (startFlag == 0)
{
if (ballSpeed != 0)
{
//printf("loc : %d\n", loc);
setColor(BLACK, YELLOW);
if (color == 1 && loc % 2 == 0)
{
printf("\n\n\n\t\t\t\t\t�떦�떊�쓽 �듅由?n");
gold += bet;
}
else if (color == 1 && loc % 2 == 1)
{
printf("\n\n\n\t\t\t\t\t�떦�떊�쓽 �뙣諛?n");
gold -= bet;
}
else if (color == 2 && loc % 2 == 0)
{
printf("\n\n\n\t\t\t\t\t�떦�떊�쓽 �뙣諛?n");
gold -= bet;
}
else if (color == 2 && loc % 2 == 1)
{
printf("\n\n\n\t\t\t\t\t�떦�떊�쓽 �듅由?n");
gold += bet;
}
vspeed = ballSpeed = bet = color = 0;
setColor(BLACK, WHITE);
}
startFlag = 1;
}
else if (startFlag == 1)
{
printf("\n\n\n\t\t\t\t\t�뼹留덈? 嫄곗떆寃좎뒿�땲源�? : ");
scanf_s("%d", &bet);
printf("\n\t\t\t\t\t�뼱�뒓 �깋�뿉 嫄곗떆寃좎뒿�땲源�? (1:鍮④컯, 2:寃��젙) :");
scanf_s("%d", &color);
startFlag = 2;
}
vspeed++;
ballSpeed += vspeed;
Sleep(ballSpeed);
if (ballSpeed > range(rn)) startFlag = 0;
}
=================================================================
//UTP - 8 로 변환
#include "pch.h"
#include "myFunc.h"
#include <random>
#define MAX 20
using namespace std;
int main()
{
random_device rn;
mt19937_64 rnd(rn());
uniform_int_distribution<int> range(350, 550);
int board[MAX], loc = 0, ani_color = 0;
int startFlag = 0;
int gold = 10000, bet = 0, color = 0;
int ballSpeed = 0, vspeed = 0;
for (int i = 0; i < MAX; i++) board[i] = i + 1;
while (1)
{
ani_color++;
if (ani_color > 15) ani_color = 0;
system("cls");
printf("\n");
printf("\t\t\t\t\t\t\t\t\t\t\t\t\t GOLD : ");
setColor(BLACK, YELLOW);
printf("%d\n", gold);
setColor(BLACK, ani_color);
printf("\t\t\t\t\t\tR O U L E T T E\n\n");
setColor(BLACK, WHITE);
for (int i = 0; i < MAX; i++)
{
if (i % 2 == 0) setColor(RED, WHITE);
else setColor(BLACK, WHITE);
printf(" %02d ", board[i]);
}
setColor(BLACK, WHITE);
printf("\n\n");
// 공굴리기
loc++;
if (loc >= MAX) loc = 0;
for (int i = 0; i < loc; i++) printf(" ");
printf(" ●\n");
printf(" \n\n Ball Speed : %d\n", ballSpeed);
// 베팅 물어보기
if (startFlag == 0)
{
if (ballSpeed != 0)
{
//printf("loc : %d\n", loc);
setColor(BLACK, YELLOW);
if (color == 1 && loc % 2 == 0)
{
printf("\n\n\n\t\t\t\t\t당신의 승리\n");
gold += bet;
}
else if (color == 1 && loc % 2 == 1)
{
printf("\n\n\n\t\t\t\t\t당신의 패배\n");
gold -= bet;
}
else if (color == 2 && loc % 2 == 0)
{
printf("\n\n\n\t\t\t\t\t당신의 패배\n");
gold -= bet;
}
else if (color == 2 && loc % 2 == 1)
{
printf("\n\n\n\t\t\t\t\t당신의 승리\n");
gold += bet;
}
vspeed = ballSpeed = bet = color = 0;
setColor(BLACK, WHITE);
}
startFlag = 1;
}
else if (startFlag == 1)
{
printf("\n\n\n\t\t\t\t\t얼마를 거시겠습니까? : ");
scanf_s("%d", &bet);
printf("\n\t\t\t\t\t어느 색에 거시겠습니까? (1:빨강, 2:검정) :");
scanf_s("%d", &color);
startFlag = 2;
}
vspeed++;
ballSpeed += vspeed;
Sleep(ballSpeed);
if (ballSpeed > range(rn)) startFlag = 0;
}
'Study > C' 카테고리의 다른 글
C언어 - 포인터 2 (0) | 2018.08.28 |
---|---|
C언어 - 포인터 (0) | 2018.08.28 |
C언어 - Rullet 게임만들기 (0) | 2018.08.27 |
C언어 - 난수 발생함수(random함수) (0) | 2018.08.27 |
C언어 - 문자열 (계산기 만들기(Atoi함수사용)) (0) | 2018.08.27 |