Author Topic: [2BUTTON] p1nkPong [updated!]  (Read 16320 times)

0 Members and 1 Guest are viewing this topic.

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
[2BUTTON] p1nkPong [updated!]
« 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]
« Last Edit: February 03, 2008 by benny! »
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Offline Buckethead

  • C= 64
  • **
  • Posts: 58
  • Karma: 30
    • View Profile
Re: [2BUTTON] monoPong-1k
« Reply #1 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.
« Last Edit: January 27, 2008 by Buckethead »
Challenge Trophies Won:

Offline Paul

  • Pentium
  • *****
  • Posts: 1490
  • Karma: 47
    • View Profile
Re: [2BUTTON] monoPong-1k
« Reply #2 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.
I will bite you - http://s5.bitefight.se/c.php?uid=31059
Challenge Trophies Won:

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: [2BUTTON] monoPong-1k
« Reply #3 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 ??=
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: [2BUTTON] monoPong-1k
« Reply #4 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.
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Offline Buckethead

  • C= 64
  • **
  • Posts: 58
  • Karma: 30
    • View Profile
Re: [2BUTTON] monoPong-1k
« Reply #5 on: January 27, 2008 »
Benny: I never run a 1K Windows game before. :)
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: [2BUTTON] monoPong-1k
« Reply #6 on: January 27, 2008 »
Congratulations for getting a game into 1kb! You have spare bytes too :)
Refresh was constant and smooth here.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: [2BUTTON] monoPong-1k
« Reply #7 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.

...
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:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: [2BUTTON] monoPong-1k
« Reply #8 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 :)
Challenge Trophies Won:

Offline taj

  • Bytes hurt
  • DBF Aficionado
  • ******
  • Posts: 4810
  • Karma: 189
  • Scene there, done that.
    • View Profile
Re: [2BUTTON] monoPong-1k
« Reply #9 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 :-)
Challenge Trophies Won:

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: [2BUTTON] monoPong-1k
« Reply #10 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 :-)

;-)

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

Challenge Trophies Won:

Offline Paul

  • Pentium
  • *****
  • Posts: 1490
  • Karma: 47
    • View Profile
Re: [2BUTTON] monoPong-1k
« Reply #11 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.

« Last Edit: January 27, 2008 by Paul »
I will bite you - http://s5.bitefight.se/c.php?uid=31059
Challenge Trophies Won:

Offline Pixel_Outlaw

  • Pentium
  • *****
  • Posts: 1382
  • Karma: 83
    • View Profile
Re: [2BUTTON] monoPong-1k
« Reply #12 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!
Challenge Trophies Won:

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: [2BUTTON] monoPong-1k
« Reply #13 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:

Offline va!n

  • Pentium
  • *****
  • Posts: 1432
  • Karma: 109
    • View Profile
    • http://www.secretly.de
Re: [2BUTTON] monoPong-1k
« Reply #14 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!
« Last Edit: January 28, 2008 by va!n »
- 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:

Offline va!n

  • Pentium
  • *****
  • Posts: 1432
  • Karma: 109
    • View Profile
    • http://www.secretly.de
Re: [2BUTTON] monoPong-1k
« Reply #15 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.
- 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:

Offline va!n

  • Pentium
  • *****
  • Posts: 1432
  • Karma: 109
    • View Profile
    • http://www.secretly.de
Re: [2BUTTON] monoPong-1k
« Reply #16 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 ();
- 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:

Offline Positron

  • C= 64
  • **
  • Posts: 93
  • Karma: 7
    • View Profile
Re: [2BUTTON] monoPong-1k
« Reply #17 on: January 28, 2008 »
Well done Benny!

Very nice 1k. :clap:

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: [2BUTTON] monoPong-1k
« Reply #18 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.
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Offline WidowMaker [retired]

  • %010101
  • Atari ST
  • ***
  • Posts: 134
  • Karma: 21
  • %010101
    • View Profile
Re: [2BUTTON] monoPong-1k
« Reply #19 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!