Selamat siang pemirsa.....!!!
jumpa lagi dengan saya,sudah lama saya gak nulis di blog ini karena lagi repot kerjain ini itu sampai gak sempat nulis.
kali ini saya mau bagi bagi source kode pembuatan object spongebob dengan basic4gl.
mungkin anda bertanya tanya....
Ni tentang apa to...?? gambar spongebob kan gampang ngapain di share segala ?
hehehe...jangan berburuk sangka dulu....mungkin buat sebagian orang pekerjaan ini sesuatu yang mudah,tapi tidak bagi mahasiswa teknik informatika seperti saya yang masih terbilang baru di dunia pemrograman grafis.
langsung saja pemirsa,kode berikut saya tulis menggunakan bahasa basic dengan library OpenGl dalam aplikasi Basic4Gl yang dapat di download Di Sini
untuk file yang siap di jalankan bisa di download Di Sini
untuk kodenya sebagai berikut
TextMode (TEXT_OVERLAID)
locate 0,0
printr " Tugas UAS "
printr " Ady S,Yunus Fanani,Nur Hidayatullah"
printr ""
printr ""
printr ""
printr ""
printr ""
printr ""
printr ""
printr ""
printr ""
printr ""
printr ""
printr ""
printr ""
printr ""
printr ""
printr ""
printr ""
printr ""
printr ""
printr ""
printr " 'Spasi' untuk melompat"
dim a#= -10
dim b#
dim c# = -30
dim akhir = 20
dim awal = a#
sub SPONGEBOB()
glTranslatef (b#, a#, c#)
glRotatef(0.0,0.0,0.0,-20)
glBegin (GL_QUADS)'kepala
glColor3f(1.0,1.0, 0.0):
glVertex2f(1.6,0.7)
glVertex2f(1.9,1.3)
glVertex2f (-1.6, 4.4)
glVertex2f (-2.4, 3.7)
glColor3f(1.0,1.0, 0.0):
glVertex2f(-1.6,0.7)
glVertex2f(-2.2,1.3)
glVertex2f (1.6, 4.4)
glVertex2f (2.4, 3.6)
glColor3f(1.0,1.0, 0.0):
glVertex2f(-2.2,4.2)
glVertex2f(-1.8,1)
glVertex2f (1.8, 1)
glVertex2f (2.2, 4.2)
glColor3f(1.0,1.0, 0.0):
glVertex2f(-2.4,3)
glVertex2f(-1,4.5)
glVertex2f (2.2, 1.6)
glVertex2f (1, 0.7)
glColor3f(1.0,1.0, 0.0):
glVertex2f(0,4.6)
glVertex2f(-2.4,2.4)
glVertex2f (0, 0.6)
glVertex2f (2.4, 2.4)
glColor3f(1.0,1.0, 0.0):
glVertex2f(0.8,4.5)
glVertex2f(2.4,3)
glVertex2f (0,0)
glVertex2f (-2.2,1.8)
glBegin (GL_QUADS)'badan
glColor3f(0.5,0.1, 0.1):
glVertex2f (1.8, 1)
glVertex2f (1.8, -0.5)
glVertex2f (-1.8, -0.5)
glVertex2f (-1.8, 1)
glColor3f(1.0,1.0, 0.0):'tangan kanan
glVertex2f (2, 0.6)
glVertex2f (2.5, 0.1)
glVertex2f (2.8,0.3)
glVertex2f (2.2,0.9)
glColor3f(0.8,0.8, 0.8):'lengan kanan
glVertex2f (1.6, 0.7)
glVertex2f (2, 0.5)
glVertex2f (2.3, 1)
glVertex2f (1.9,1.3)
glColor3f(1.0,1.0, 0.0):'tangan kiri
glVertex2f (-2, 0.6)
glVertex2f (-2.5, 0.1)
glVertex2f (-2.8,0.3)
glVertex2f (-2.2,0.9)
glColor3f(0.8,0.8, 0.8):'lengan kiri
glVertex2f (-1.6, 0.7)
glVertex2f (-2, 0.5)
glVertex2f (-2.3, 1)
glVertex2f (-1.9,1.3)
glColor3f(0.3,0.1, 0.1):'celana kiri
glVertex2f (-1, -0.5)
glVertex2f (-1, -1)
glVertex2f (-0.3, -1)
glVertex2f (-0.3,-0.5)
glColor3f(1.0,1.0, 0.0):'kaki kiri
glVertex2f (-0.8, -1)
glVertex2f (-0.8, -1.5)
glVertex2f (-0.5, -1.5)
glVertex2f (-0.5,-1)
glColor3f(0.5,0.2, 1.0):'sepatu kiri
glVertex2f (-0.9, -1.5)
glVertex2f (-0.45, -1.5)
glVertex2f (-0.45,-1.8)
glVertex2f (-1.6,-1.8)
glColor3f(0.3,0.1, 0.1):'celana kanan
glVertex2f (1, -0.5)
glVertex2f (1, -1)
glVertex2f (0.3, -1)
glVertex2f (0.3,-0.5)
glColor3f(1.0,1.0, 0.0):'kaki kanan
glVertex2f (0.8, -1)
glVertex2f (0.8, -1.5)
glVertex2f (0.5, -1.5)
glVertex2f (0.5,-1)
glColor3f(0.5,0.2, 1.0):'sepatu kanan
glVertex2f (0.9, -1.5)
glVertex2f (0.45, -1.5)
glVertex2f (0.45,-1.8)
glVertex2f (1.5,-1.8)
glColor3f(0.0,0.0, 0.0):'sabuk kiri
glVertex2f (-1.3,-0.1)
glVertex2f (-0.5,-0.1)
glVertex2f (-0.5, 0.1)
glVertex2f (-1.3, 0.1)
glColor3f(0.0,0.0, 0.0):'sabuk kanan
glVertex2f (1.3,-0.1)
glVertex2f (0.5,-0.1)
glVertex2f (0.5, 0.1)
glVertex2f (1.3, 0.1)
glColor3f(1.0, 1.0, 1.0):'baju
glVertex2f (1.8, 1)
glVertex2f (1.8, 0.5)
glVertex2f (-1.8, 0.5)
glVertex2f (-1.8, 1)
glEnd ()
glBegin(GL_LINE_STRIP)'Krah kiri
glColor3f(0.0,0.0,0.0)
glVertex2f(-1.3,1)
glVertex2f(-0.8,0.5)
glVertex2f(-0.2,1)
glEnd()
glBegin(GL_LINE_STRIP)'Krah kanan
glColor3f(0.0,0.0,0.0)
glVertex2f(1.3,1)
glVertex2f(0.8,0.5)
glVertex2f(0.2,1)
glEnd()
glBegin(GL_LINE_LOOP)'dasi
glColor3f(1.0,0.0,0.0)
glVertex2f(0.2,1)
glVertex2f(-0.3,0)
glVertex2f(0,-0.3)
glVertex2f(0.3,0)
glVertex2f(-0.2,1)
glEnd()
glBegin(GL_LINES)
glColor3f(0.0,0.0,0.0)
glVertex2f(-1,1.6)
glVertex2f(1,1.6)
glVertex2f(1.3,1.8)
glVertex2f(1,1.6)
glVertex2f(-1.3,1.8)
glVertex2f(-1,1.6)
glEnd()
glBegin(GL_QUADS)'gigi dan mata
glColor3f(1.0,1.0,1.0)
glVertex2f(-0.5,1.6)'GIGI KIRI
glVertex2f(0,1.6)
glVertex2f(0,1.3)
glVertex2f(-0.5,1.3)
glColor3f(0.0,0.0,0.0)
glVertex2f(0.1,2.5)'HIDUNG
glVertex2f(0.1,2.1)
glVertex2f(-0.1,2.1)
glVertex2f(-0.1,2.5)
glColor3f(0.0,0.0,0.0)
glVertex2f(0.7,3)'MATA KANAN
glVertex2f(0.7,2.7)
glVertex2f(1,2.7)
glVertex2f(1,3)
glColor3f(0.0,0.0,0.0)
glVertex2f(-0.7,3)'MATA KIRI
glVertex2f(-0.7,2.7)
glVertex2f(-1,2.7)
glVertex2f(-1,3)
glColor3f(1.0,1.0,1.0)
glVertex2f(0.1,1.6)'GIGI KANAN
glVertex2f(0.6,1.6)
glVertex2f(0.6,1.3)
glVertex2f(0.1,1.3)
glEnd()
DrawText()
SwapBuffers ()
end sub
while true
glClear (GL_DEPTH_BUFFER_BIT or GL_COLOR_BUFFER_BIT)
glLoadIdentity ()
SPONGEBOB()
if a# > -10 then
a# = a# - 0.09
endif
if ScanKeyDown(VK_SPACE) then 'fungsi ketika di tekan tombol spasi
a# = 10
elseif ScanKeyDown(VK_RIGHT) then
'fungsi ketika di tekan tombol kanan
b# = b# + 0.015
elseif ScanKeyDown(VK_LEFT) then
'fungsi ketika di tekan tombol kiri
b# = b# - 0.015
else
endif
wend
file tersebut disimpan dengan extension .gb
jika dijalankan kurang lebuh hasilnya seperti ini
sekian dulu tulisan saya selamat mencoba....
selamat siang
0 comments:
Post a Comment