DemoCoding - 256 CubeTro

Developed or developing a new product in PureBasic? Tell the world about it.
va!n
Addict
Addict
Posts: 1104
Joined: Wed Apr 20, 2005 12:48 pm

DemoCoding - 256 CubeTro

Post by va!n »

This is for all the ppl, dont know this production done with PB...

Some time ago, there was an PB compo, creating an program in max 256 lines and using only one : each line... here is the result a very good friend (remi meier) and me created Smiley

www.secretly.de/public/256_CubeTro.zip (source including exe)

The goal was not to have an readable source... our goal was to beat the limit and showing great stuff in just so few and crypted lines Cheesy

Code: Select all

Prototype glOrtho(a.d,b.d,c.d,d.d,e.d,f.d) : Prototype gluPerspective(a.d,b.d,c.d,d.d)
Global glOrtho_.glOrtho = 0*OpenLibrary(0, "OpenGL32.dll") + GetFunction(0, "glOrtho"), gluPerspective_.gluPerspective = 0*OpenLibrary(1, "glu32.dll") + GetFunction(1, "gluPerspective"), StartTime.d = GetTickCount_(), pfd.PIXELFORMATDESCRIPTOR\dwFlags = #PFD_DOUBLEBUFFER | #PFD_SUPPORT_OPENGL, hdc = GetDC_ (CreateWindow_("edit", 0, #WS_POPUP|#WS_VISIBLE|#WS_MAXIMIZE,0, 0, 0 , 0, 0, 0, 0, 0) )  : t=SetPixelFormat_ (hdc, ChoosePixelFormat_ ( hdc, pfd) , pfd ) + wglMakeCurrent_ (hdc, wglCreateContext_(hdc) ) + ShowCursor_(#False) + InitSound() + InitModule() + LoadModule(0,"data\tune.mod") + PlayModule(0)  + glClearColor_(0.4,0.0,0.6,0.0) + glViewport_(0.0,0.0,GetSystemMetrics_(0),GetSystemMetrics_(1)) + glMatrixMode_($1701) + glLoadIdentity_() + gluPerspective_(45.0,800.0/600.0,1.0,500.0) + glMatrixMode_($1700) + glEnable_($0B44) + glEnable_($0B71) + glDepthMask_(1) + glDisable_($0B44)
Procedure OGLRect(x1.f, y1.f, x2.f, y2.f, r.f, g.f, b.f) : t = glMatrixMode_($1701) + glLoadIdentity_() + glOrtho_(0,1024, 0,768,-2048, 2048) + glMatrixMode_($1700) + glLoadIdentity_() + glColor3f_(r, g, b) + glRectf_(x1, y1, x2, y2) + glMatrixMode_($1701) + glLoadIdentity_() + gluPerspective_(45.0,800.0/600.0,1.0,500.0) + glMatrixMode_($1700)
EndProcedure : Procedure CreateCube( x.d, y.d, z.d)
  Protected dRotate.d = (GetTickCount_() - StartTime) / 10, t = glLoadIdentity_() + glTranslatef_(x.d,y.d,z.d) + glRotatef_(dRotate, dRotate,dRotate, 0), *datad.Double = ?dat_cube : For loop = 0 To 1 + (0 * ((loop < 2) And glBegin_(Int(PeekD(*datad))))) 
  For i = 0 To (Int(PeekD(*datad+8))-1) + 0 * (((Not (Abs(PeekD(*datad+16+32*i)-1) < 0.01)) + (Not (glColor3dv_(*datad+24+32*i)))) And glVertex3dv_(*datad+24+32*i))  :  Next 
*datad + (16 + Int(PeekD(*datad+8)) * 32) + 0 * (glEnd_()) : Next 
EndProcedure : Procedure DrawCube(n.l, *p.Double)
ProcedureReturn (CreateCube(PeekD(*p)+6, PeekD(*p+8)+2.5, -45 + Sin((GetTickCount_()-StartTime)/666)*10 )) + (n > 1 And DrawCube(n-1, *p + 16)) : EndProcedure
Repeat : Until (0 * ((0* (glClear_($00004000 | $00000100) + DrawCube(42, ?dat_cube + $3A0) + OGLRect(0, 0, 1024, 100, 0, 0, 0) + OGLRect(0, 668, 1024, 768, 0, 0, 0) + Sleep_(10) + SwapBuffers_ ( hdc ) )))) Or ((GetAsyncKeyState_(#VK_ESCAPE) And ShowCursor_(#True)) And TerminateProcess_(GetCurrentProcess_(), 0))
dat_cube: ! dq   7.0, 10.0, 1.0, 1.0, 0.0, 0.0, 2.0, -1.0, 1.0, 1.0, 2.0, 1.0, 1.0, 1.0, 2.0, 1.0, 1.0, -1.0, 2.0, -1.0, 1.0, -1.0, 1.0, 0.0, 0.0, 1.0, 2.0, -1.0, -1.0, 1.0, 2.0, -1.0, -1.0, -1.0, 2.0, 1.0, -1.0, -1.0, 2.0, 1.0, -1.0, 1.0, 5.0, 18.0, 1.0, 1.0, 1.0, 1.0, 2.0, -1.0, 1.0, 1.0, 2.0, -1.0, -1.0, 1.0, 2.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 2.0, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 2.0, 1.0, 1.0, -1.0, 1.0, 0.0, 1.0, 1.0, 2.0, 1.0, -1.0, -1.0, 1.0, 0.6, 0.6, 0.6, 2.0, -1.0, 1.0, -1.0, 1.0, 0.1, 0.1, 0.1, 2.0, -1.0, -1.0, -1.0, 1.0, 0.0, 0.0, 1.0, 2.0, -1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 2.0, -1.0, -1.0, 1.0, -22.5, 0.0, -20.5, 2.0,-18.5, 2.0, -16.5, 2.0, -14.5, 0.0, -18.5, -2.0, -16.5, -2.0, -20.5, -4.0, -22.5, -6.0, -20.5, -6.0, -18.5, -6.0, -16.5, -6.0, -14.5, -6.0, -10.5, 2.0, -8.5, 2.0, -6.5, 2.0, -4.5, 2.0, -2.5, 2.0, -10.5 ,0.0, -10.5, -2.0,-8.5, -2.0, -6.5, -2.0, -4.5, -2.0, -2.5, -4.0, -10.5, -6.0, -8.5, -6.0, -6.5, -6.0, -4.5, -6.0, 4.5, 2.0, 6.5, 2.0, 8.5, 2.0, 10.5, 2.0, 2.5, 0.0, 2.5, -2.0, 4.5, -2.0, 6.5, -2.0, 8.5, -2.0, 2.5, -4.0, 10.5, -4.0,  4.5, -6.0,  6.5, -6.0, 8.5, -6.0
Last edited by va!n on Mon Oct 01, 2007 12:44 pm, edited 1 time in total.
va!n aka Thorsten

Intel i7-980X Extreme Edition, 12 GB DDR3, Radeon 5870 2GB, Windows7 x64,
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Re: 256 CubeTro

Post by traumatic »

Nice :)
Good programmers don't comment their code. It was hard to write, should be hard to read.
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

Love the music! Image

Well done!
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
Post Reply