All pastes #435574 Raw Edit

Something

public cpp v1 · immutable
·published 2007-04-12 00:14 UTC
rendered paste body
//****************************************************************************// table.hclass Table {public:	void DrawScore();	void static DrawTable(BITMAP *);};//****************************************************************************// table.cpp#include <allegro.h>#include "table.h"void Table::DrawTable(BITMAP *backBuffer){	acquire_screen();	rect(backBuffer, 0, 0, 639, 479, makecol(255,255,255));	line(backBuffer, 320, 0, 320, 479, makecol(255,255,255));	draw_sprite(screen, backBuffer, 0, 0);	release_screen();}//****************************************************************************// paddle.hclass Paddle {public:	Paddle();		// Default constructor	void PaddleMove(bool, BITMAP *);private:	int p_size_x;	// Width of the paddle	int p_size_y;	// Height of the paddle	int p_temp_y;	};//****************************************************************************// paddle.cpp#include <allegro.h>#include "paddle.h"Paddle::Paddle() {	p_size_x = 10;	p_size_y = 50;}void Paddle::PaddleMove(bool firstPlayer, BITMAP *backBuffer){	char up, down;	int p_x, p_y;		if (firstPlayer) {		up = key[KEY_A];		down = key[KEY_Z];		p_x = 20;		p_y = 220;	} else {		up = key[KEY_L];		down = key[KEY_M];		p_x = 620 - p_size_x;		p_y = 220;	}	p_temp_y = p_y;	if(up && p_y > 0) {		--p_y;	} else if(down && p_y < 480 - p_size_y) {		++p_y;	}     	acquire_screen();	rectfill(backBuffer, p_x, p_temp_y, p_x + p_size_x, p_y + p_size_y, makecol(0, 0, 0));	rectfill(backBuffer, p_x, p_y, p_x + p_size_x, p_y + p_size_y, makecol(255, 255, 255));	draw_sprite(screen, backBuffer, 0, 0);	release_screen();	rest(50);}//****************************************************************************// main.cpp#include <allegro.h>#include "table.h"#include "paddle.h"BITMAP *backBuffer;int main(){		allegro_init();	install_keyboard();	set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);	backBuffer = create_bitmap(640, 480); 	clear_to_color(backBuffer, makecol(0,0,0));	Paddle p1, p2;	while(!key[KEY_ESC]){		Table::DrawTable(backBuffer);		p1.PaddleMove(true, backBuffer);		p2.PaddleMove(false, backBuffer);	}	return 0;}END_OF_MAIN();