All pastes #265639 Raw Edit

Stuff

public text v1 · immutable
·published 2006-12-03 14:20 UTC
rendered paste body
#include <allegro.h>
#include <stdlib.h>
#include "units.h"

volatile long speed_counter = 0;

void increment_speed_counter()
{
        speed_counter++;
}

int main()
{
    allegro_init();
    install_keyboard();
    install_timer();

	install_mouse();
	show_os_cursor(2);

	BITMAP *buffer = create_bitmap(800, 600);
	
		
    LOCK_VARIABLE(speed_counter); //Used to set the timer - which regulates the game's
    LOCK_FUNCTION(increment_speed_counter);//speed.

    install_int_ex(increment_speed_counter, BPS_TO_TIMER(60));

	set_color_depth(16);
    set_gfx_mode(GFX_AUTODETECT_WINDOWED , 800 , 600 , 0 , 0);

	show_os_cursor(MOUSE_CURSOR_ARROW);


	unit test;

	test.assign_bitmap();

	int nf = 0, nt = 0;

	while(!key[KEY_ESC])//If the user hits escape, quit the program
    {
        while(speed_counter > 0)
        {



			nt++;
            speed_counter--;

        } // speed counter loop


		test.draw();

		textprintf_ex(buffer, font, 0, 0, -1, 0, "%f", (float) nf * 60 / nt);

		blit(buffer, screen, 0, 0, 0, 0, 800, 600);//Blit the buffer
		nf++;
		clear(buffer);//Clear the buffer
	}

	return 0;
}
	


// units.cpp
#include "units.h"
#include "allegro.h"


void unit::draw()
{
	draw_sprite(buffer, hold , X, Y); // Draw image1
}

void unit::assign_bitmap()
{
	hold = load_bitmap("tank.bmp");
}


// units.h

#include "allegro.h"

class unit
{

	private:	
		BITMAP *hold;
		BITMAP *buffer;
		int X , Y;

	public:

		void assign_bitmap();
		void draw();

		unit();
};



void unit::unit()
{
	buffer = create_bitmap(800, 600);
}





g++  main.cpp units.cpp `allegro-config --cflags --static` -o testje


evert@gentoolinux ~/C++/allegro $ ./compile.sh
In file included from main.cpp:3:
units.h:26:2: warning: no newline at end of file
units.h:23: error: return type specification for constructor invalid
In file included from units.cpp:2:
units.h:26:2: warning: no newline at end of file
units.cpp:14:2: warning: no newline at end of file
units.h:23: error: return type specification for constructor invalid
/usr/local/include/allegro/datafile.h: In member function 'void unit::assign_bitmap()':
/usr/local/include/allegro/datafile.h:81: error: too few arguments to function 'BITMAP* load_bitmap(const char*, RGB*)'
units.cpp:13: error: at this point in file
evert@gentoolinux ~/C++/allegro $