i have been learning C and i have got most of the basics down and i would like to start my first project and i would like to start a pong game in C and was wondering how i would go about making it from scratch and its for my pc where i use the mouse as the paddle
so any idear how i could start ? please thank u
also any other idears on starting projects since im still only coding in the console
Pong Game info
Started by shadowhound, Jan 27 2009 01:33 PM
7 replies to this topic
#1
Posted 27 January 2009 - 01:33 PM
|
|
|
#2
Posted 27 January 2009 - 01:57 PM
^_^ I just started learning this myself, you'll need things like:
Oh, and
#include <allegro.h>
int x = 10;
int y = 10;
int main()
{
/* we need to use allegro_init to install the files we need. */
allegro_init();
/* install_keyboard allows the user
install_keyboard();
/* this changes the resolution 640x480 */
set_gfx_modoe( GFX_AUTODETECT, 640, 480, 0, 0);
/* this reads which keys are pressed. */
while ( !key[KEY_ESC] ){
/* clear_keybuf is like fflush(stdin) it's to clear all saved buttons pressed.
clear_keybuf();
/* acquire_screen is used to let allegro know that we need to draw to the screen. */
acquire_screen();
textout_ex( screen, font, " ", x, y, makecol( 0, 0, 0), makecol( 0, 0, 0) );
/* the --y ++y ++x --x refer to the axis like from graphs. */
if (key[KEY_UP]) --y; /* --y means up */
else if (key[KEY_DOWN]) ++y; /* ++y means down */
else if (key[KEY_RIGHT]) ++x; /* ++x means right */
else if (key[KEY_LEFT) --x; /* --x means left */
/* textout_ex will draw text to the screen
* it requires seven parameters, the first is where you want it to right too
* second is type of font to be used, third is what text to draw to the screen
* next two parameters are where you want it to be drawn.
* 0, 0 would be top left, x will move it right/y will mmove it down.
* next is colour of text, makecol() which takes 3 parameters.
* first is the intensity of the red, the green, and the blue.
* the final parameter is background colour!
*/
textout_ex( screen, font "@", x, y, makecol( 255, 0, 0), makecol( 0, 0, 0) );
/* release_screen is used to let go of the screen, so we are no longer drawing to it. */
release_screen();
/* Rest is used to pause the program for a set amount of milliseconds */
rest(50);
}
return 0;
}
END_OF_MAIN();
Oh, and
//circle and circlefill both draw circles, the difference is that circlefill
//will fill with the colour specified in the last parameter, while circle()
//simply draws the outline. The second and third paramater specifies the position
//the fourth defines the radius of the circle.
circle( screen, 20, 20, 10, makecol( 255, 0, 0));
circlefill( screen, 50, 50, 25, makecol( 0,255, 0));
#3
Posted 28 January 2009 - 06:08 AM
Drawing directly to the screen, even if you acquire it, has enormous speed penalties. It's better to create a bitmap, draw to that, and blit the complete frame to the screen. That way is faster and in between draw operations, you won't have frames where, eg, the paddles are drawn but the score isn't.
#4
Posted 28 January 2009 - 09:44 AM
okay got a little problem im coding this pong game via a console app i dunno if this is right but when i complie it it tells me in the debug section.
Pong Demo - Debug" uses an invalid compiler. Skipping...
Nothing to be done.
also im coding in code::blocks so do i need anything adding like plugins or librays or anything ?
Pong Demo - Debug" uses an invalid compiler. Skipping...
Nothing to be done.
also im coding in code::blocks so do i need anything adding like plugins or librays or anything ?
#5
Posted 28 January 2009 - 01:05 PM
#6
Posted 29 January 2009 - 05:04 AM
okay i figured an easy way to download the libray files using Dev C++ all i do is go to Tools> Check for updates/packegs > check the devpacks
and find it in there and download :D:D:D so i know now that works :) but i tryed compileing it and got an error on
the error is
25 C:\Dev-Cpp\Marks Projects\main2.c syntax error before string constant
i don't know what it means i understand the code sort of
and find it in there and download :D:D:D so i know now that works :) but i tryed compileing it and got an error on
textout_ex( screen, font "@", x, y, makecol( 255, 0, 0), makecol( 0, 0, 0) );
the error is
25 C:\Dev-Cpp\Marks Projects\main2.c syntax error before string constant
i don't know what it means i understand the code sort of
#7
Posted 29 January 2009 - 07:03 AM
“You may be disappointed if you fail, but you are doomed if you don't try.”
- Beverly Sills
- Beverly Sills
#8
Posted 29 January 2009 - 09:07 AM
the link has a bit of usefull information im understanding the programming better now the only thing that needs adding is adding of the bitmaps i recon but im searching around for informaction


Sign In
Create Account


Back to top









