|
Having trouble using tiled with allegro 5 |
ISDcaptain
Member #15,087
May 2013
|
I downloaded the header file from here this is my code, very short: 1int x = 1;
2
3#include <allegro5/allegro.h>
4#include <allegro5/allegro_native_dialog.h>
5#include <allegro5/allegro_image.h>
6#include "allegro_tiled.h"
7#include <iostream>
8using namespace std;
9
10
11#define WIDTH 800
12#define HEIGHT 600
13#define FPS 60
14#define MAP_FOLDER "data/maps"
15
16int main()
17{
18 al_init();
19 if(!al_init())
20 {
21 al_show_native_message_box(NULL, NULL, NULL, "Tiled Test", NULL, NULL);
22 }
23
24 ALLEGRO_DISPLAY *display;
25 al_set_new_display_flags(ALLEGRO_RESIZABLE | ALLEGRO_WINDOWED);
26 display = al_create_display(WIDTH, HEIGHT);
27 al_set_window_title(display, "Tiled Test");
28
29 //Init all subsystem
30 al_install_keyboard();
31 ALLEGRO_KEYBOARD_STATE keyState;
32 al_init_image_addon();
33
34 //create timer
35 ALLEGRO_TIMER *timer;
36 timer = al_create_timer(1.0/FPS);
37
38 //create event queue
39 ALLEGRO_EVENT_QUEUE *event_queue;
40 event_queue = al_create_event_queue();
41
42 //Register the event queue
43 al_register_event_source(event_queue, al_get_keyboard_event_source());
44 al_register_event_source(event_queue, al_get_timer_event_source(timer));
45 al_register_event_source(event_queue, al_get_display_event_source(display));
46
47 //Load the map
48 ALLEGRO_MAP *map = NULL;
49 map = al_open_map(MAP_FOLDER, "zelda1.tmx");
50 int map_total_width = al_get_map_width(map) * al_get_tile_width(map);
51 int map_total_height = al_get_map_height(map) * al_get_tile_height(map);
52
53 bool done= false;
54
55 //start the timer
56 al_start_timer(timer);
57
58 while(!done)
59 {
60 ALLEGRO_EVENT events;
61 al_wait_for_event(event_queue, &events);
62
63 if(events.type == ALLEGRO_EVENT_DISPLAY_CLOSE)
64 {
65 done = true;
66 }
67
68 al_clear_to_color(al_map_rgb(0,0,0));
69 al_draw_map(map, map_total_width, map_total_height, NULL);
70 al_flip_display();
71 }
72
73
74 return 0;
75}
I keep on getting these error: |
DanielH
Member #934
January 2001
|
You have the headers, but how is your program access the source? Just like linking the allegro library, but you have to link to the library or add the source to your project. |
ISDcaptain
Member #15,087
May 2013
|
I have the .h file in my project folder. |
Dizzy Egg
Member #10,824
March 2009
|
You can't just use the .h file! You have to link against the library that contains the functions described in the header file...
---------------------------------------------------- |
|