p1nkpong / monopong
p1nkpong / monopong was my attempt to write a full Windows OpenGL within 1KB (ie. 1024bytes) only. monopong was my first attempt. After a lot of optimization (thanks to auld) - I created a new version (named p1nkpong).
The gameplay lacks a bit since it was more a proof-of-concept that it is possible to create such a small windows game.
Screenshots
|
|
Features
- Windows game in 1016 bytes only
- OpenGL graphics
- sound system (midi)
- (binary) scoring system
Usage (p1nkpong)
The game starts immediately. Press ESC to quit the game. Use UP/DOWN cursor to control. The scoring system is shown in the middle screen. It represents teh score in binary form.
The control in monoPong is slightly different. Please refer to readme.txt file in archive.
Credits
Code benny!weltenkonstrukteur.de (with a lot of help of auld)
Packer Crinkler1.1
Source
Only monopong source is available atm.
// // monoPong1k // // code: benny!weltenkonstrukteur.de // // This code is built upon auld's great // 1k-coding sources/tips. thanks a lot! // VS2005 modifications // by benny!weltenkonstrukteur.de // #include#include #define NULLNULL 0.0000000000f #define NULLNULLONETRHEE 0.0130000000f #define NULLNINE 0.8984375000f #define NULLTWO 0.2001953125f #define NULLNULLFIVE 0.0500488281f #define NULLEIGHTSIX 0.8593750000f #define NULLNULLEIGHT 0.0800781250f #define NULLFIVE 0.5000000000f static PIXELFORMATDESCRIPTOR pfd; static GLfloat batY = NULLNULL; static GLfloat ballX = NULLNULL; static GLfloat ballY = NULLNULL; static GLfloat veloX = NULLNULLONETRHEE; static GLfloat veloY = NULLNULLONETRHEE; // // some math functions // static float floatAbs(float f) { (int&)f &= ~0x80000000; return f; } // // drawing stuff // static void drawBat(void) { glBegin(GL_QUADS); glVertex2f(NULLNULL, NULLNULL); glVertex2f(NULLNULLFIVE, NULLNULL); glVertex2f(NULLNULLFIVE, NULLTWO); glVertex2f(NULLNULL, NULLTWO); glEnd(); } static void render( void ) { glClear( GL_COLOR_BUFFER_BIT ); glLoadIdentity(); glTranslatef( NULLNINE, -NULLNULLEIGHT + batY, NULLFIVE ); drawBat(); glLoadIdentity(); glTranslatef( -NULLNINE, -NULLNULLEIGHT - batY, NULLNULL ); drawBat(); glLoadIdentity(); glTranslatef( ballX, ballY, NULLNULL ); glBegin(GL_QUADS); glVertex2f(NULLNULL, NULLNULL); glVertex2f(NULLNULLFIVE, NULLNULL); glVertex2f(NULLNULLFIVE, NULLNULLFIVE); glVertex2f(NULLNULL, NULLNULLFIVE); glEnd(); } void WINAPI WinMainCRTStartup() { // auld code // minimal windows setup code for opengl pfd.cColorBits = pfd.cDepthBits = 32; pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; // "HDC hDC" changed 19. April 2007 by benny!weltenkonstrukteur.de HDC hDC = GetDC( CreateWindow("edit", 0, WS_POPUP|WS_VISIBLE|WS_MAXIMIZE, 0, 0, 0, 0, 0, 0, 0, 0) ); SetPixelFormat ( hDC, ChoosePixelFormat ( hDC, &pfd) , &pfd ); wglMakeCurrent ( hDC, wglCreateContext(hDC) ); //ShowCursor(FALSE); int quit = 0; DWORD start = GetTickCount(); DWORD cur = 0; do { cur = GetTickCount(); if ( (cur - start ) < 10 ) continue; start = cur; ballX+=veloX; ballY+=veloY; // check if ( ballY > NULLNINE ) veloY = -NULLNULLONETRHEE; if ( ballY < -NULLNINE) veloY = NULLNULLONETRHEE; float check = floatAbs(batY - ballY); float check2= floatAbs(-batY - ballY); if ( ballX > NULLEIGHTSIX && check < NULLTWO ){ veloX = -(0.005f + (check/5)); } else if ( ballX > NULLEIGHTSIX && check > NULLTWO ) { quit = 1; } if ( ballX < -NULLEIGHTSIX && check2 < NULLTWO ){ veloX = 0.005f + (check2/5); } if ( ballX < -NULLEIGHTSIX && check2 > NULLTWO ) { quit = 1; } if ( GetAsyncKeyState(VK_RIGHT) && batY < NULLNINE ) { batY += NULLNULLFIVE; } else if ( GetAsyncKeyState(VK_LEFT) && batY > -NULLNINE) { batY -= NULLNULLFIVE; } render(); SwapBuffers(hDC); } while ( quit == 0 ); ExitProcess(0); }



