[ create a new paste ] login | about

Link: http://codepad.org/5S3UZ4wc    [ raw code | output | fork ]

C++, pasted on Feb 22:
#include <allegro5\allegro.h>
#include <allegro5\allegro_primitives.h>
#include <allegro5\allegro_image.h>
#include <allegro5\allegro_font.h>
#include <allegro5\allegro_ttf.h>

enum location{X,Y};

int main()
{
	bool done = FALSE;
	bool redraw = FALSE;
	bool drawanim = FALSE; //draw the saved animation
	bool getxy = FALSE; //get and add x y to array
	

	int bitmapHeight;
	int bitmapWidth;

	int width = 640 - 1;
	int height = 480 - 1;
	int FPS = 60;
	int max = 60; //max size of x and y array

	//to save the location of the mouse 
	int *draw_x = new int[max];
	int *draw_y = new int[max];
	int n = 0;
	int a = 0;

	if(!al_init())
		return -1;

	//create important stuff
	ALLEGRO_DISPLAY *display = NULL;
	ALLEGRO_TIMER *timer = NULL;
	ALLEGRO_EVENT_QUEUE *event_queue = NULL;
	ALLEGRO_BITMAP *bitmap = NULL;
	ALLEGRO_FONT *arial = NULL;

	//init everything
	al_install_keyboard();
	al_install_mouse();
	al_init_primitives_addon();
	al_init_image_addon();
	al_init_font_addon();
	al_init_ttf_addon();

	//initialize allegro font
	arial = al_load_font("arial.ttf",24,0);

	//initialize bitmap
	bitmap = al_load_bitmap("Un 1.png");
	bitmapHeight = al_get_bitmap_height(bitmap);
	bitmapWidth = al_get_bitmap_width(bitmap);

	//initialize display
	display = al_create_display(width, height);
	al_clear_to_color(al_map_rgb(255,255,255));
	al_flip_display();

	//initialize timer
	timer = al_create_timer(1.0/FPS);

	//initialize and register event sources
	event_queue = al_create_event_queue();
	al_register_event_source(event_queue,al_get_keyboard_event_source());
	al_register_event_source(event_queue,al_get_mouse_event_source());
	al_register_event_source(event_queue,al_get_display_event_source(display));
	al_register_event_source(event_queue,al_get_timer_event_source(timer));
	al_start_timer(timer);

	while(!done)
	{

		ALLEGRO_EVENT ev;
		al_wait_for_event(event_queue, &ev);
		
		if(ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE)
		{
			done = true;
		}

		if(ev.type == ALLEGRO_EVENT_KEY_DOWN)
		{
			if(ev.keyboard.keycode == ALLEGRO_KEY_ESCAPE)
				done = TRUE;
		}
		//if draw anim true
		//draw bitmap, using draw_x and draw_y
		//on finish, set redraw equal to false
		//wait 5 seconds and then exit game loop
		if(!drawanim)
		{
			if (n = max)
			{
				max = max + 60;

				int* tempx = new int[max];
				for(int i = 0; i < n; i++){
					tempx[i] = draw_x[i];
				}

				int* tempy = new int[max];
				for(int i = 0; i < n;i++){
					tempy[i] = draw_y[i];
				}

				delete[] draw_x;
				delete[] draw_y;

				draw_x = tempx;
				draw_y = tempy;
			}
			if(ev.type == ALLEGRO_EVENT_MOUSE_BUTTON_DOWN)
			{
				//add specification for left mouse button
				getxy = TRUE;
			}
			if(ev.type == ALLEGRO_EVENT_MOUSE_BUTTON_UP)
			{
				drawanim = true;
				getxy = FALSE;
			}
			if(ev.type == ALLEGRO_EVENT_MOUSE_AXES && getxy == TRUE)
			{
				draw_x[n] = ev.mouse.x;
				draw_y[n] = ev.mouse.y;
				
				redraw = TRUE;
			}

				

			if(redraw == TRUE && al_is_event_queue_empty(event_queue))
			{
				al_draw_pixel(draw_x[n],draw_y[n],al_map_rgb(0,0,0));
				
				al_flip_display();
			
				redraw = FALSE;
			}
			if(ev.type == ALLEGRO_EVENT_TIMER)
			{
				n = n + 1;
			}
		}else{
			al_draw_textf(arial,al_map_rgb(0,0,0),400,100,0,"%i",n);
		
			al_draw_bitmap(bitmap,draw_x[a],draw_y[a],0);
			al_flip_display();
			drawanim == FALSE;
			a= a+1;
		}
	}

	al_destroy_display(display);
	al_destroy_timer(timer);
	al_destroy_event_queue(event_queue);
	delete [] draw_x;
	delete [] draw_y;

	return 0;
}


Output:
1
2
3
4
5
6
7
8
Line 29: error: allegro5\allegro.h: No such file or directory
Line 40: error: allegro5\allegro_primitives.h: No such file or directory
Line 35: error: allegro5\allegro_image.h: No such file or directory
Line 34: error: allegro5\allegro_font.h: No such file or directory
Line 33: error: allegro5\allegro_ttf.h: No such file or directory
In function 'int main()':
Line 11: error: 'FALSE' was not declared in this scope
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: