Minggu, 29 April 2012

Program C++ dengan GUI

Pada kesempatan kali ini, saya akan menampilkan program yang saya buat yaitu Permainan Game Suit dengan Menggunakan Microsoft Visual Studio C++ 2010 berbasis GUI (Graphical User Interface).
Inilah coding pada pembuatan programnya.

#pragma once
#include <time.h>
//#include <string>
#include "AboutGame.h"
#include "copyright.h"
namespace GameSuitAdic {

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;

/// <summary>
/// Summary for MulaiGame
/// </summary>

public ref class MulaiGame : public System::Windows::Forms::Form
{

static int pointanda=0;
static int pointcomp=0;
static int Second = 0;
static int Minute = 0;
String^ Sec;
String^ nama;


private: System::Windows::Forms::Label^  label5;
private: System::Windows::Forms::Label^  lblNilaiAnda;
private: System::Windows::Forms::Label^  lblNilaiComp;
private: System::Windows::Forms::Label^  label6;
private: System::Windows::Forms::DateTimePicker^  dateTimePicker1;
private: System::Windows::Forms::Button^  button3;
private: System::Windows::Forms::LinkLabel^  linkLabel1;
private: System::Windows::Forms::LinkLabel^  linkLabel2;
private: AxWMPLib::AxWindowsMediaPlayer^  axWindowsMediaPlayer1;
private: System::Windows::Forms::Timer^  timer1;
String^ Min;
public:
MulaiGame(String^ x)
{
nama=x;
InitializeComponent();
//
//TODO: Add the constructor code here
//

}

protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~MulaiGame()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::PictureBox^  pictureBox1;
protected:
private: System::Windows::Forms::PictureBox^  pictureBox2;
private: System::Windows::Forms::PictureBox^  pictureBox3;
private: System::Windows::Forms::PictureBox^  pictureBox4;
private: System::Windows::Forms::PictureBox^  pictureBox5;
private: System::Windows::Forms::PictureBox^  pictureBox6;
private: System::Windows::Forms::Label^  label1;


private: System::Windows::Forms::Label^  label2;
private: System::Windows::Forms::Label^  label3;
private: System::Windows::Forms::Label^  label4;
private: System::Windows::Forms::Button^  button1;

private: System::Windows::Forms::Timer^  Timer;
private: System::Windows::Forms::Label^  Time;

private: System::ComponentModel::IContainer^  components;


protected:

private:
/// <summary>
/// Required designer variable.
/// </summary>


#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->components = (gcnew System::ComponentModel::Container());
System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(MulaiGame::typeid));
this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
this->pictureBox2 = (gcnew System::Windows::Forms::PictureBox());
this->pictureBox3 = (gcnew System::Windows::Forms::PictureBox());
this->pictureBox4 = (gcnew System::Windows::Forms::PictureBox());
this->pictureBox5 = (gcnew System::Windows::Forms::PictureBox());
this->pictureBox6 = (gcnew System::Windows::Forms::PictureBox());
this->label1 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->label3 = (gcnew System::Windows::Forms::Label());
this->label4 = (gcnew System::Windows::Forms::Label());
this->button1 = (gcnew System::Windows::Forms::Button());
this->Timer = (gcnew System::Windows::Forms::Timer(this->components));
this->Time = (gcnew System::Windows::Forms::Label());
this->label5 = (gcnew System::Windows::Forms::Label());
this->lblNilaiAnda = (gcnew System::Windows::Forms::Label());
this->lblNilaiComp = (gcnew System::Windows::Forms::Label());
this->label6 = (gcnew System::Windows::Forms::Label());
this->dateTimePicker1 = (gcnew System::Windows::Forms::DateTimePicker());
this->button3 = (gcnew System::Windows::Forms::Button());
this->linkLabel1 = (gcnew System::Windows::Forms::LinkLabel());
this->linkLabel2 = (gcnew System::Windows::Forms::LinkLabel());
this->axWindowsMediaPlayer1 = (gcnew AxWMPLib::AxWindowsMediaPlayer());
this->timer1 = (gcnew System::Windows::Forms::Timer(this->components));
(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox1))->BeginInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox2))->BeginInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox3))->BeginInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox4))->BeginInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox5))->BeginInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox6))->BeginInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->axWindowsMediaPlayer1))->BeginInit();
this->SuspendLayout();
//
// pictureBox1
//
this->pictureBox1->BackColor = System::Drawing::Color::Transparent;
this->pictureBox1->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"pictureBox1.Image")));
this->pictureBox1->Location = System::Drawing::Point(28, 51);
this->pictureBox1->Name = L"pictureBox1";
this->pictureBox1->Size = System::Drawing::Size(100, 103);
this->pictureBox1->TabIndex = 0;
this->pictureBox1->TabStop = false;
this->pictureBox1->Click += gcnew System::EventHandler(this, &MulaiGame::pictureBox1_Click);
this->pictureBox1->MouseClick += gcnew System::Windows::Forms::MouseEventHandler(this, &MulaiGame::pictureBox1_MouseClick);
//
// pictureBox2
//
this->pictureBox2->BackColor = System::Drawing::Color::Transparent;
this->pictureBox2->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"pictureBox2.Image")));
this->pictureBox2->Location = System::Drawing::Point(28, 151);
this->pictureBox2->Name = L"pictureBox2";
this->pictureBox2->Size = System::Drawing::Size(100, 101);
this->pictureBox2->TabIndex = 1;
this->pictureBox2->TabStop = false;
this->pictureBox2->Click += gcnew System::EventHandler(this, &MulaiGame::pictureBox2_Click);
this->pictureBox2->MouseClick += gcnew System::Windows::Forms::MouseEventHandler(this, &MulaiGame::pictureBox2_MouseClick);
//
// pictureBox3
//
this->pictureBox3->BackColor = System::Drawing::Color::Transparent;
this->pictureBox3->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"pictureBox3.Image")));
this->pictureBox3->Location = System::Drawing::Point(28, 248);
this->pictureBox3->Name = L"pictureBox3";
this->pictureBox3->Size = System::Drawing::Size(100, 97);
this->pictureBox3->TabIndex = 2;
this->pictureBox3->TabStop = false;
this->pictureBox3->Click += gcnew System::EventHandler(this, &MulaiGame::pictureBox3_Click);
//
// pictureBox4
//
this->pictureBox4->BackColor = System::Drawing::Color::Transparent;
this->pictureBox4->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"pictureBox4.Image")));
this->pictureBox4->Location = System::Drawing::Point(461, 51);
this->pictureBox4->Name = L"pictureBox4";
this->pictureBox4->Size = System::Drawing::Size(100, 103);
this->pictureBox4->TabIndex = 3;
this->pictureBox4->TabStop = false;
this->pictureBox4->Click += gcnew System::EventHandler(this, &MulaiGame::pictureBox4_Click);
this->pictureBox4->MouseClick += gcnew System::Windows::Forms::MouseEventHandler(this, &MulaiGame::pictureBox4_MouseClick);
//
// pictureBox5
//
this->pictureBox5->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"pictureBox5.Image")));
this->pictureBox5->Location = System::Drawing::Point(461, 151);
this->pictureBox5->Name = L"pictureBox5";
this->pictureBox5->Size = System::Drawing::Size(100, 101);
this->pictureBox5->TabIndex = 4;
this->pictureBox5->TabStop = false;
this->pictureBox5->Click += gcnew System::EventHandler(this, &MulaiGame::pictureBox5_Click);
//
// pictureBox6
//
this->pictureBox6->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
this->pictureBox6->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"pictureBox6.Image")));
this->pictureBox6->Location = System::Drawing::Point(461, 248);
this->pictureBox6->Name = L"pictureBox6";
this->pictureBox6->Size = System::Drawing::Size(100, 96);
this->pictureBox6->TabIndex = 5;
this->pictureBox6->TabStop = false;
this->pictureBox6->Click += gcnew System::EventHandler(this, &MulaiGame::pictureBox6_Click);
//
// label1
//
this->label1->AutoSize = true;
this->label1->Font = (gcnew System::Drawing::Font(L"Courier New", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label1->Location = System::Drawing::Point(179, 27);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(0, 22);
this->label1->TabIndex = 6;
this->label1->Text =nama;
this->label1->Click += gcnew System::EventHandler(this, &MulaiGame::label1_Click);
//
// label2
//
this->label2->AutoSize = true;
this->label2->Font = (gcnew System::Drawing::Font(L"Courier New", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label2->Location = System::Drawing::Point(273, 27);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(32, 22);
this->label2->TabIndex = 7;
this->label2->Text = L"VS";
//
// label3
//
this->label3->AutoSize = true;
this->label3->Font = (gcnew System::Drawing::Font(L"Courier New", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label3->Location = System::Drawing::Point(362, 27);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(54, 22);
this->label3->TabIndex = 8;
this->label3->Text = L"COMP";
//
// label4
//
this->label4->AutoSize = true;
this->label4->Font = (gcnew System::Drawing::Font(L"Courier New", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label4->Location = System::Drawing::Point(251, 286);
this->label4->Name = L"label4";
this->label4->Size = System::Drawing::Size(65, 22);
this->label4->TabIndex = 9;
this->label4->Text = L"HASIL";
this->label4->Click += gcnew System::EventHandler(this, &MulaiGame::label4_Click);
//
// button1
//
this->button1->Font = (gcnew System::Drawing::Font(L"Courier New", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->button1->Location = System::Drawing::Point(177, 310);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(97, 35);
this->button1->TabIndex = 10;
this->button1->Text = L"LANJUT";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &MulaiGame::button1_Click);
//
// Timer
//
this->Timer->Enabled = true;
this->Timer->Interval = 1000;
this->Timer->Tick += gcnew System::EventHandler(this, &MulaiGame::timer1_Tick);
//
// Time
//
this->Time->AutoSize = true;
this->Time->Font = (gcnew System::Drawing::Font(L"Courier New", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->Time->Location = System::Drawing::Point(461, 13);
this->Time->Name = L"Time";
this->Time->Size = System::Drawing::Size(65, 22);
this->Time->TabIndex = 12;
this->Time->Text = L"0 : 0";
this->Time->TextAlign = System::Drawing::ContentAlignment::TopCenter;
this->Time->Click += gcnew System::EventHandler(this, &MulaiGame::Time_Click);
//
// label5
//
this->label5->AutoSize = true;
this->label5->Location = System::Drawing::Point(274, 248);
this->label5->Name = L"label5";
this->label5->Size = System::Drawing::Size(0, 13);
this->label5->TabIndex = 13;
//
// lblNilaiAnda
//
this->lblNilaiAnda->AutoSize = true;
this->lblNilaiAnda->Font = (gcnew System::Drawing::Font(L"Courier New", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->lblNilaiAnda->Location = System::Drawing::Point(189, 66);
this->lblNilaiAnda->Name = L"lblNilaiAnda";
this->lblNilaiAnda->Size = System::Drawing::Size(21, 22);
this->lblNilaiAnda->TabIndex = 14;
this->lblNilaiAnda->Text = L"0";
this->lblNilaiAnda->Click += gcnew System::EventHandler(this, &MulaiGame::lblNilaiAnda_Click);
//
// lblNilaiComp
//
this->lblNilaiComp->AutoSize = true;
this->lblNilaiComp->Font = (gcnew System::Drawing::Font(L"Courier New", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->lblNilaiComp->Location = System::Drawing::Point(366, 66);
this->lblNilaiComp->Name = L"lblNilaiComp";
this->lblNilaiComp->Size = System::Drawing::Size(21, 22);
this->lblNilaiComp->TabIndex = 15;
this->lblNilaiComp->Text = L"0";
//
// label6
//
this->label6->AutoSize = true;
this->label6->Font = (gcnew System::Drawing::Font(L"Courier New", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label6->Location = System::Drawing::Point(24, 5);
this->label6->Name = L"label6";
this->label6->Size = System::Drawing::Size(76, 22);
this->label6->TabIndex = 16;
this->label6->Text = L"label6";
this->label6->Click += gcnew System::EventHandler(this, &MulaiGame::label6_Click);
//
// dateTimePicker1
//
this->dateTimePicker1->CalendarFont = (gcnew System::Drawing::Font(L"Courier New", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->dateTimePicker1->Location = System::Drawing::Point(225, 5);
this->dateTimePicker1->Name = L"dateTimePicker1";
this->dateTimePicker1->Size = System::Drawing::Size(200, 20);
this->dateTimePicker1->TabIndex = 17;
//
// button3
//
this->button3->Font = (gcnew System::Drawing::Font(L"Courier New", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->button3->Location = System::Drawing::Point(309, 310);
this->button3->Name = L"button3";
this->button3->Size = System::Drawing::Size(87, 34);
this->button3->TabIndex = 18;
this->button3->Text = L"EXIT";
this->button3->UseVisualStyleBackColor = true;
this->button3->Click += gcnew System::EventHandler(this, &MulaiGame::button3_Click);
//
// linkLabel1
//
this->linkLabel1->AutoSize = true;
this->linkLabel1->Location = System::Drawing::Point(522, 352);
this->linkLabel1->Name = L"linkLabel1";
this->linkLabel1->Size = System::Drawing::Size(63, 13);
this->linkLabel1->TabIndex = 19;
this->linkLabel1->TabStop = true;
this->linkLabel1->Text = L"AboutGame";
this->linkLabel1->LinkClicked += gcnew System::Windows::Forms::LinkLabelLinkClickedEventHandler(this, &MulaiGame::linkLabel1_LinkClicked);
//
// linkLabel2
//
this->linkLabel2->AutoSize = true;
this->linkLabel2->Location = System::Drawing::Point(28, 352);
this->linkLabel2->Name = L"linkLabel2";
this->linkLabel2->Size = System::Drawing::Size(151, 13);
this->linkLabel2->TabIndex = 20;
this->linkLabel2->TabStop = true;
this->linkLabel2->Text = L"©copyright by Adic Komalasari";
this->linkLabel2->LinkClicked += gcnew System::Windows::Forms::LinkLabelLinkClickedEventHandler(this, &MulaiGame::linkLabel2_LinkClicked);
//
// axWindowsMediaPlayer1
//
this->axWindowsMediaPlayer1->Enabled = true;
this->axWindowsMediaPlayer1->Location = System::Drawing::Point(402, 299);
this->axWindowsMediaPlayer1->Name = L"axWindowsMediaPlayer1";
this->axWindowsMediaPlayer1->OcxState = (cli::safe_cast<System::Windows::Forms::AxHost::State^  >(resources->GetObject(L"axWindowsMediaPlayer1.OcxState")));
this->axWindowsMediaPlayer1->Size = System::Drawing::Size(75, 66);
this->axWindowsMediaPlayer1->TabIndex = 21;
this->axWindowsMediaPlayer1->Visible = false;
this->axWindowsMediaPlayer1->Enter += gcnew System::EventHandler(this, &MulaiGame::axWindowsMediaPlayer1_Enter);
//
// timer1
//
this->timer1->Enabled = true;
this->timer1->Interval = 1000;
this->timer1->Tick += gcnew System::EventHandler(this, &MulaiGame::timer1_Tick_1);
//
// MulaiGame
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->BackColor = System::Drawing::Color::White;
this->BackgroundImage = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"$this.BackgroundImage")));
this->ClientSize = System::Drawing::Size(602, 376);
this->Controls->Add(this->axWindowsMediaPlayer1);
this->Controls->Add(this->linkLabel2);
this->Controls->Add(this->linkLabel1);
this->Controls->Add(this->button3);
this->Controls->Add(this->dateTimePicker1);
this->Controls->Add(this->label6);
this->Controls->Add(this->lblNilaiComp);
this->Controls->Add(this->lblNilaiAnda);
this->Controls->Add(this->label5);
this->Controls->Add(this->Time);
this->Controls->Add(this->button1);
this->Controls->Add(this->label4);
this->Controls->Add(this->label3);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Controls->Add(this->pictureBox6);
this->Controls->Add(this->pictureBox5);
this->Controls->Add(this->pictureBox4);
this->Controls->Add(this->pictureBox3);
this->Controls->Add(this->pictureBox2);
this->Controls->Add(this->pictureBox1);
this->Name = L"MulaiGame";
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
this->Text = L"MulaiGame";
this->Load += gcnew System::EventHandler(this, &MulaiGame::MulaiGame_Load);
(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox1))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox2))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox3))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox4))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox5))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox6))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->axWindowsMediaPlayer1))->EndInit();
this->ResumeLayout(false);
this->PerformLayout();

}

#pragma endregion

// static System::Windows::Forms::timer1^ myTimer = gcnew System::Windows::Forms::timer1;
private: System::Void pictureBox6_Click(System::Object^  sender, System::EventArgs^  e) {


}
private: System::Void pictureBox1_Click(System::Object^  sender, System::EventArgs^  e) {
this->pictureBox1->Location = System::Drawing::Point(189, 138);
int i=0;
Random^ r = gcnew Random();
i=r->Next(3);
if(i==0){
this->pictureBox4->Location = System::Drawing::Point(295, 138);
label4->Text="SERI";
}
else if (i==1){
this->pictureBox5->Location = System::Drawing::Point(295, 140);
label4->Text="MENANG";
pointanda+=10;
}
else if (i==2){
this->pictureBox6->Location = System::Drawing::Point(295, 138);
label4->Text="KALAH";
pointcomp+=10;
}
lblNilaiAnda->Text=System::Convert::ToString(pointanda);
lblNilaiComp->Text=System::Convert::ToString(pointcomp);
if(pointanda == 50){
MessageBox::Show("SELAMAT ANDA MENANG !");

}
if(pointcomp == 50){
MessageBox::Show("MAAF ANDA KALAH !");
}

}
private: System::Void MulaiGame_Load(System::Object^  sender, System::EventArgs^  e) {

}
private: System::Void pictureBox2_Click(System::Object^  sender, System::EventArgs^  e) {
this->pictureBox2->Location = System::Drawing::Point(194, 141);
int i=0;
Random^ r = gcnew Random();
i=r->Next(3);
if(i==0){
this->pictureBox4->Location = System::Drawing::Point(295, 138);
label4->Text="KALAH";
pointcomp+=10;
}
else if (i==1){
this->pictureBox5->Location = System::Drawing::Point(295, 140);
label4->Text="SERI";

}
else if (i==2){
this->pictureBox6->Location = System::Drawing::Point(295, 138);
label4->Text="MENANG";
pointanda+=10;
}
lblNilaiAnda->Text=System::Convert::ToString(pointanda);
lblNilaiComp->Text=System::Convert::ToString(pointcomp);
if(pointanda == 50){
MessageBox::Show("SELAMAT, ANDA MENANG");

}
if(pointcomp == 50){
MessageBox::Show("MAAF, ANDA KALAH !");
}
}
private: System::Void pictureBox3_Click(System::Object^  sender, System::EventArgs^  e) {
this->pictureBox3->Location = System::Drawing::Point(194, 138);
int i=0;
Random^ r = gcnew Random();
i=r->Next(3);
if(i==0){
this->pictureBox4->Location = System::Drawing::Point(295, 138);
label4->Text="MENANG";
pointanda+=10;
}
else if (i==1){
this->pictureBox5->Location = System::Drawing::Point(295, 140);
label4->Text="KALAH";
pointcomp+=10;

}
else if (i==2){
this->pictureBox6->Location = System::Drawing::Point(295, 138);
label4->Text="SERI";

}
lblNilaiAnda->Text=System::Convert::ToString(pointanda);
lblNilaiComp->Text=System::Convert::ToString(pointcomp);
if(pointanda == 50){
MessageBox::Show("SELAMAT, ANDA MENANG");

}
if(pointcomp == 50){
MessageBox::Show("MAAF, ANDA KALAH !");
}
}
private: System::Void pictureBox4_Click(System::Object^  sender, System::EventArgs^  e) {
}
private: System::Void pictureBox5_Click(System::Object^  sender, System::EventArgs^  e) {

}
private: System::Void pictureBox1_MouseClick(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) {

}
private: System::Void pictureBox4_MouseClick(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) {
}
private: System::Void pictureBox2_MouseClick(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) {
}
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
this->pictureBox1->Location = System::Drawing::Point(28, 51);
this->pictureBox2->Location = System::Drawing::Point(28, 151);
this->pictureBox3->Location = System::Drawing::Point(28, 248);
this->pictureBox4->Location = System::Drawing::Point(461, 51);
this->pictureBox5->Location = System::Drawing::Point(461, 151);
this->pictureBox6->Location = System::Drawing::Point(461, 248);
label4->Text="";
}
private: System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e) {

 time_t rawtime;
struct tm * timeinfo;

char j,m,d;
time(&rawtime);
timeinfo=localtime(&rawtime);
j=timeinfo->tm_hour;
m=timeinfo->tm_min;
d=timeinfo->tm_sec;

label6->Text=j.ToString() + " : "+m.ToString() + " : "+d.ToString();

}
private: System::Void Time_Click(System::Object^  sender, System::EventArgs^  e) {

}
private: System::Void label1_Click(System::Object^  sender, System::EventArgs^  e) {
}
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
}
private: System::Void lblNilaiAnda_Click(System::Object^  sender, System::EventArgs^  e) {

}
private: System::Void label6_Click(System::Object^  sender, System::EventArgs^  e) {
}
private: System::Void button3_Click(System::Object^  sender, System::EventArgs^  e) {
Application::Exit();
}
private: System::Void linkLabel1_LinkClicked(System::Object^  sender, System::Windows::Forms::LinkLabelLinkClickedEventArgs^  e) {
AboutGame ^ form = gcnew AboutGame;
form->Show();
}
private: System::Void linkLabel2_LinkClicked(System::Object^  sender, System::Windows::Forms::LinkLabelLinkClickedEventArgs^  e) {
copyright ^ form = gcnew copyright;
form->Show();

}
private: System::Void axWindowsMediaPlayer1_Enter(System::Object^  sender, System::EventArgs^  e) {

}
private: System::Void label4_Click(System::Object^  sender, System::EventArgs^  e) {
}

private: System::Void timer1_Tick_1(System::Object^  sender, System::EventArgs^  e) {
Second++;
if(Second == 60)
{
Second = 0;
Minute++;
}

if (Second==20){
timer1->Enabled=false;
MessageBox::Show("GAME OVER.....!!!!!!!!!");

}

Sec = Convert::ToString(Second);
Min = Convert::ToString(Minute);
Time->Text = Min + ":" + Sec;

}
};
}
 dan Hasil Programnya 

Senin, 16 April 2012

Kumpulan Materi Teknik Media Digital: Proses Pemrograman Dalam Komputer IAS

Kumpulan Materi Teknik Media Digital: Proses Pemrograman Dalam Komputer IAS: Pada postingan blog saya kali ini akan membahas tentang Proses Pemrograman dalam Komputer IAS, Terlebih dahulu saya akan menjelaskan apa itu...

Proses Pemrograman Dalam Komputer IAS

Pada postingan blog saya kali ini akan membahas tentang Proses Pemrograman dalam Komputer IAS, Terlebih dahulu saya akan menjelaskan apa itu yang dimaksud dengan komputer IAS. Komputer IAS termasuk perkembangan komputer generasi pertama yang dimulai pada tahun 1946, yang struktur dan fungsinya dirancang oleh John Von Neumann dan berkonsep komputer stored program pertama.
Untuk mengenal lebih jauh lagi tentang komputer IAS, maka pada kesempatan kali ini saya akan mencontohkan studi kasus pemrograman pada komputer IAS di bawah ini.

Buat program pada komputer IAS sebagai berikut, kemudian simpan program tersebut di memory.
Kalikan data di memory alamat 0551 dengan data di memory alamat 0552.
Simpan hasil perkalian tersebut di memory (MSB di alamat 0556 dan LSB di alamat 0557).
Jumlahkan data LSB hasil perkalian tersebut dengan isi memory alamat 0553.
Simpan hasil penjumlahan tersebut di alamat 0559.
Program Counter(PC) awal terdapat pada alamat 0011.

Penyelesaian :

LOAD MQ, M (0531)
MUL M (0552)
STOR M (0556)
LOAD MQ
STOR M (0557)
ADD M (0553)
STOR M (0559)

Pada komputer IAS terdapat dua langkah pengolahan instruksi yaitu fetch dan execute.
Fetch yaitu prosesor membaca instruksi dari memory, satu persatu setiap waktu.
Execute yaitu mengeksekusi setiap instruksinya.
Untuk lebih memahami ilustrasi dari soal di atas, maka saya menggambarkan isi memory dimana program dan data diletakkan. Alamat memory terbagi menjadi 2 yaitu tempat untuk menyimpan memory dan tempat untuk menyimpan program. Berikut ini adalah gambar isi memory nya.



Langkah awal .

1. Fetch 1
PC = 0011
PC (Program Counter) --> 0011
PC -->MAR  ==>MAR = PC = 0011 (Alamat PC disalin ke MAR)
M(MAR) --> MBR (Memory Buffer Register diisi dengan alamat memory M(0011)).
MBR (20 : 39) --> IBR (Menyalin isi MBR (20 : 39) ke Instruction Buffer Register)
MBR (0 : 19) --> IR (Menyalin isi MBR (0 : 19) ke Instruction Register)
MBR (8 : 19) -->MAR (Menyalin isi Memory MBR (8 : 19) ke Address Register)

2. Execute 1
MQ, M (0551) --> MBR M (0551)-->A (Menerima data dari alamat memory M(0551) ke A)
MBR --> MQ = MQ = A (MBR menyimpan data ke MQ = A)

3. Fetch 2
IBR (0 : 7) --> IR = IR  (Menyalin isi IBR (0 : 7) ke IR)
IBR (8 : 19) --> MAR = MAR = M (0552) (Menyalin isi IBR (8 : 19) ke MAR )
PC = PC + 1 (Untuk pindah ke alamat program berikutnya jadi Program Counter ditambah 1)

4. Execute 2
M (0552) --> MBR (Menyalin M(0552)disimpan di MBR)
MBR * MQ --> MQ LSB, AC = MSB (Melakukan proses perkalian dan hasilnya disimpan ke Register MQ untuk LSB dan Register AC untuk MSB)  [MSB yang paling kiri, LSB yang paling kanan]

5. Fetch 3
PC (Program Counter)= 0012
PC --> MAR , MAR = PC = 0012 (Alamat memory 0011 disalin ke MAR sehingga MAR=PC=0012)
M (MAR) -->MBR , MBR M (0012) (Menyalin MAR ke MBR M (0012) )
MBR (20 : 39) ==> IBR (Menyalin isi MBR (20 : 39) ke IBR)
MBR (0 : 19) ==> IR (Menyalin isi MBR (0 : 19) ke IR)
MBR (8 : 19) ==> MAR (Menyalin isi MBR (8 : 19) ke MAR )

6. Execute 3
MBR --> AC (MBR menerima data-data dari Register AC)
M (MAR) = MBR (MBR Menyimpan data-data ke alamat M (MAR)).

Pada penjelasan proses pemrograman Komputer IAS ini, saya melakukan eksekusi hingga sampai Instruction Set yang ke 3, Dan sampai sejauh ini pada Instruction Set Fetch dan Execute ini sudah menggambarkan bagaimana cara kerja dari program di dalam komputer IAS tersebut.
Demikianlah penjelasan dari proses program komputer IAS ini, semoga bermanfaat bagi semua.



Minggu, 15 April 2012

5 Lapisan Protokol TCP/IP dan fungsinya:

1. Physical Layer
Merupakan lapisan terbawah yang mendefinisikan besaran fisik seperti media komunikasi, dll. Lapisan ini fleksibel sesuai dengan media komunikasi yang digunakan.
2. Network Access Layer
Berfungsi mengatur penyaluran data pada media fisik yang digunakan. Lapisan ini memberikan layanan dan koreksi terhadap kesalahan data yang ditransmisikan.
3. Internet Layer
Berfungsi mendefinisikan bagaimana hubungan antara dua pihak dapat terjadi pada suatu jaringan. Pada jaringan internet, lapisan ini bertugas untuk memastikan agar semua paket data yang dikirimkan dapat sampai di tujuannya masing-masing.
4. Transport Layer
Berfungsi mendefinisikan cara-cara untuk melakukan pengiriman data antara end to end host. Lapisan ini menjamin bahwa informasi yang diterima oleh penerima adalah sama dengan informasi yang dikirim oleh pengirim.
5. Application Layer
Merupakan lapisan terakhir dalam arsitektur TCP/IP yang berfungsi mendefinisikan aplikasi-aplikasi yang berjalan pada jaringan. Oleh karena itu, akan banyak protokol pada lapisan ini sesuai dengan jumlah aplikasi yang dapat dijalankan.

Perbedaan protokol transport TCP dengan UDP, terkait konektivitas, kehandalan, dan penggunaannya adalah sebagai berikut :

1. TCP ( Transmission Control Protocol ) merupakan protocol transport yang andal ( reliable ), dikarenakan protokol TCP mempunyai mekanisme yang memastikan packet dapat diterima oleh client. Pada saat TCP mengirimkan data ke penerima, TCP akan memberikan state acknowledgement. Apabila state acknowledgement tidak diterima, maka TCP akan secara otomatis mengirim ulang data dan menunggu dengan selang waktu tertentu namun apabila dalam selang waktu tertentu TCP gagal mengirimkan data, maka koneksi akan dihentikan. TCP memiliki algoritma yang digunakan untuk memperkirakan round-trip time ( RTT ) yaitu waktu yang dibutuhkan pada saat pengiriman data antara client dan server. TCP mempunyai karakteristik sebagai protokol yang berorientasi koneksi (Connection oriented). Sebelum terjadi proses tranfer data, maka yang pertama dilakukan adalah kedua belah pihak melakukan caal request dan call accept. Protokol TCP menggunakan jalur data full duplex yang berarti antara kedua host terdapat dua buah jalur, jalur masuk dan jalur keluar sehingga data dapat dikirimkan secara simultan.

2. UDP ( User Datagram Protocol ) adalah transport layer yang tidak andal ( unreliable ), connectionless (tidak berbasis koneksi) data yang dikirimkan dalam bentuk packet tidak harus melakukan call setup seperti pada TCP. Selain itu, data dalam protokol UDP akan dikirimkan sebagai datagram tanpa adanya nomor identifier. Sehingga sangat besar sekali kemungkinan data sampai tidak berurutan dan sangat mungkin hilang/rusak dalam perjalananan dari host asal ke host tujuan. Tergantung pada host penerima/tujuan, apakah akan meminta kembali pakcet yang rusak atau hilang. UDP merupakan kebalikan dari transport layer TCP. Dengan menggunakan UDP, setiap aplikasi socket dapat mengirimkan paket – paket yang berupa datagram. Istilah datagram diperuntukkan terhadap paket dengan koneksi yang tidak andal ( unreliable service ). Koneksi yang andal selalu memberikan keterangan apabila pengiriman data gagal, sedangkan koneksi yang tidak andal tidak akan mengirimkan keterangan meski pengiriman data gagal. UDP tidak menjamin kevalidan data saat data sampai ke si penerima.