• Welcome to Dark Bit Factory & Gravity.
 

[2BUTTON] p1nkPong [updated!]

Started by benny!, January 27, 2008

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

benny!

UPDATED VERSION - PLEASE READ LAST POSTS !!!!

Hi all,

here is my little entry for the 2BUTTON GAME
COMPETITION.


About

It is a little pong clone written in C/C++. You
play pong versus yourself controlling both
bats simultaneously. Try to keep the ball as
long as possible on the field.


Demoscene factor

Well, unfortunately there aren't any demo-
scenish effects in it. However I hope the fact
that it has the size limitation of 1kb draws a
connection to the demoscene.


Controls

Use left/right cursor key to control. No ad-
ditional keys for start/end used. The game
starts right after it is loaded and quits auto-
matically after the ball gets lost.


Credits

Coding: benny!weltenkonstrukteur.de
Packer: Crinkler1.0a
Thanks: chris from which sources I learned
           and took so much!


[EDIT]
Updated version with proper exit. Thanks to rbraz
[/EDIT]
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Buckethead

#1
Great 1K Benny  8)  the quit is a bit dull for the gameplay but there are no room for that, and of course it has a connection to the demoscene.
Challenge Trophies Won:

Paul

I'm running vista 32 and when i loose i haveto do a ctrl+alt+delete to get rid of it.

1k is cool, but the game is far to hard, at least for me. managed to get 3 bounces and then the ball went far to fast... probably just me though.
I will bite you - http://s5.bitefight.se/c.php?uid=31059
Challenge Trophies Won:

benny!

Thanks a lot, Buckethead.

Quote from: Buckethead on January 27, 2008
...the quit is a bit dull for the gameplay ...

You are totally right. The gameplay is boring and not
very smooth and unoptimized, also. But the whole
thing was more than a proof-of-concept to squeeze
a game into 1kb.


Btw. I searched pouet for other 1kb-windows games ?
I didn't find any  - does anyone know a link to other
existing ones ??=
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

benny!

Quote from: Paul on January 27, 2008
I'm running vista 32 and when i loose i haveto
do a ctrl+alt+delete to get rid of it.

Strange. I tested it on WindowsXP and Vista
Home Premium. And it ended normally ... hmmmm.


Quote from: Paul on January 27, 2008
1k is cool, but the game is far to hard, at
least for me. managed to get 3 bounces
and then the ball went far to fast...
probably just me though.

That might be because of my rubbish code.
I tried to implement somekind of constant
framerate stuff - but I guess it is not
working probably.
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Buckethead

Benny: I never run a 1K Windows game before. :)
Challenge Trophies Won:

Shockwave

Congratulations for getting a game into 1kb! You have spare bytes too :)
Refresh was constant and smooth here.
Shockwave ^ Codigos
Challenge Trophies Won:

benny!

Quote from: Shockwave on January 27, 2008
Congratulations for getting a game into 1kb!
...

Thanks mate.

Quote from: Shockwave on January 27, 2008
...
You have spare bytes too :)
...

Every is welcome to make a add some code to fill
the spare bytes ;-) Source is available here.

Quote from: Shockwave on January 27, 2008
...
Refresh was constant and smooth here.
...

That's good news.
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Rbz

Very cool idea benny!  8)

I must try something like that in 1kb too  ;D


Some people are having problems when your program exit, try to add "ExitProcess(0)" in the end of your code and it might solve this problem, I hope you have free bytes for that :)
Challenge Trophies Won:

taj

Huge kudos for game in 1k (remember zx-81 chess?). I accept your argument that its demoscene related by being 1k. Very much so infact. But then , I would :-)
Challenge Trophies Won:

benny!

Quote from: rbraz on January 27, 2008
Very cool idea benny!  8)

I must try something like that in 1kb too  ;D

Yeah. Looking forward to see more 1kb/4kb controllable
fx 8-)

Quote from: rbraz on January 27, 2008
Some people are having problems when your program exit,
try to add "ExitProcess(0)" in the end of your code and it
might solve this problem, I hope you have free bytes for that :)

Good idea.Thx.After all size-reducing I forget about it. Source
updated (see C/C++ forum) and new version attached.
The ExitProcess(0)-function costs 3bytes


Quote from: taj on January 27, 2008
Huge kudos for game in 1k (remember zx-81 chess?).

Unfortunately not ... I am going to google it ;)

Quote from: taj on January 27, 2008
I accept your argument that its demoscene related by being 1k.
Very much so infact. But then , I would :-)

;-)

[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Paul

#11
thats allot better it quits like it should, and it seems to run at a more human speed :) stable 60 fps.

Edit: just noticed that i had like 20 "monoPongk-1k.exe" running in the taskmanager from the first exe :P no wonder i couldn't delete the exe.

I will bite you - http://s5.bitefight.se/c.php?uid=31059
Challenge Trophies Won:

Pixel_Outlaw

Very cool idea. Is there any possible way to include a score display? Also the exiting is pretty frusterating. If those lines of code would kill this I understand. I've never seen a game so small!
Challenge Trophies Won:

benny!

Quote from: Pixel_Outlaw on January 27, 2008
Very cool idea. Is there any possible way to include a score display?
Also the exiting is pretty frusterating. If those lines of code would kill
this I understand. I've never seen a game so small!

Ja. I tried to implement a scoring system via opening a message-
requester on exist showing the score. Unfortunately I couldn't
manage to stay in the size-limit of 1024 bytes with that.

If someone is able to play around with my code and can add a
scoring display that would truley rock !!!
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

va!n

#14
hi benny!
Very nice 1k game! I would be proud if it would be my production *grin*. K++ for the nice work and for the source! As you may know i dont get work any C/CPP code (even i want to learn CPP)... i just did a small view to your source and possible following thing could optimize your exe size!? (i cant test here, sorry)... Hope i didnt made any mistake

Your original source:


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();
}


Just try out to replace it with this (its possible to optimize it a bit, to save some more bytes!):


Static void drawObject( fTransX:float, fTransY:float, fTransZ:float, fLeft:float, fBottom:float, fRight:float, fTop:float )   
{
glLoadIdentity();
glTranslatef_( fTransX, fTransY, fTransZ, );

glBegin(GL_QUADS);
glVertex2f( fLeft , fBottom );
glVertex2f( fRight, fBottom );
glVertex2f( fRight, fTop    );
glVertex2f( fLeft , fTop    );
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();

    drawObject(  NULLNINE, -NULLNULLEIGHT + batY , NULLNULL, NULLNULL, NULLNULLFIVE, NULLTWO      );
    drawObject( -NULLNINE, -NULLNULLEIGHT - batY , NULLNULL, NULLNULL, NULLNULLFIVE, NULLTWO      );
    drawObject(     ballX,                  ballY, NULLNULL, NULLNULL, NULLNULLFIVE, NULLNULLFIVE );

}


But as i have seen you are using floats, which needs some extra space in the exe... you can do all the things with integers and dont need to use OGL-floating commands, i am sure this will produce a small exe too. good luck!
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

va!n

@benny:
i am not sure but i cant find something like glColor3f( r,g,b ) in your source to define the objects colors. However, try to replace all the float OGL commands with integer OGL commands like:


glColor3f (floating values) --> glColor3b (bye values) --> glColor3i (integer values)
glVertex2f (floating values) --> glVertex2i (integer values)


Possible you can cut off then floatAbs()... and at least you can try to set the display/screen to 640x480 (integers) for example instead -1 to +1 as dimension where you need to calc with floats to set a x/y position.
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

va!n

just a fast thought, you could try out and play/experience with to get a rounded ball and possible smaller exe size!? Instead using glVertex2f / glVertex2b / glVertex2i / glVertex2ui to create filled quads for the paddle and ball object, you could try to use GLUT API which could save you some bytes by using inbuild 3d objects like:


glutWireCube ();
glutSolidCube ();

glutWireSphere ();
glutSolidSphere ();

- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Positron

Well done Benny!

Very nice 1k. :clap:

benny!

Thanks for nice feedback.

@va!n:
Thanks a lot for optimization hints. I feedbacked your tipps
in the c++ source board.
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

WidowMaker [retired]

Good Karma given because you shared the source :)

Nice to see a 1kb game, I am sure you could put some score system?
Anyway, great that you got a game into only 1kb!