Cahaya yang menyinari forum [COMICK, MUSIC, GAME, ANIME & COMPUTER] @ Hikari-Community [at] dal.net
 
HomePortalFAQSearchMemberlistUsergroupsRegisterLog in

Share | 
 

 Source Code Game ringan c + +

View previous topic View next topic Go down 
AuthorMessage
ea_ngel
Hikari Master
Hikari Master


Jumlah posting : 657
Reputation : 2
Join date : 2008-04-18

Status
Race: Undead
Class: Magician

PostSubject: Source Code Game ringan c + +   Thu May 01, 2008 1:16 am

Buat kalian yg pingin belajar membuat game kecil-kecilan dari c + +, silakan didownload disini
klik

semoga bermamfaat
Back to top Go down
View user profile
Doniskynet
Hikari Master
Hikari Master


Jumlah posting : 130
Reputation : 0
Join date : 2008-05-13
Lokasi : Skynet Corporation

PostSubject: Re: Source Code Game ringan c + +   Tue May 13, 2008 11:15 pm

tambahin yang mau blajar...

#include <iostream.h>
#include <time.h>
#include <stdlib.h>

int GetCard();
int ConvertAce(int value);
int DealerAI();
void DisplayCards();
void InputChoice();
void InputChoice2();
void Results();
void SorH();
void Continue();

int card1, card2, dealerCV, bet;
int playerCV = 0;
int cash = 500;

void main()
{
srand(time(NULL));
DisplayCards();
}

int GetCard()
{
int x;

x = 1 + rand() % 15;

if (x >= 12)
return 10;
else
return x;

}

int ConvertAce(int value)
{
return 0;
}

void DisplayCards()
{
int flag1, flag2;

playerCV = 0;
flag1 = 0;
flag2 = 0;
card1 = GetCard();
card2 = GetCard();

cout << "Cash: $" << cash << endl << endl;

if (cash <= 0){
cout << "Your bankrupt, GAME OVER!" << endl;
cash = 500;
Continue();
DisplayCards();
}

if (cash >= 10000){
cout << "You Win!" << endl;
cash = 500;
Continue();
DisplayCards();
}

if (card1 == 11){
cout << "Your first card is: " << "ACE";
flag1 = 1;
}
else if (card1 == 1){
cout << "Your first card is: " << "ACE";
flag1 = 1;
}
else
cout << "Your first card is: " << card1;

cout << endl << endl << "Place your bet: $";
cin >> bet;

if (bet > cash){
cout << endl;
cout << "You cannot bet more than you have" << endl;
Continue();
DisplayCards();
}

cout << endl;

if (card2 == 11){
cout << "Your second card is: " << "ACE" << endl;
flag2 = 1;
}
else if (card2 == 1){
cout << "Your second card is: " << "ACE" << endl;
flag2 = 1;
}
else
cout << "Your second card is: " << card2 << endl;

cout << endl;

if (flag1 == 1){
cout << "(Q)First card is 1 | (W)First card is 11" << endl;
InputChoice();
}

if (flag2 == 1){
cout << "(Z)Second card is 1 | (X)Second card is 11" << endl;
InputChoice2();
}

playerCV = card1 + card2;

cout << "Your total card value is " << playerCV << endl;

if (playerCV == 21){
system("CLS");
cout << endl << "BLACKJACK!!!" << endl;
cash = cash + bet * 5;
Continue();
DisplayCards();
}

cout << endl;

SorH();

}

void InputChoice()
{

char choice;
cout << endl;

cin >> choice;

switch (choice) {
case 'q':
card1 = 1;
break;
case 'w':
card1 = 11;
break;
}

}

void InputChoice2()
{

char choice;
cout << endl;

cin >> choice;

switch (choice) {
case 'z':
card2 = 1;
break;
case 'x':
card2 = 11;
break;
}

}


void SorH()
{
char choice;

cout << "(S)stand | (H)hit" << endl;

cout << endl;
cin >> choice;

switch (choice) {
case 'h':
playerCV = playerCV + GetCard();
if (playerCV > 21){
system("CLS");
cout << "Your total card value is " << playerCV << endl;
cout << "You bust" << endl;
cash = cash - bet;
Continue();
DisplayCards();
}
system("CLS");
cout << "Your total card value is " << playerCV << endl << endl;
SorH();
break;
case 's':
system("CLS");
Results();
break;
}

}

void Results()
{
dealerCV = DealerAI();

cout << "Your total card value is " << playerCV << endl;
if (playerCV > 21){
cout << "You bust" << endl;
cash = cash - bet;
Continue();
DisplayCards();
}
else
cout << "Dealer's total card value is " << dealerCV << endl << endl;
if (dealerCV > 21){
cout << "Dealer busts" << endl;
cash = cash + bet;
Continue();
DisplayCards();
}
else {
if (playerCV > dealerCV){
cout << "You win" << endl;
cash = cash + bet;
}
if (playerCV == dealerCV)
cout << "It's a draw" << endl;
if (playerCV < dealerCV){
cout << "You lose" << endl;
cash = cash - bet;
}
Continue();
DisplayCards();
}
}

int DealerAI()
{
int c1, c2, cv, f1, f2;

c1 = GetCard();
c2 = GetCard();

if (c1 == 11)
f1 = 1;

if (c2 == 11)
f2 = 1;

cv = c1 + c2;

while (cv <= 16)
cv = cv + GetCard();

if (cv > 21 & f1 == 1){
while (cv <= 16)
cv = 1 + c2 + GetCard();
}

if (cv > 21 & f2 == 1){
while (cv <= 16)
cv = c1 + 1 + GetCard();
}

return cv;

}

void Continue()
{
char key;
cout << endl;
cout << "Press R then <enter> to restart game" << endl;
cin >> key;
system("CLS");
}

running pake Borland 5.2
Back to top Go down
View user profile
diansari
Hikari Old
Hikari Old


Jumlah posting : 359
Reputation : 0
Join date : 2008-06-24
Age : 28
Lokasi : _gak ada tempat_

Status
Race: Baby
Class: Newbie

PostSubject: Re: Source Code Game ringan c + +   Wed Jun 25, 2008 9:07 pm

sip2..
langsung ke tkp Wink

_________________
Back to top Go down
View user profile http://hikari-community.darkbb.com
animonzterz
Hikari Senior
Hikari Senior


Jumlah posting : 196
Reputation : 0
Join date : 2008-06-21
Lokasi : White House

Status
Race: Human
Class: Merchant

PostSubject: Re: Source Code Game ringan c + +   Fri Jun 27, 2008 6:57 am

@doniskynet

pusing baca codingnya..
But gamenya lumayan asik...
Main Blackjack tanpa kartu Very Happy
thanx bro
Back to top Go down
View user profile
p4j3l
Hikari Newbie
Hikari Newbie


Jumlah posting : 6
Reputation : 0
Join date : 2008-06-25

PostSubject: Re: Source Code Game ringan c + +   Sun Jun 29, 2008 9:45 pm

ud kopy paste entar nyoba bro thanks b4
Back to top Go down
View user profile
exnome
Hikari Senior
Hikari Senior


Jumlah posting : 181
Reputation : 0
Join date : 2008-05-14
Age : 31
Lokasi : Belakang Proxy

Status
Race: Undead
Class: Swordman

PostSubject: Re: Source Code Game ringan c + +   Mon Jun 30, 2008 12:35 am

animonzterz wrote:
@doniskynet

pusing baca codingnya..
But gamenya lumayan asik...
Main Blackjack tanpa kartu Very Happy
thanx bro

g sah psg .... bljar step by step aj omz ....
yg prtma ttg logika dan algoritma pmrograman dlu, ntar bru ke bhs compire ato interpreter ....

affraid affraid
Back to top Go down
View user profile
animonzterz
Hikari Senior
Hikari Senior


Jumlah posting : 196
Reputation : 0
Join date : 2008-06-21
Lokasi : White House

Status
Race: Human
Class: Merchant

PostSubject: Re: Source Code Game ringan c + +   Fri Jul 04, 2008 9:40 pm

Owh gitu ya...
heheehehhe:D:D:D
Back to top Go down
View user profile
Sponsored content




PostSubject: Re: Source Code Game ringan c + +   Today at 11:16 am

Back to top Go down
 
Source Code Game ringan c + +
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» Game PC: Alien Terbaru Gratis
» Game Seru
» Virtual orchestra studio
» LOTUS RELOAD | BUKA PENDAFTARAN MASTER DEALER PULSA ELEKTRIK ALL OPERATOR, PLN PRA BAYAR, GAME VOUCHER
» Game Online Lebih Menarik Daripada Bercinta?

Permissions in this forum:You cannot reply to topics in this forum
Hikari Community :: Special Interest :: Games-
Jump to: