Selasa, 03 Juli 2012
Basic4GL Bikin 3 Kotak dan Rotasi Bergerak
sub kotak()
glBegin(GL_QUADS) ' Draw A Quad
glVertex3f( 0.0, 0.0, 0.0) ' Top Left
glVertex3f( 0.0, 2.0, 0.0) ' Top Right
glVertex3f( 14.0, 2.0, 0.0) ' Bottom Right
glVertex3f( 14.0, 0.0, 0.0) ' Bottom Left
glEnd() ' Done Drawing The Quad
end sub
sub kotak1()
glBegin(GL_QUADS) ' Draw A Quad
glVertex3f( 0.0, 0.0, 0.0) ' Top Left
glVertex3f( 0.0, 2.0, 0.0) ' Top Right
glVertex3f( 6.0, 2.0, 0.0) ' Bottom Right
glVertex3f( 6.0, 0.0, 0.0) ' Bottom Left
glEnd() ' Done Drawing The Quad
end sub
sub kotak2()
glBegin(GL_QUADS) ' Draw A Quad
glVertex3f( 0.0, 0.0, 0.0) ' Top Left
glVertex3f( 0.0, 2.0, 0.0) ' Top Right
glVertex3f( 16.0, 2.0, 0.0) ' Bottom Right
glVertex3f( 16.0, 0.0, 0.0) ' Bottom Left
glEnd() ' Done Drawing The Quad
end sub
dim alpa#
dim beta#
dim teta#
alpa# = 45
beta#=-90
teta#=90
while true
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT) ' Clear The Screen And The Depth Buffer
glLoadIdentity() ' Reset The View
glTranslatef(0.0,0.0,-40.0) ' Move Left 1.5 Units And Into The Screen 6.0
glRotatef (alpa#,0,0,1)
kotak()
glPopMatrix()
glTranslatef(14.0,2.0,0.0)
glRotatef (beta#,0,0,1)
kotak1()
glPopMatrix()
glTranslatef(6.0,2.0, 0.0)
glRotatef (teta#,0,0,1)
kotak2()
SwapBuffers ()
if KeyDown("Q") then alpa#=alpa# - 1 endif
if KeyDown("A") then alpa#=alpa# + 1 endif
if KeyDown("W") then beta#=beta# + 1 endif
if KeyDown("S") then beta#=beta# - 1 endif
if KeyDown("E") then teta#=teta# + 1 endif
if KeyDown("D") then teta#=teta# - 9999 endif
wend
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar