Lampiran A
HELP EZTWAIN
TWAIN_LogFilevoid TWAIN_LogFile(int fLog);
EZTwain membuat suatu log di c:\eztwain.log yang mencatat setiap aktifitas dari Twain.
TWAIN_LogFile(0) menutup file log dan menghentikan pencatatan TWAIN_LogFile(1) membuka file log (jika belum terbuka) dan memulai pencatatan
Jika file log sudah terbuka maka TWAIN_LogFile(1) berfungsi untuk mencatat file log di harddisk sehingga data yang telah didapat tidak akan hilang jika terjadi crash.
TWAIN_SetHideUI
void TWAIN_SetHideUI(int fHide);
Jika diset pada FALSE(0), maka User Interface akan ditampilkan.
Jika diset pada TRUE(1), maka User Interface akan dicoba untuk disembunyikan. TWAIN_OpenDefaultSource
int TWAIN_OpenDefaultSource(void); membuka dialog dari alat capture
TWAIN_SetPixelType
int TWAIN_SetPixelType(int nPixType); mengatur pixel-pixel seperti pada tabel dibawah
Code TWAIN Name Description
0 TWPT_BW 1-bit per pixel, black
and white
1 TWPT_GRAY grayscale, 8 or 4-bit
2 TWPT_RGB RGB color, 24-bit
(rarely, 15,16,32-bit)
3 TWPT_PALETTE indexed color (image
has a color table) 8 or 4-bit.
4 TWPT_CMY CMY color, 24-bit
5 TWPT_CMYK CMYK color, 32-bit
TWAIN_SetXferCount
int TWAIN_SetXferCount(int nXfers);
memastikan jumlah gambar yang disimpan sama dengan jumlah gambar yang dicapture. (1) berarti sukses dan (0) berarti gagal
LAMPIRAN B
Variabel Visual Basic yang Digunakan
dan Keterangannya
Daftar variabel-variabel ini dibuat untuk mempermudah memahami listing program permainan yang akan dijelaskan pada lampiran C.
i= koordinat x sementara / akhir dari “penusuk balon” j= koordinat y sementara / akhir dari ”penusuk balon” x= koordinat x dari balon-balon
y= koordinat y dari balon-balon
r= derajat kemerahan dari pixel yang ditunjuk g= derajat kehijauan dari pixel yang ditunjuk b= derajat kebiruan dari pixel yang ditunjuk
pix= variabel yang digunakan untuk mengatasi bug
Q= pergerakan vertikal balon berupa counter 1 sampai 8 ( dengan 8 = 1) z= hasil grayscale dari pixel yang ditunjuk
Picture1= hasil capture kamera web diletakkan disini
Picture2, Picture3, Picture4 = gambar balon dan animasi balon pecah diletakkan disini
balon mini.jpg= gambar balon saat belum pecah, diletakkan di picture 2, 3 dan 4 (gambar 3.3.a )
balon mini2.jpg= salah satu dari serangkaian gambar animasi balon pecah (gambar 3.3.b )
balon mini3.jpg = salah satu dari serangkaian gambar animasi balon pecah (gambar 3.3.c )
balon mini4.jpg = salah satu dari serangkaian gambar animasi balon pecah (gambar 3.3.d )
LAMPIRAN C
LISTING PROGRAM GAME
Dim waktu
Private Declare Function PlaySound Lib "winmm.dll" Alias _
"PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, _ ByVal dwFlags As Long) As Long
Private Sub Form_Load() waktu = Now
Timer1.Enabled = True End Sub
Static Sub Timer1_Timer() Picture2.Visible = False Picture3.Visible = False Picture4.Visible = False Dim score As Long Call TWAIN_LogFile(1) Call TWAIN_SetHideUI(1) Call TWAIN_SetIndicators(0)
If TWAIN_OpenDefaultSource() <> 0 Then ' Not guaranteed to work, check return = 1: Call TWAIN_SetPixelType(2)
Call DIB_Free(hdib) End If
End If
If TWAIN_LastErrorCode() <> 0 Then
Call TWAIN_ReportLastError("Unable to scan.") End If
Picture1.Picture = LoadPicture("c:\image.bmp")
For i = 1 To Picture1.Width - 30 Step 15 j = Picture1.Height - 38 warna2 = Picture1.Point(i, j) r = warna2 And RGB(255, 0, 0) G = Int((warna2 And RGB(0, 255, 0)) / 256) b = Int(Int((warna2 And RGB(0, 0, 255)) / 256) / 256) x = (r + G + b) / 3 If x < 128 Then x = 0 Else x = 255
'If x = 0 Then picture1.Circle (i, j), 200, RGB(0, 0, 255) Else: If x = 255 Then picture1.Circle (i, j), 50, RGB(0, 255, 0)
If x = 255 Then GoTo atas Else Next i
atas:
If j > 0 Then j = j - 1 Else: GoTo coba 'bug pada harus stop max height warna2 = Picture1.Point(i, j)
r = warna2 And RGB(255, 0, 0)
G = Int((warna2 And RGB(0, 255, 0)) / 256)
b = Int(Int((warna2 And RGB(0, 0, 255)) / 256) / 256) x = (r + G + b) / 3 'set point jadi 0 atau 255
If x < 128 Then x = 0 Else x = 255 'If x = 255 Then pix = 0 Else: 'Label3.Caption = pix
If x = 0 Then GoTo kiri Else: GoTo atas kiri: 'bug pada harus stop kanan-kiri j = j + 1 'kembalikan ke koordinat awal 'dibawah ini bug harus stop max kiri If i > 38 Then i = i - 1 Else: GoTo coba warna2 = Picture1.Point(i, j) r = warna2 And RGB(255, 0, 0) G = Int((warna2 And RGB(0, 255, 0)) / 256) b = Int(Int((warna2 And RGB(0, 0, 255)) / 256) / 256) x = (r + G + b) / 3 If x < 128 Then x = 0 Else x = 255
'If x = 255 Then pix = i Else: pix = i + 1 'muncul di else 'If x = 0 Then Label2.Caption = 1 Else: Label2.Caption = 2 If (x = 255) And (pix = i) Then GoTo kanan Else:
If x = 0 Then GoTo kanan Else: GoTo atas kanan:
i = i + 1 'kembali ke koordinat awal pix = i
If i < (Picture1.Width - 38) Then i = i + 1 Else: GoTo coba warna2 = Picture1.Point(i, j)
r = warna2 And RGB(255, 0, 0)
G = Int((warna2 And RGB(0, 255, 0)) / 256)
'If i <> (pix + 1) Then GoTo coba Else: If x = 0 Then GoTo coba Else: GoTo atas
'If i <> (pix + 1) Then Label1.Caption = 1 Else Label1.Caption = 2 'If x = 0 Then Label1.Caption = 3 Else: Label1.Caption = 7
GoTo akhiri coba:
Picture1.Circle (i, j), 50, RGB(0, 255, 0) 'Label2.Caption = Picture4.Left
'Label3.Caption = Picture4.Left + Picture3.Width 'Label4.Caption = i
'Label5.Caption = Picture3.Top + Picture3.Height
If pic2 <> 1 Then Picture2.Visible = True ' untuk bug balon dianggap picture2 If pic3 <> 1 Then Picture3.Visible = True ' untuk bug balon dianggap picture2 If pic4 <> 1 Then Picture4.Visible = True ' untuk bug balon dianggap picture2 If (i >= Picture2.Left) And (i <= Picture2.Left + Picture2.Width) And (j >= Picture2.Top) And (j <= Picture2.Top + Picture2.Height) And (Picture2.Visible = True) Then GoTo hapus2 Else:
If (i >= Picture3.Left) And (i <= Picture3.Left + Picture3.Width) And (j >= Picture3.Top) And (j <= Picture3.Top + Picture3.Height) And (Picture3.Visible = True) Then GoTo hapus3 Else:
If (i >= Picture4.Left) And (i <= Picture4.Left + Picture4.Width) And (j >= Picture4.Top) And (j <= Picture4.Top + Picture4.Height) And (Picture4.Visible = True) Then GoTo hapus4 Else: GoTo akhiri
hapus2:
score = score + 100
Picture2.Picture = LoadPicture("c:\balon mini2.jpg") Picture2.Picture = LoadPicture("c:\balon mini3.jpg") Picture2.Picture = LoadPicture("c:\balon mini4.jpg") Label1.Caption = score
Picture2.Visible = False pic2 = 1
retVal = PlaySound("c:\Chains.wav", 0&, &H20000) GoTo akhiri
hapus3:
score = score + 100
Picture3.Picture = LoadPicture("c:\balon mini2.jpg") Picture3.Picture = LoadPicture("c:\balon mini3.jpg") Picture3.Picture = LoadPicture("c:\balon mini4.jpg") Label1.Caption = score
Picture3.Visible = False pic3 = 1
retVal = PlaySound("c:\Chains.wav", 0&, &H20000) GoTo akhiri
hapus4:
score = score + 100 Label1.Caption = score
Picture4.Picture = LoadPicture("c:\balon mini2.jpg") Picture4.Picture = LoadPicture("c:\balon mini3.jpg") Picture4.Picture = LoadPicture("c:\balon mini4.jpg") Picture4.Visible = False
pic4 = 1
retVal = PlaySound("c:\Chains.wav", 0&, &H20000) GoTo akhiri
Timer2.Enabled = False Timer1.Enabled = False
MsgBox ("waktu anda menyelesaikan adalah " & Format$(Now - waktu, "hh:mm:ss") & " dapatkah anda lebih cepat?")
End akhiri2: End Sub
Static Sub Timer2_Timer() If z <> 0 Then GoTo mulai Else xasal1 = Rnd * Form1.Width xakhir1 = Rnd * Form1.Width xasal2 = Rnd * Form1.Width xakhir2 = Rnd * Form1.Width xasal3 = Rnd * Form1.Width xakhir3 = Rnd * Form1.Width mulai: z = z + 1
If z = 8 Then GoTo acak kembali:
If z = 8 Then z = 1
Picture2.Left = xasal1 + ((xakhir1 - xasal1) / 8 * z) Picture3.Left = xasal2 + ((xakhir2 - xasal2) / 8 * z) Picture4.Left = xasal3 + ((xakhir3 - xasal3) / 8 * z) Picture2.Top = Form1.Height / 10 * z Picture3.Top = Form1.Height / 10 * z Picture4.Top = Form1.Height / 10 * z GoTo ending acak: xasal1 = Rnd * Form1.Width C-6
xakhir1 = Rnd * Form1.Width xasal2 = Rnd * Form1.Width xakhir2 = Rnd * Form1.Width xasal3 = Rnd * Form1.Width xakhir3 = Rnd * Form1.Width GoTo kembali ending: End Sub
Private Sub Timer3_Timer()
Label2.Caption = Format$(Now - waktu, "hh:mm:ss") End Sub