Aug 15, 2014 at 1:00am UTC
i am just getting started and am not nearly done and havent even gotten around to getting the 'O' to happen yet. but am i at least getting there? tips?
only reason i am posting it now is because i am leaving for a while tonight and wont be back till later.
#include <allegro5/allegro.h>
#include <allegro5/allegro_image.h>
int main()
{
int POne = 1;
int PTwo = 0;
int one = 0;
int two = 0;
int three = 0;
int four = 0;
int five = 0;
int six = 0;
int seven = 0;
int eight = 0;
int nine = 0;
ALLEGRO_DISPLAY *Screen;
ALLEGRO_EVENT_QUEUE *EventQueue;
ALLEGRO_EVENT Event;
ALLEGRO_BITMAP *TicTacToe = NULL;
ALLEGRO_BITMAP *X = NULL;
ALLEGRO_BITMAP *O = NULL;
bool Exit = false;
al_init();
al_init_image_addon();
al_install_mouse();
Screen = al_create_display(96, 128);
EventQueue = al_create_event_queue();
al_register_event_source(EventQueue, al_get_display_event_source(Screen));
al_register_event_source(EventQueue, al_get_mouse_event_source());
TicTacToe = al_load_bitmap("TicTacToe.png");
X = al_load_bitmap("X.png");
O = al_load_bitmap("O.png");
al_draw_bitmap(TicTacToe, 0, 0, 0);
while(Exit == false)
{
ALLEGRO_EVENT ev;
al_wait_for_event(EventQueue, &ev);
al_draw_bitmap(TicTacToe, 0, 0, 0);
if(ev.type == ALLEGRO_EVENT_MOUSE_BUTTON_DOWN)
{
if(ev.mouse.button & 1 && POne == 1 && one == 0 && Event.mouse.x >= 0 && Event.mouse.x <= 32 && Event.mouse.y >= 0 && Event.mouse.y <= 32)
{
one = 1;
POne == 0;
PTwo == 1;
}
else if(ev.mouse.button & 2 && POne == 0 && one == 0 && Event.mouse.x >= 0 && Event.mouse.x <= 32 && Event.mouse.y >= 0 && Event.mouse.y <= 32)
{
one = 2;
POne == 1;
PTwo == 0;
}
if(ev.mouse.button & 1 && POne == 1 && two == 0 && Event.mouse.x >= 32 && Event.mouse.x <= 64 && Event.mouse.y >= 0 && Event.mouse.y <= 32)
{
two = 1;
POne == 0;
PTwo == 1;
}
else if(ev.mouse.button & 1 && POne == 0 && two == 0 && Event.mouse.x >= 32 && Event.mouse.x <= 64 && Event.mouse.y >= 0 && Event.mouse.y <= 32)
{
two = 2;
POne == 1;
PTwo == 0;
}
if(ev.mouse.button & 1 && POne == 1 && three == 0 && Event.mouse.x >= 64 && Event.mouse.x <= 96 && Event.mouse.y >= 0 && Event.mouse.y <= 32)
{
three = 1;
POne == 0;
PTwo == 1;
}
else if(ev.mouse.button & 1 && POne == 0 && three == 0 && Event.mouse.x >= 64 && Event.mouse.x <= 96 && Event.mouse.y >= 0 && Event.mouse.y <= 32)
{
three = 2;
POne == 1;
PTwo == 0;
}
if(ev.mouse.button & 1 && POne == 1 && four == 0 && Event.mouse.x >= 0 && Event.mouse.x <= 32 && Event.mouse.y >= 32 && Event.mouse.y <= 64)
{
four = 1;
POne == 0;
PTwo == 1;
}
else if(ev.mouse.button & 1 && POne == 0 && four == 0 && Event.mouse.x >= 0 && Event.mouse.x <= 32 && Event.mouse.y >= 32 && Event.mouse.y <= 64)
{
four = 2;
POne == 1;
PTwo == 0;
}
if(ev.mouse.button & 1 && POne == 1 && five == 0 && Event.mouse.x >= 32 && Event.mouse.x <= 64 && Event.mouse.y >= 32 && Event.mouse.y <= 64)
{
five = 1;
POne == 0;
PTwo == 1;
}
else if(ev.mouse.button & 1 && POne == 0 && five == 0 && Event.mouse.x >= 64 && Event.mouse.x <= 96 && Event.mouse.y >= 0 && Event.mouse.y <= 32)
{
five = 2;
POne == 1;
PTwo == 0;
}
if(ev.mouse.button & 1 && POne == 1 && six == 0 && Event.mouse.x >= 64 && Event.mouse.x <= 96 && Event.mouse.y >= 0 && Event.mouse.y <= 32)
{
six = 1;
POne == 0;
PTwo == 1;
}
else if(ev.mouse.button & 1 && POne == 0 && six == 0 && Event.mouse.x >= 64 && Event.mouse.x <= 96 && Event.mouse.y >= 0 && Event.mouse.y <= 32)
{
six = 2;
POne == 1;
PTwo == 0;
}
if(ev.mouse.button & 1 && POne == 1 && seven == 0 && Event.mouse.x >= 0 && Event.mouse.x <= 32 && Event.mouse.y >= 32 && Event.mouse.y <= 64)
{
four = 1;
POne == 0;
PTwo == 1;
}
else if(ev.mouse.button & 1 && POne == 0 && seven == 0 && Event.mouse.x >= 0 && Event.mouse.x <= 32 && Event.mouse.y >= 32 && Event.mouse.y <= 64)
{
four = 2;
POne == 1;
PTwo == 0;
}
if(ev.mouse.button & 1 && POne == 1 && eight == 0 && Event.mouse.x >= 32 && Event.mouse.x <= 64 && Event.mouse.y >= 32 && Event.mouse.y <= 64)
{
five = 1;
POne == 0;
PTwo == 1;
}
else if(ev.mouse.button & 1 && POne == 0 && eight == 0 && Event.mouse.x >= 64 && Event.mouse.x <= 96 && Event.mouse.y >= 0 && Event.mouse.y <= 32)
{
five = 2;
POne == 1;
PTwo == 0;
}
if(ev.mouse.button & 1 && POne == 1 && nine == 0 && Event.mouse.x >= 64 && Event.mouse.x <= 96 && Event.mouse.y >= 0 && Event.mouse.y <= 32)
{
six = 1;
POne == 0;
PTwo == 1;
}
else if(ev.mouse.button & 1 && POne == 0 && nine == 0 && Event.mouse.x >= 64 && Event.mouse.x <= 96 && Event.mouse.y >= 0 && Event.mouse.y <= 32)
{
six = 2;
POne == 1;
PTwo == 0;
}
}
if(one == 1)
{
al_draw_bitmap(X, 0, 0, 0);
}
else if(one == 2)
{
al_draw_bitmap(O, 0, 0, 0);
}
if(two == 1)
{
al_draw_bitmap(X, 32, 0, 0);
}
else if(two == 2)
{
al_draw_bitmap(O, 32, 0, 0);
}
if(three == 1)
{
al_draw_bitmap(X, 64, 0, 0);
}
else if(three == 2)
{
al_draw_bitmap(O, 64, 0, 0);
}
if(four == 1)
{
al_draw_bitmap(X, 0, 32, 0);
}
else if(four == 2)
{
al_draw_bitmap(O, 0, 32, 0);
}
if(five == 1)
{
al_draw_bitmap(X, 32, 32, 0);
}
else if(five == 2)
{
al_draw_bitmap(O, 32, 32, 0);
}
if(six == 1)
{
al_draw_bitmap(X, 64, 32, 0);
}
else if(six == 2)
{
al_draw_bitmap(O, 64, 32, 0);
}
if(seven == 1)
{
al_draw_bitmap(X, 0, 64, 0);
}
else if(seven == 2)
{
al_draw_bitmap(O, 0, 64, 0);
}
if(eight == 1)
{
al_draw_bitmap(X, 32, 64, 0);
}
else if(eight == 2)
{
al_draw_bitmap(O, 32, 64, 0);
}
if(nine == 1)
{
al_draw_bitmap(X, 64, 64, 0);
}
else if(nine == 2)
{
al_draw_bitmap(O, 64, 64, 0);
}
al_flip_display();
al_wait_for_event(EventQueue, &Event);
if(Event.type == ALLEGRO_EVENT_DISPLAY_CLOSE)
{
Exit = true;
}
}
return 0;
}