Labels

Belajar, Berbagi, Bermanfaat

Selasa, 20 Januari 2015

GAME TANGKAP DORAEMON DENGAN VB.NET

Kemarin saat dapat Tugas Akhir pengganti UAS yang berupaaplikasi Game Tangkap Doraemon.
Pertama-tama yang kita butuhkan adalah

4 picture box untuk gambar doraemon
2 button untuk tombol mulai dan Keluar
4 Label untuk judul, Waktu, lbl60, dan Score
1 Textbox untuk score

Dan Inilah hasil nya

1. Halaman Awal

2. Halaman Mulai main

3. Halaman  Mendapat Nilai

4. Halaman Game Over



5. Halaman Main lagi

6. Halaman Menang


Kalo udah tampilan ini nih scriptnya:


Public Class Form1
    Dim doral1 As System.Drawing.Point
    Dim doral2 As System.Drawing.Point
    Dim doral3 As System.Drawing.Point
    Dim doral4 As System.Drawing.Point
    Sub aktif()
        TextBox1.Text = 0
        lbl60.Tag = 60
        PictureBox1.Enabled = True
        PictureBox2.Enabled = True
        PictureBox3.Enabled = True
        PictureBox4.Enabled = True
        TextBox1.Enabled = True
        Button2.Enabled = True
        Timer1.Enabled = True
    End Sub
    Sub nonaktif()
        PictureBox1.Enabled = False
        PictureBox2.Enabled = False
        PictureBox3.Enabled = False
        PictureBox4.Enabled = False
        TextBox1.Enabled = False
        Button2.Enabled = False
        Timer1.Enabled = False
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        nonaktif()
        doral1.X = 15
        doral1.Y = 52

        doral2.X = 166
        doral2.Y = 52

        doral3.X = 328
        doral3.Y = 52

        doral4.X = 496
        doral4.Y = 52
    End Sub
    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        If TextBox1.Text = 100 Then
            nonaktif()
            MessageBox.Show("Anda menang " & "Nilai Anda " & TextBox1.Text)
            nonaktif()
            Button1.Text = "Main Lagi"
            Button2.Enabled = True
        End If
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        lbl60.Tag = lbl60.Tag - 1
        lbl60.Text = lbl60.Tag
        If lbl60.Tag = 0 Then
            PictureBox1.Enabled = False
            PictureBox2.Enabled = False
            PictureBox3.Enabled = False
            PictureBox4.Enabled = False
            TextBox1.Enabled = False
            Button2.Enabled = False
            Timer1.Enabled = False
            MessageBox.Show("Game Over " & "Nilai Anda " & TextBox1.Text)
            nonaktif()
            Button1.Text = "Main Lagi"
            Button2.Enabled = True
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        aktif()
        doral1.X = 15
        doral1.Y = 52

        doral2.X = 166
        doral2.Y = 52

        doral3.X = 328
        doral3.Y = 52

        doral4.X = 496
        doral4.Y = 52
        PictureBox1.Location = doral1
        PictureBox2.Location = doral2
        PictureBox3.Location = doral3
        PictureBox4.Location = doral4
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        End
    End Sub

    Private Sub PictureBox1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
        PictureBox1.Visible = True
        TextBox1.Text = TextBox1.Text + 20
    End Sub

    Private Sub PictureBox2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click
        PictureBox2.Visible = True
        TextBox1.Text = TextBox1.Text + 20
    End Sub

    Private Sub PictureBox3_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox3.Click
        PictureBox3.Visible = True
        TextBox1.Text = TextBox1.Text + 20
    End Sub

    Private Sub PictureBox4_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox4.Click
        PictureBox4.Visible = True
        TextBox1.Text = TextBox1.Text + 20
    End Sub

    Private Sub PictureBox1_MouseMove_1(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
        Randomize()
        Dim kanan As Integer = Panel1.Width * Rnd()
        PictureBox1.Left = kanan
    End Sub

    Private Sub PictureBox2_MouseMove_1(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox2.MouseMove
        Randomize()
        Dim kanan As Integer = Panel1.Width * Rnd()
        PictureBox2.Left = kanan
    End Sub

    Private Sub PictureBox3_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox3.MouseMove
        Randomize()
        Dim kanan As Integer = Panel1.Width * Rnd()
        PictureBox3.Left = kanan
    End Sub

    Private Sub PictureBox4_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox4.MouseMove
        Randomize()
        Dim kanan As Integer = Panel1.Width * Rnd()
        TextBox1.Enabled = False
    End Sub
End Class

 



Yang mau download hasilnya bisa disini

0 komentar:

Posting Komentar