Dark Bit Factory & Gravity

GENERAL => Challenges & Competitions => Topic started by: benny! on January 27, 2008

Title: [2BUTTON] p1nkPong [updated!]
Post by: benny! on January 27, 2008
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]
Title: Re: [2BUTTON] monoPong-1k
Post by: Buckethead on January 27, 2008
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.
Title: Re: [2BUTTON] monoPong-1k
Post by: 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.

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.
Title: Re: [2BUTTON] monoPong-1k
Post by: benny! on January 27, 2008
Thanks a lot, Buckethead.

...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 ??=
Title: Re: [2BUTTON] monoPong-1k
Post by: benny! 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.


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.
Title: Re: [2BUTTON] monoPong-1k
Post by: Buckethead on January 27, 2008
Benny: I never run a 1K Windows game before. :)
Title: Re: [2BUTTON] monoPong-1k
Post by: Shockwave on January 27, 2008
Congratulations for getting a game into 1kb! You have spare bytes too :)
Refresh was constant and smooth here.
Title: Re: [2BUTTON] monoPong-1k
Post by: benny! on January 27, 2008
Congratulations for getting a game into 1kb!
...

Thanks mate.

...
You have spare bytes too :)
...

Every is welcome to make a add some code to fill
the spare bytes ;-) Source is available here (http://dbfinteractive.com/index.php?topic=2860.msg39159#new).

...
Refresh was constant and smooth here.
...

That's good news.
Title: Re: [2BUTTON] monoPong-1k
Post by: Rbz on January 27, 2008
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 :)
Title: Re: [2BUTTON] monoPong-1k
Post by: taj on January 27, 2008
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 :-)
Title: Re: [2BUTTON] monoPong-1k
Post by: benny! 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-)

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


Huge kudos for game in 1k (remember zx-81 chess?).

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

I accept your argument that its demoscene related by being 1k.
Very much so infact. But then , I would :-)

;-)

Title: Re: [2BUTTON] monoPong-1k
Post by: Paul on January 27, 2008
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.

Title: Re: [2BUTTON] monoPong-1k
Post by: 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!
Title: Re: [2BUTTON] monoPong-1k
Post by: benny! 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 !!!
Title: Re: [2BUTTON] monoPong-1k
Post by: va!n on January 27, 2008
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:

Code: [Select]
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!):

Code: [Select]
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!
Title: Re: [2BUTTON] monoPong-1k
Post by: va!n on January 27, 2008
@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:

Code: [Select]
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.
Title: Re: [2BUTTON] monoPong-1k
Post by: va!n on January 28, 2008
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:

Code: [Select]
glutWireCube ();
glutSolidCube ();

glutWireSphere ();
glutSolidSphere ();
Title: Re: [2BUTTON] monoPong-1k
Post by: Positron on January 28, 2008
Well done Benny!

Very nice 1k. :clap:
Title: Re: [2BUTTON] monoPong-1k
Post by: benny! on January 28, 2008
Thanks for nice feedback.

@va!n:
Thanks a lot for optimization hints. I feedbacked your tipps
in the c++ source board.
Title: Re: [2BUTTON] monoPong-1k
Post by: WidowMaker [retired] on January 28, 2008
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!
Title: Re: [2BUTTON] monoPong-1k
Post by: benny! on January 29, 2008
@WidowMaker:
Thx mate.


@topic:
Just if someone is interested in it - mr. doob has just
done a flash version of that game. Have a look here:
http://www.pouet.net/prod.php?which=48996 (http://www.pouet.net/prod.php?which=48996)
Title: Re: [2BUTTON] monoPong-1k
Post by: Shockwave on January 29, 2008
Yeah, I saw that!

Wouldn't it be cool if your version of Pong has started a trend? :D
Title: Re: [2BUTTON] monoPong-1k
Post by: Tetra on January 29, 2008
Nice 1 Benny1 :)

I still got a pong machine somewhere :D
Title: Re: [2BUTTON] monoPong-1k
Post by: benny! on January 29, 2008
Yeah, I saw that!

Wouldn't it be cool if your version of Pong
has started a trend? :D

Yeah, back to basics 8-)


Nice 1 Benny1 :)

I still got a pong machine somewhere :D

A real pong machine ??? Awesome. Post if
picture of it if possible :-O
Title: Re: [2BUTTON] monoPong-1k
Post by: Pixel_Outlaw on January 29, 2008
P_O Funfact: Some people thought that Pong was transmitted from a television station to the machine that they were playing.  :whisper:
Title: Re: [2BUTTON] monoPong-1k
Post by: benny! on January 30, 2008
P_O Funfact: Some people thought that Pong was transmitted from a television station to the machine that they were playing.  :whisper:

 ;D really ? lol
Title: Re: [2BUTTON] p1nkPong [updated!]
Post by: benny! on February 03, 2008
Hey,

because of so much optimizing help from
the forum (esp. taj) - here is a new ver-
sion of the actual game.

The game is now called p1nkPong !!!


Changelog

- added sound
- added scoring system
- added game loop (game loops infinite
  until you press ESC
)
- changed controls (use UP/DOWN cursor)
- updated color-scheme (ref. title)


Title: Re: [2BUTTON] p1nkPong [updated!]
Post by: taj on February 03, 2008
Glow!!

Err..edit...I was sure this was glowing last night: I'll put that down to my bad eyesight.

OK, this is much more playable now.
Those binary bars are a very novel solution to not having sprintf available to do a score.

Taj
Title: Re: [2BUTTON] p1nkPong [updated!]
Post by: Shockwave on February 03, 2008
Wouldn't it be cool if the ball collided with the score too? :)
Title: Re: [2BUTTON] p1nkPong [updated!]
Post by: benny! on February 03, 2008
@taj:
Whatever it was - please send me some of the stuff
you drank last night  ;)


@shocky:
What a great idea - but I guess not possible in the
spare 8 bytes. Personally, the project is closed for me.
Although it could be optimized even more I guess - I
have so many new ideas already. I really learned a lot
with this project thanks to this wonderful community!
Title: Re: [2BUTTON] p1nkPong [updated!]
Post by: Rbz on February 03, 2008
@benny1: very good update, more fun to play now  :goodpost: