Hikari Community
Would you like to react to this message? Create an account in a few clicks or log in to continue.


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

 

 Source Code Game ringan c + +

Go down 
+2
Doniskynet
ea_ngel
6 posters
AuthorMessage
ea_ngel
Hikari Master
Hikari Master
ea_ngel


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

Status
Race: Undead
Class: Magician

Source Code Game ringan c + + Empty
PostSubject: Source Code Game ringan c + +   Source Code Game ringan c + + EmptyThu 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
Doniskynet
Hikari Master
Hikari Master
Doniskynet


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

Source Code Game ringan c + + Empty
PostSubject: Re: Source Code Game ringan c + +   Source Code Game ringan c + + EmptyTue 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
diansari
Hikari Old
Hikari Old
diansari


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

Status
Race: Baby
Class: Newbie

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

sip2..
langsung ke tkp Wink
Back to top Go down
https://hikari-community.indonesianforum.net
animonzterz
Hikari Senior
Hikari Senior
animonzterz


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

Status
Race: Human
Class: Merchant

Source Code Game ringan c + + Empty
PostSubject: Re: Source Code Game ringan c + +   Source Code Game ringan c + + EmptyFri 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
p4j3l
Hikari Newbie
Hikari Newbie



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

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

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


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

Status
Race: Undead
Class: Swordman

Source Code Game ringan c + + Empty
PostSubject: Re: Source Code Game ringan c + +   Source Code Game ringan c + + EmptyMon 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
animonzterz
Hikari Senior
Hikari Senior
animonzterz


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

Status
Race: Human
Class: Merchant

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

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





Source Code Game ringan c + + Empty
PostSubject: Re: Source Code Game ringan c + +   Source Code Game ringan c + + Empty

Back to top Go down
 
Source Code Game ringan c + +
Back to top 
Page 1 of 1
 Similar topics
-
» Source Code Virus .vbs
» Cheat Code Game
» css with js code
» New Image Code- CSS
» Code Seal ^^

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