Пример #1
0
int main( void )
{
   int depth;   /* represents color depth */

   /* first, set up Allegro and the graphics mode */
   allegro_init(); /* initialize Allegro */
   install_keyboard(); /* install the keyboard for Allegro to use */
   
   depth = desktop_color_depth();  /* find out what color depth is on our computer */
   if (depth == 0)
	   depth = 32;
   set_color_depth( depth ); /* set the color depth to depth used by our computer */

   set_gfx_mode( GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0 ); /* set graphics mode */
   ball = load_bitmap( "ball.bmp", NULL ); /* load the ball bitmap */
   buffer = create_bitmap( SCREEN_W, SCREEN_H ); /* create buffer */
   ball_x = SCREEN_W / 2; /* give the ball its initial x-coordinate */
   ball_y = SCREEN_H / 2; /* give the ball its initial y-coordinate */
   srand( time( NULL ) ); /* seed the random function ... */
   direction = rand() % 4; /* and then make a random initial direction */

   while ( !key[KEY_ESC] ) /* until the escape key is pressed ... */
   {
      moveBall(); /* move the ball */
      /* now, perform double buffering */
      clear_to_color( buffer, makecol( 255, 255, 255 ) );
      blit( ball, buffer, 0, 0, ball_x, ball_y, ball->w, ball->h );
      blit( buffer, screen, 0, 0, 0, 0, buffer->w, buffer->h );    
      clear_bitmap( buffer );
   } /* end while */

   destroy_bitmap( ball ); /* destroy the ball bitmap */
   destroy_bitmap( buffer ); /* destroy the buffer bitmap */
   return 0;
} /* end function main */
Пример #2
0
Alleg4Display::Alleg4Display(int width, int height, int scale)
  : m_surface(NULL)
  , m_scale(0)
  , m_nativeCursor(kNoCursor)
  , m_restoredWidth(0)
  , m_restoredHeight(0)
{
  unique_display = this;

  if (install_mouse() < 0) throw DisplayCreationException(allegro_error);
  if (install_keyboard() < 0) throw DisplayCreationException(allegro_error);

#ifdef FULLSCREEN_PLATFORM
  set_color_depth(16);        // TODO Try all color depths for fullscreen platforms
#else
  set_color_depth(desktop_color_depth());
#endif

  if (set_gfx_mode(
#ifdef FULLSCREEN_PLATFORM
        GFX_AUTODETECT_FULLSCREEN,
#else
        GFX_AUTODETECT_WINDOWED,
#endif
        width, height, 0, 0) < 0)
    throw DisplayCreationException(allegro_error);

  show_mouse(NULL);
  setScale(scale);

#if _WIN32
  subclass_hwnd((HWND)nativeHandle());
#endif
}
Пример #3
0
void textgfx_init()
{
#ifdef UNIX
	strcpy(_xwin.application_name, "vitetris");
	strcpy(_xwin.application_class, "Vitetris");
#endif
	if (install_allegro(SYSTEM_AUTODETECT, &errno, NULL) != 0)
		exit(1);
#ifdef UNIX
	sigaction(SIGINT, NULL, &allegro_sigint_handler);
	signal(SIGINT, sigint_handler);
#endif
	load_pc8x16_font();
	set_window_title(VITETRIS_VER);
	set_close_button_callback(close_btn);
#ifndef UNIX
	/* Seems to cause seg fault later quite randomly on Linux  */
	int depth = desktop_color_depth();
	if (depth != 0)
		set_color_depth(depth);
#endif
	virt_screen = set_screen(getopt_int("", "fullscreen"));
	lang |= LATIN1;
	if (!font8x16) {
		font8x16 = font;
		textgfx_flags |= ASCII;
	}
	setattr_normal();
#if WIN32 && !ALLEGRO_USE_CONSOLE
	if (exists("stdout.tmp")) {
		FILE *fp;
		freopen("stdout2.tmp", "w", stdout);
		fp = fopen("stdout.tmp", "r");
		if (fp) {
			char line[80];
			int i;
			for (i=0; i < 25 && fgets(line, 80, fp); i++) {
				setcurs(0, i);
				i += printline(line);	
			}
			fclose(fp);
			if (i) {
				refreshscreen();
				if (!strncmp(line, "Press ", 6)) {
					install_keyboard();
					clear_keybuf();
					readkey();
					remove_keyboard();
				}
			}
		}
		freopen("stdout.tmp", "w", stdout);
		delete_file("stdout2.tmp");
	}
#endif
}
Пример #4
0
    /**
     * Initialises the Allegro application. This function creates the global
     * Gui object that can be populated by various examples.
     */
    void init()
    {
        // We simply initialise Allegro as we would do with any Allegro application.
        allegro_init();

        int bpp = desktop_color_depth();
        if (bpp == 0)
        {
            bpp = 16;
        }

        set_color_depth(bpp);

        if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0))
        {
            if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0))
            {
                throw FCN_EXCEPTION("Unable to set graphics mode");
            }
        }

        screenBuffer = create_bitmap(SCREEN_W, SCREEN_H);

        if (screenBuffer == NULL)
        {
            throw FCN_EXCEPTION("Unable to create a screen buffer");
        }

        install_keyboard();
        install_mouse();
        install_timer();

        // Now it's time to initialise the Guichan Allegro back end.

        imageLoader = new fcn::AllegroImageLoader();
        // The ImageLoader Guichan should use needs to be passed to the Image object
        // using a static function.
        fcn::Image::setImageLoader(imageLoader);
        graphics = new fcn::AllegroGraphics();
        // Set the target for the graphics object to be the doublebuffer
        // for the screen. Drawing to the screen directly is not a good
        // idea, as it will produce flicker, unless you use page flipping.
        graphics->setTarget(screenBuffer);
        input = new fcn::AllegroInput();

        // Now we create the Gui object to be used with this Allegro application.
        globals::gui = new fcn::Gui();
        // The Gui object needs a Graphics to be able to draw itself and an Input
        // object to be able to check for user input. In this case we provide the
        // Gui object with Allegro implementations of these objects hence making Guichan
        // able to utilise Allegro.
        globals::gui->setGraphics(graphics);
        globals::gui->setInput(input);
    }
Пример #5
0
int main( void )
{
    int depth;   /* represents color depth */

    /* first, set up Allegro and the graphics mode */
    allegro_init(); /* initialize Allegro */
    install_keyboard(); /* install the keyboard for Allegro to use */
    install_sound( DIGI_AUTODETECT, MIDI_AUTODETECT, NULL );

    depth = desktop_color_depth();  /* find out what color depth is on our computer */
    if (depth == 0)
        depth = 32;
    set_color_depth( depth ); /* set the color depth to depth used by our computer */

    set_gfx_mode( GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0 ); /* set graphics mode */
    ball = load_bitmap( "ball.bmp", NULL ); /* load the ball bitmap */
    bar = load_bitmap( "bar.bmp", NULL); /* load the bar bitmap */
    buffer = create_bitmap(SCREEN_W, SCREEN_H);/* create buffer */
    boing = load_sample( "boing.wav" ); /* load the sound file */
    pongFont = load_font( "pongfont.pcx", NULL, NULL ); /* load the font */
    ball_x = SCREEN_W / 2; /* give the ball its initial x-coordinate */
    ball_y = SCREEN_H / 2; /* give the ball its initial y-coordinate */
    barL_y = SCREEN_H / 2; /* give left paddle its initial y-coordinate */
    barR_y = SCREEN_H / 2; /* give right paddle its initial y-coordinate */
    scoreL = 0; /* set left player’s score to 0 */
    scoreR = 0; /* set right player’s score to 0 */
    srand( time( NULL ) ); /* seed the random function ... */
    direction = rand() % 4; /* and then make a random initial direction */

    while ( !key[KEY_ESC] )/* until the escape key is pressed ... */
    {
        moveBall(); /* move the ball */
        respondToKeyboard(); /* respond to keyboard input */
        /* now, perform double buffering */
        clear_to_color( buffer, makecol( 255, 255, 255 ) );
        blit( ball, buffer, 0, 0, ball_x, ball_y, ball->w, ball->h );
        blit( bar, buffer, 0, 0, 0, barL_y, bar->w, bar->h );
        blit( bar, buffer, 0, 0, 620, barR_y, bar->w, bar->h );
        /* draw text onto the buffer */
        textprintf_ex( buffer, pongFont, 75, 0, makecol( 0, 0, 0 ),
                       -1, "Left Player Score: %d", scoreL );
        textprintf_ex( buffer, pongFont, 400, 0, makecol( 0, 0, 0 ),
                       -1, "Right Player Score: %d", scoreR );
        blit( buffer, screen, 0, 0, 0, 0, buffer->w, buffer->h );
        clear_bitmap( buffer );
    } /* end while */

    destroy_bitmap( ball ); /* destroy the ball bitmap */
    destroy_bitmap( bar ); /* destroy the bar bitmap */
    destroy_bitmap( buffer ); /* destroy the buffer bitmap */
    destroy_sample( boing ); /* destroy the boing sound file */
    destroy_font( pongFont ); /* destroy the font */
    return 0;
} /* end function main */
Пример #6
0
int main(int argc, char *argv[])
{	
	//////////////////////////////////////////////////////////////////////////
	allegro_init(); // Initialize Allegro
	install_keyboard();
	set_close_button_callback(quit_function);
	FreeImage_Initialise(TRUE);

	create_cycles_table();

	Configuration cfg;
	cfg.Process(argc, argv);

	if (cfg.continue_processing)
	{
		quiet=true;
		rasta.Resume();
		rasta.cfg.continue_processing=true;
		quiet=false;
	}
	else
		rasta.SetConfig(cfg);

	screen_color_depth = desktop_color_depth();
	get_desktop_resolution(&desktop_width,&desktop_height);
	set_color_depth(screen_color_depth);

	if (!rasta.cfg.preprocess_only)
	{
		if (desktop_width>=320*3)
			set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320*3,480,0,0); 
		else
			set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480,0,0); // Change our graphics mode to 640x480

		set_display_switch_mode(SWITCH_BACKGROUND);
		set_close_button_callback(close_button_procedure);

		set_window_title(rasta.cfg.command_line.c_str());
	}
	else
		quiet=true;

	rasta.LoadAtariPalette();

	rasta.LoadInputBitmap();
	if (rasta.ProcessInit())
	{
		rasta.FindBestSolution();
		rasta.SaveBestSolution();
	}
	return 0; // Exit with no errors
}
Пример #7
0
void init() {
	int depth, res;
	allegro_init();
	depth = desktop_color_depth();
	if (depth == 0) depth = 32;
	set_color_depth(depth);
	res = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 960, 600, 0, 0);
	if (res != 0) {
		allegro_message(allegro_error);
		exit(-1);
	}
	install_keyboard();
}
Пример #8
0
void init() 
{
	int depth, res;
	allegro_init();
	depth = desktop_color_depth();
	if (depth == 0) depth = 32;
	set_color_depth(depth);
	res = set_gfx_mode(GFX_AUTODETECT, 1440, 900, 0, 0);
	if (res != 0) {	allegro_message(allegro_error);	exit(-1);}
	install_timer();
	install_keyboard();
	install_mouse();
}
Пример #9
0
  Alleg4Display(int width, int height, int scale)
    : m_surface(NULL)
    , m_scale(0) {
    unique_display = this;

    if (install_mouse() < 0) throw DisplayCreationException(allegro_error);
    if (install_keyboard() < 0) throw DisplayCreationException(allegro_error);

#ifdef FULLSCREEN_PLATFORM
    set_color_depth(16);        // TODO Try all color depths for fullscreen platforms
#else
    set_color_depth(desktop_color_depth());
#endif

    if (set_gfx_mode(
#ifdef FULLSCREEN_PLATFORM
                     GFX_AUTODETECT_FULLSCREEN,
#else
                     GFX_AUTODETECT_WINDOWED,
#endif
                     width, height, 0, 0) < 0)
      throw DisplayCreationException(allegro_error);

    setScale(scale);

    m_queue = new Alleg4EventQueue();

    // Copy the initial queue to the display queue
    {
      base::scoped_lock hold(unique_display_mutex);
      Event ev;
      while (initial_queue.try_pop(ev))
        m_queue->queueEvent(ev);
    }

    // Add a hook to display-switch so when the user returns to the
    // screen it's completelly refreshed/redrawn.
    LOCK_VARIABLE(display_flags);
    LOCK_FUNCTION(display_switch_in_callback);
    set_display_switch_callback(SWITCH_IN, display_switch_in_callback);

#ifdef ALLEGRO4_WITH_RESIZE_PATCH
    // Setup the handler for window-resize events
    set_resize_callback(resize_callback);
#endif

#if WIN32
    subclass_hwnd((HWND)nativeHandle());
#endif
  }
Пример #10
0
// changes to some widescreen or fullscreen mode
bool setup_gfx()
{
  int dsk_w, dsk_h;
  int w = 720;
  int h = 480;
  int bpp = 16;

  if (get_desktop_resolution(&dsk_w, &dsk_h) == 0) {
    bpp = desktop_color_depth();
    if (bpp == 8)
      bpp = 16;

  if (dsk_w >= 720 && dsk_h >= 480) {
      w = 720;
      h = 480;
    }
    else {
      w = 360;
      h = 240;
    }
  }

  set_color_depth(bpp);

  int gfx_mode = gfx_fullscreen ? GFX_AUTODETECT_FULLSCREEN:
				  GFX_AUTODETECT_WINDOWED;

  if (gfx_widescreen) {
    if (set_gfx_mode(gfx_mode, w, h, 0, 0) == 0 ||
	set_gfx_mode(GFX_AUTODETECT_WINDOWED, w, h, 0, 0) == 0 ||
	set_gfx_mode(GFX_AUTODETECT_FULLSCREEN, w, h, 0, 0) == 0) {
      _gfx_w = 360;
      return true;
    }
  }

  if (set_gfx_mode(gfx_mode, 640, 480, 0, 0) < 0 ||
      set_gfx_mode(gfx_mode, 320, 240, 0, 0) < 0 ||
      set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0) < 0) {
    // error, no graphics mode
    return false;
  }

  _gfx_w = 320;

  // success
  return true;
}
Пример #11
0
void init() {
    int depth, res;
    allegro_init();
    depth = desktop_color_depth();
    if (depth == 0) depth = 32;
    set_color_depth(depth);
    res = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 800, 600, 0, 0);
    if (res != 0) {
        allegro_message(allegro_error);
        exit(-1);
    }

    install_timer();
    install_keyboard();
    /* add other initializations here */
}
/* 
	Este metodo inicializa todos los componentes de allegro para la ejecucion
	del programa, la pantalla, la ventanta, el mouse y el teclado.
*/
void init() {	
	int depth, res;
	allegro_init();
	depth = desktop_color_depth();
	if (depth == 0) depth = 32;
	set_color_depth(depth);
	//detecta drivers de video automaticamente
	res = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
	if (res != 0) {
		allegro_message(allegro_error);
		exit(-1);
	}

	install_timer();
	install_keyboard();
	install_mouse();
	show_mouse(screen);
}
Пример #13
0
void init() {
	int depth, res;
	allegro_init();
	depth = desktop_color_depth();
	if (depth == 0) depth = 32;
	set_color_depth(depth);
	res = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
	if (res != 0) {
		allegro_message(allegro_error);
		exit(-1);
	}
 install_sound(DIGI_AUTODETECT,MIDI_AUTODETECT, NULL);
	  install_sound_input(DIGI_AUTODETECT,MIDI_NONE);
	install_timer();
	install_keyboard();
	install_mouse();
	/* add other initializations here */
}
Пример #14
0
void init() {
	int depth, res;
	allegro_init();
	depth = desktop_color_depth();
	if (depth == 0) depth = 32;
	set_color_depth(depth);
	res = set_gfx_mode(GFX_AUTODETECT_FULLSCREEN, 1280, 720, 0, 0); //WINDOWSED / FULLSCREEN
	if (res != 0) {
		allegro_message(allegro_error);
		exit(-1);
	}

	install_timer();
	install_keyboard();
	install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL);

	/* add other initializations here */
}
Пример #15
0
/**
 * arquivo de exemplo de funções de sprite
 *
 * @author: Cantídio Oliveira Fontes
 * @since: 13/06/2008
 * @final: 14/06/2008
 */
void init()
{
	int depth;
	if (allegro_init() != 0)	exit(1);
	install_timer();
	install_keyboard();
	key[KEY_ENTER]=0;
	install_mouse();
	depth = desktop_color_depth();
	if (depth == 0) depth = 16;
	set_color_depth(depth);

	if(set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 240, 0, 0))
	{
		if (set_gfx_mode(GFX_AUTODETECT, 320, 240, 0, 0))
			exit(1);
	}
}
void init()
{
	int depth, res;
	allegro_init();
	depth = desktop_color_depth();
	if (depth == 0) depth = 32;
	set_color_depth(depth);
	res = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 800, 600, 0, 0);
	
    if (res != 0)
    {
		allegro_message(allegro_error);
		exit(-1);
	}

	install_timer();
	install_keyboard();
	install_mouse();
	
	set_window_title("Travelling Salesman Problem by Junian Triajianto - 5108100038");
}
Пример #17
0
void lancerAllegro(int largeur, int hauteur)
{
    // BUFFER d'affichage
    BITMAP *page;

    allegro_init();
    install_keyboard();

    /// OUVERTURE DU MODE GRAPHIQUE
    set_color_depth(desktop_color_depth());
    if (set_gfx_mode(GFX_AUTODETECT_WINDOWED,largeur,hauteur,0,0)!=0)
    {
        allegro_message("Erreur graphique : %s", allegro_error);
        allegro_exit();
        exit(EXIT_FAILURE);
    }

    /// CREATION DU BUFFER D'AFFICHAGE à la taille de l'écran
    page=create_bitmap(SCREEN_W,SCREEN_H);
    clear_bitmap(page);
}
Пример #18
0
void init() {
	int depth, res;
	allegro_init();
	alpng_init();
	alfont_init();
	depth = desktop_color_depth();
	if (depth == 0) depth = 32;
	set_color_depth(depth);
	res = set_gfx_mode(GFX_AUTODETECT_WINDOWED, SCREEN_WIDTH ,SCREEN_HEIGHT, 0, 0);
	if (res != 0) {
		allegro_message(allegro_error);
		exit(-1);
	}
	/* set the window title */
    set_window_title("Title");


	install_timer();
	install_keyboard();
	install_mouse();
	/* add other initializations here */
}
Пример #19
0
// <- FUNCTIONS -> //
void init() {
	int depth, res;	
	allegro_init();	
	depth = desktop_color_depth();	
	if (depth == 0) 
     depth = 32;    
	set_color_depth(depth);	
	res = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
	perform_creations();  //to create bitmaps, etc...
	if (res != 0) 
     {
		allegro_message(allegro_error);
		exit(-1);
	 }

	install_timer();
	install_keyboard();
	install_mouse();
	
	if(mouse_needs_poll() == true)
	  poll_mouse();
	/* add other initializations here */
}
Пример #20
0
/***
* Init function
*/
void Initr() {
	int depth, res;
	allegro_init();
	depth = desktop_color_depth();
	if (depth == 0) depth = 32;
	set_color_depth(depth);
	res = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 800, 600, 0, 0);
	if (res != 0) {
		allegro_message(allegro_error);
		exit(-1);
	}

	install_timer();
	install_keyboard();
	install_mouse();
	
	// Init time counter
	LOCK_VARIABLE(contadorTempo);
    LOCK_FUNCTION(contar_tempo);
    install_int_ex(contar_tempo, BPS_TO_TIMER(30)); // Count time at each 30 FPS
    
    // Init music
    install_sound(DIGI_AUTODETECT,MIDI_AUTODETECT,NULL);
    set_volume(255, 128); // volume setup

    MIDI *mid = load_midi("..\\recursos\\musica.mid");
    play_midi(mid,1);    
    
    // Init SFX
    sompulo = load_sample("..\\recursos\\pulo.wav");
    somponto = load_sample("..\\recursos\\ponto.wav");
    somdano = load_sample("..\\recursos\\dano.wav");
    
    //
    srand(time(NULL));
    
}
int main(int argc, char *argv[]) 
{ 
	allegro_init(); // Initialize Allegro 
	install_keyboard(); // Initialize keyboard routines 
	set_color_depth(desktop_color_depth()); // Set the color depth 
	set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0); // Change our graphics mode to 640x480
	
	/* Create a bitmap, and load the picture into memory */
		
	BITMAP *my_pic; //Declare a BITMAP called my_pic 
	my_pic = load_bitmap("picture.bmp", NULL); // Load our picture
	
	/* Here we will blit a masked bitmap; that is, it contains pixels that we want will
	 * be shown as transparent. In order to make transparent parts in a bitmap, you must 
	 * use the RGB color:
	 *  Red 255 
	 *  Green 0 
	 *  Blue 255
	 *
	 * This color will be the brightest pink possible. Any pixel in a bitmap that is this 
	 * color when you draw a bitmap using masked_bitmap or draw_sprite will be transparent. 
	 * masked_blit takes the same parameters as blit, so you can perform clipping if you wish.
	 */
	masked_blit(my_pic, screen, 0,0,0,0,572,473); //Draw the whole bitmap to the screen at (0,0)
	readkey(); // Wait untill a key is pressed
			
	/* The clear_keybuf function will just clear the keybuffer of any information. 
	 * We are calling this because we don't want the program to think a key is pressed when we 
	 * call readkey for the second time. Some computers are so fast that they may draw the upcoming 
	 * sprite and think that a key is still pressed from the previous keypress. 
	 * 
	 * Note that this isn't an efficient way of preventing the next chunk of code from thinking
	 * they key is still pressed. You will notice that if you hold down the key long enough, clearing
	 * the keybuffer seemingly has no effect (it still does clear the keyboard buffer, though) 
	 * and the program will simply look like it exits.
	 * There are better methods for preventing execution of portions of code until a key is actually
	 * released. This topic is not covered in this lesson.
	 */
	clear_keybuf();
			
	/* Here we will be using two new functions. 
	 * The function clear_bitmap does exactly what its name implies: it will clear a bitmap to color 0 (black).
	 *
	 * In this case, we want to clear the screen, which is a special kind of bitmap (but a bitmap nonetheless), 
	 * 
	 * After clearing the screen, we will be using the function draw_sprite. 
	 * Draw sprite is exactly the same as masked_blit except for the fact that it has no clipping capabilities.
	 * draw_sprite() will always draw the full, masked, bitmap. Also, notice that the source bitmap and 
	 * destination bitmap are in reverse order from the blit series of functions. When calling draw_sprite put 
	 * the bitmap you wish to draw to first, and the bitmap you are actually going to be drawing second.
	 *
	 *	When you run the program, you won't be able to tell the difference between masked_blit and draw_sprite.
	 */
	clear_bitmap(screen); 
	draw_sprite(screen, my_pic, 0,0);//Draw the bitmap at 0,0. 
	readkey(); //Wait for a keypress
	
	/* Destroy the bitmap, and exit the program. */
	destroy_bitmap(my_pic); //Release the bitmap data 
	return 0; // Exit with no errors 
} 
Пример #22
0
int main()
{
    Baslat();

    double first_screen=1;
    double still_run;
    int choose_control;
    int choose_tema;

    LOCK_VARIABLE(speed_counter);
    LOCK_FUNCTION(increment_speed_counter);
    install_int_ex(increment_speed_counter,BPS_TO_TIMER(60));

    BITMAP *bmp_first_screen = create_bitmap(SCREEN_WW,SCREEN_HH);
    BITMAP *bmp = create_bitmap(MAP_W,MAP_H);
    BITMAP *arka_fon_defter = load_bitmap("defter.bmp",NULL);
    BITMAP *arka_fon_su_damlasi = load_bitmap("su_damlasi.bmp",NULL);
    BITMAP *arka_fon_karatahta = load_bitmap("karatahta.bmp",NULL);
    BITMAP *sprite = load_bitmap("mouse_icon_purple.bmp",NULL);
    BITMAP *sprite_game = load_bitmap("mouse_icon_blue.bmp",NULL);
    color_feature_t yem_color;
    color_feature_t player_color;

    int depth;
    depth=desktop_color_depth();
    set_color_depth(depth);

    //ILK EKRAN
    still_run=screen_first(first_screen,bmp_first_screen,sprite);

    //PLAYER KONTROLU SECILIR
    choose_control=player_control(bmp_first_screen,sprite,still_run);

    //TEMA VE KARAKTER SECILIR
    choose_thema(bmp,sprite,still_run, &choose_tema, &yem_color, &player_color);

    //ARKA FON SECIMI
    if(choose_tema==1)
    {
        //OYUN
        game(still_run,bmp,arka_fon_defter,sprite_game,choose_control, yem_color, player_color);
    }

    else if(choose_tema==2)
    {
        //OYUN
        game(still_run,bmp,arka_fon_su_damlasi,sprite_game,choose_control, yem_color, player_color);
    }

    else
    {
        //OYUN
        game(still_run,bmp,arka_fon_karatahta,sprite_game,choose_control, yem_color, player_color);
    }

    destroy_bitmap (bmp);
    destroy_bitmap (arka_fon_defter);
    destroy_bitmap (arka_fon_su_damlasi);
    destroy_bitmap (arka_fon_karatahta);


    Bitir();
    return 0;
}
/////////////////////////////////////
//// MAIN ///////////////////////////
/////////////////////////////////////
int main(int argc, char *argv[])
{
 
/////////////////////////////////////
// START GUI SPECIFIC CODE //////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////
	int bpp; // color depth 
	int ret; // for processing return values
	
	//initialise allegro stuff
	allegro_init(); 
	install_keyboard(); 
	install_timer();

	bpp = desktop_color_depth();
	set_color_depth(bpp);
	
	/* Lets play the color depth game!  tries 32, 24, then 16 bit color modes */
	// set resolution to play intro movie
	ret = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
	/* did the video mode set properly? */
	if (ret != 0) {
		set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
		allegro_message("Error setting %d bit graphics mode\n%s\nLets try another color depth!", bpp, allegro_error);
		
		bpp = 32;
		set_color_depth(bpp);
		
		// set resolution
		ret = set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0);
		/* did the video mode set properly? */
		if (ret != 0) {
			set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
			allegro_message("Error setting %d bit graphics mode\n%s\nLets try another color depth!", bpp, allegro_error);

			bpp = 16;
			set_color_depth(bpp);

			// set resolution
			ret = set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0);
			/* did the video mode set properly? */
			if (ret != 0) {
				set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
				allegro_message("Error setting %d bit graphics mode\n%s\nIm all out of options. Exiting", bpp, allegro_error);
				return 1;
			}
		}
	}
	
///////////////////////////
// END OF GUI SPECIFIC //////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////

//////////////////////////
///// VARIABLES //////////
//////////////////////////

	CEdge edgelist; //the edges
	int besttour = MAX_DISTANCE*NUM_TOWNS; //best result ever
	int currtour = MAX_DISTANCE*NUM_TOWNS; //best result from last tour
	int bestant = -1; //stores ant that did really well and adds more phero to its trail
	CAnt colony[NUM_ANTS]; //the ants

	int i,j; //universal for loop counters
	
	int cycles=0;
	
	srand(time(NULL));		 //seed random number
	int limit;				//universal random number limit.. (rand()%limit will give a number between 0 and limit-1)

	// Start Cycling
	while (!key[KEY_ESC] && cycles < MAX_CYCLES) {
		
		textprintf(screen,font,5,5,makecol(255,0,0),"Press Esc to hault processing [Cycle %d]",cycles);
		
		//initialise the ants before they all do a tour	
		//sets each ants first town to somewhere random
		
		limit = NUM_TOWNS;
		for (i=0;i<NUM_ANTS;i++) {			
			//colony[i].SetTown(0,i); //set each ants first tour element to a town 
			colony[i].SetTown(0,rand()%limit); //random version
		}	
		
		
		//each time though loop add another node to each ants tour list 
		//starting at the 2nd node (the 1st node is already set)
		limit = NUM_TOWNS+1;				
		double distance;
		double pheromone;	
		double probability;
		double total;
		double p[NUM_TOWNS];

		for (int tourcount=1;tourcount<NUM_TOWNS;tourcount++) {
			
			for (i=0;i<NUM_ANTS;i++) { //for each ant.. add 1 more tour
				
				//reset probabilities
				probability=0;
				total=0;
				
				//calculate best probability from all possible new paths
				
				//loop through all remaining possible tours left on the current ant
				//each time through the loop calc probability and keep track of best
				int k;
				for (j=tourcount,k=0;j<NUM_TOWNS;j++,k++) {
					
					//get variables used to calc probability
					distance = edgelist.GetDistance(colony[i].GetTown(tourcount-1), colony[i].GetTown(j));
					pheromone = edgelist.GetPhero(colony[i].GetTown(tourcount-1), colony[i].GetTown(j));
					
					probability = pow(pheromone, ALPHA);
					probability = probability * pow(distance, -BETA);
					
					p[k] = probability;
					total += probability;
					
				}
				
				//choose new town based on probability
				int best = 0;
				for (j=0;j<k;j++) {
					
					if ((p[best]/total)  > (p[j]/total)) {
						//new best
						best = j; 
					}
					
				}
				
				//move current ant to new town
				colony[i].SetTown(tourcount, colony[i].GetTown(tourcount+best));
				
			}//for ant
		}
		

		//////////////////////////////////////
		//ants now have full tour lists
		//compute length of each ants list
		//////////////////////////////////////
		for (i=0;i<NUM_ANTS;i++) { //for each ant
			
			int distance = 0;
			
			//reset currtour
			currtour = MAX_DISTANCE*NUM_TOWNS;
			
			printf("\nant %d [%d",i,colony[i].GetTown(0));//display ants tour in console window
			
			for (int j=1;j<NUM_TOWNS;j++) { //for each edge in the ants tour
				
				printf(",%d",colony[i].GetTown(j));//display ants tour in console window
				distance += edgelist.GetDistance(colony[i].GetTown(j-1), colony[i].GetTown(j));
				
			}
			
			printf("]");//display ants tour in console window
			
			//add on loopback distance
			distance += edgelist.GetDistance(colony[i].GetTown(NUM_TOWNS-1), colony[i].GetTown(0));
			
			printf("=%d",distance);//display ants tour distance in console window

			//keep record of best tours
			if (distance < besttour) {
				besttour = distance;
				bestant = i; //we only add extra phero to a tour when a best tour "record" is broken
			}
			if (distance < currtour)
				currtour = distance;

			//store distance on ant
			colony[i].SetDistance(distance);
		}

		
		/////////////////////////
		//evaporate pheromones
		/////////////////////////
		edgelist.Evaporate(EVAP);


		//////////////////////////////////////////////////
		//lay new pheromones based on colony[i].distance
		//////////////////////////////////////////////////
		for (i=0;i<NUM_ANTS;i++) {
			
			double phero;
			
			for (int j=1;j<NUM_TOWNS;j++) { //for each edge in the ants tour
				
				phero = edgelist.GetPhero(colony[i].GetTown(j-1), colony[i].GetTown(j)); //get old phero
				phero = phero + QUE / colony[i].GetDistance(); //calc new phero
				
				//reinforce best path
				if (bestant != -1 && i == bestant) {
					phero += ADD_PHERO;
				}

				edgelist.SetPhero(colony[i].GetTown(j-1), colony[i].GetTown(j), phero);
			}
			
			//loop back 
			phero = edgelist.GetPhero(colony[i].GetTown(NUM_TOWNS-1), colony[i].GetTown(0)); //get old phero
			phero = phero + QUE / colony[i].GetDistance(); //calc new phero
			
			//reinforce best path
			if (bestant != -1 && i == bestant) {
				phero += ADD_PHERO;
				bestant = -1;
			}

			edgelist.SetPhero(colony[i].GetTown(NUM_TOWNS-1), colony[i].GetTown(0), phero); //set phero
		}

		
		/////////////////////////////
		//reset ants and do it again
		/////////////////////////////
		for (i=0;i<NUM_ANTS;i++) {
			
			colony[i].ResetAnt();
			
		}
				
		//cycle done
		
		cycles ++;
		Draw(cycles, currtour, besttour);

	}

	clear_keybuf();
	textprintf_centre(screen,font,SCREEN_W/2,SCREEN_H/2-60,makecol(255,0,0),"Best Tour = %d",besttour);
	textout_centre(screen,font,"Press a key to exit",SCREEN_W/2,SCREEN_H/2-40,makecol(255,0,0));
	readkey();

	return 0;
}
Пример #24
0
int main () {

    //allegro initializations
    allegro_init();
    install_keyboard();
    set_color_depth (desktop_color_depth() );
    set_gfx_mode (GFX_AUTODETECT_WINDOWED, screenWidth, screenHeight, 0, 0);

    LOCK_VARIABLE (timer);
    LOCK_FUNCTION (timestep);
    install_int_ex (timeStep, BPS_TO_TIMER (frameRate) );

    //bitmap initializations
    buffer = create_bitmap (screenWidth, screenHeight);

    //data initializations
    unsigned int n = 0;
    unsigned int i = 0;

    strcpy (planet[EARTH].name, "Earth");
    planet[EARTH].radius = 200;
    planet[EARTH].mass = 5.9742e2;
    planet[EARTH].fillColour = makecol (0, 255, 0);
    planet[EARTH].atmosphereColour = makecol (0, 0, 255);
    planet[EARTH].atmosphereHeight = 3;

    for (n = 0; n < PLANETMAX; n++) {
        planet[n] = planet[EARTH];
        planet[n].x = 1;
        planet[n].y = 1;
    }

    planet[EARTH].x = screenWidth / 2;
    planet[EARTH].y = screenHeight / 2;


    strcpy (craft[HAB].name, "Habitat");
    craft[HAB].fillColour = makecol (211, 211, 211);
    craft[HAB].engineColour = makecol (139, 0, 0);
    craft[HAB].radius = 30;
    craft[HAB].x = screenWidth / 2 + planet[EARTH].radius + craft[HAB].radius;
    craft[HAB].y = screenHeight / 2;
    craft[HAB].mass = 50000;

//    craft[HAB].x = planet[EARTH].x + 1;
//    craft[HAB].y = planet[EARTH].y + 1;

    strcpy (planet[MARS].name, "Mars");
    planet[MARS].x = planet[EARTH].x + planet[EARTH].radius + 800;
    planet[MARS].y = planet[EARTH].y;
    planet[MARS].radius = 150;
    planet[MARS].mass = 6e1;
    planet[MARS].fillColour = makecol (205, 164, 150);
    planet[MARS].atmosphereColour = makecol (160, 40, 40);
    planet[MARS].atmosphereHeight = 7;

    camera.zoom = pow (camera.actualZoom(), 1 / zoomMagnitude);
    camera.x = craft[HAB].x - (screenWidth / 4);
    camera.y = craft[HAB].y - (screenHeight / 4);

    camera.target = &craft[HAB];
    camera.reference = &planet[EARTH];

    while (!key[KEY_ESC]) {

        while (timer > 0) {

            input();

            for (i = 0; i < CRAFTMAX; i++)
                for (n = 0; n < PLANETMAX; n++) {
                    craft[i].gravitate (planet[n]);
                    craft[i].detectCollision (planet[n]);
                    planet[n].gravitate (craft[i]);
                }

//            for (i = 1; i < 4; i++)
//                for (n = 1; n < 4; n++) {
////					craft[i].gravitate (planet[n]);
//                    if (n != i)
//                        planet[n].gravitate (planet[i]);
//
//                    planet[n].detectCollision (planet[i]);
//                }

//            planet[EARTH].accX (2 * PI, 50);
//            planet[EARTH].accY (2 * PI, 50);

            for (n = 1; n < PLANETMAX; n++)
                planet[n].move();

            for (n = 0; n < CRAFTMAX; n++) {
                craft[n].turn();
                craft[n].fireEngine();
                craft[n].move();
            }

            camera.autoZoom();
            camera.shift();




            timer--;
        }

        drawGrid();

        for (n = 0; n < PLANETMAX; n++)
            planet[n].draw();

        for (n = 0; n < CRAFTMAX; n++)
            craft[n].draw();

//        craft[HAB].detectCollision (planet[EARTH]);

        debug();

        drawBuffer();

    }

    //end of program
    destroy_bitmap (buffer);
    return (0);
}
Пример #25
0
void initialize()
{
    char buf[1024];
    int i;

    // Do the libxml binary compatibility check
    initXML();

    // Initialise Allegro
    allegro_init();
    install_keyboard();
    install_mouse();
    install_timer();

    set_config_file("rpgedit.cfg");
    int grph_drv = (get_config_int("video", "fullscreen", 1)) ?
        GFX_AUTODETECT_FULLSCREEN : GFX_AUTODETECT_WINDOWED;
    int screen_w = get_config_int("video", "width", 800);
    int screen_h = get_config_int("video", "height", 600);

    if (get_config_int("tile_zoom", "grid", 1)) {
        showTileGrid = true;
    }

    set_color_conversion(
            (COLORCONV_TOTAL &
             ~(
                 COLORCONV_32A_TO_8  |
                 COLORCONV_32A_TO_15 |
                 COLORCONV_32A_TO_16 |
                 COLORCONV_32A_TO_24
              ))
            );

    int colordepth = 0;
    if (grph_drv == GFX_AUTODETECT_WINDOWED) {
        colordepth = desktop_color_depth();
    }
    if (colordepth == 0) {
        colordepth = 16;
    }
    set_color_depth(colordepth);

    if (set_gfx_mode(grph_drv, screen_w, screen_h, 0, 0) != 0) {
        set_color_depth(15);
        if (set_gfx_mode(grph_drv, screen_w, screen_h, 0, 0) != 0) {
            set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
            allegro_message("Unable to set graphic mode\n%s\n", allegro_error);
            exit(1);
        }
    }

    buffer = create_bitmap(SCREEN_W, SCREEN_H);


    // Initialize GUI look and feel stuff
    agup_init(aphoton_theme);
    gui_fg_color = agup_fg_color;
    gui_bg_color = agup_bg_color;
    gui_shadow_box_proc = d_agup_shadow_box_proc;
    gui_button_proc = d_agup_button_proc;
    gui_edit_proc = d_agup_edit_proc;
    gui_text_list_proc = d_agup_text_list_proc;

    engine_data = load_datafile("gui.dat");

    DATAFILE* font_data = find_datafile_object(engine_data, "SmallFont");
    if (font_data) font = (FONT*)font_data->dat;

    engine_font = font;

    DATAFILE* mouse_pointer = find_datafile_object(engine_data, "_MS_STD_BMP");
    if (mouse_pointer) set_mouse_sprite((BITMAP*)mouse_pointer->dat);

    DATAFILE* logo = find_datafile_object(engine_data, "MoonlightLogo");
    if (logo) about_dlg[1].dp = (BITMAP*)logo->dat;
    else console.log(CON_QUIT, CON_ALWAYS, "Error loading MoonlightLogo");

    console.log(CON_LOG, CON_ALWAYS, "Loading module \"data\"...");
    module = new Module("data");

    // Lua initialisation
    console.log(CON_LOG, CON_ALWAYS, "Initialising scripting environment...");
    initScripting();

    D_AUTOTEXT_STATUS.dp2 = status_message;
    D_AUTOTEXT_MAPINFO.dp2 = status_mapinfo;

    set_dialog_color(main_dlg, agup_fg_color, agup_bg_color);
    set_dialog_color(newmap_dlg, agup_fg_color, agup_bg_color);
    set_dialog_color(import_tileset_dlg, agup_fg_color, agup_bg_color);
    set_dialog_color(export_tileset_dlg, agup_fg_color, agup_bg_color);
    set_dialog_color(resizemap_dlg, agup_fg_color, agup_bg_color);
    set_dialog_color(about_dlg, agup_fg_color, agup_bg_color);


    // Position the dialogs on the screen
    int margin = 6;
    int zoom_w = get_config_int("tile_zoom", "zoom_width", 120) - 1;
    int zoom_h = get_config_int("tile_zoom", "zoom_height", 120) - 1;
    int x, y, w, h;

    // Main (back + menu)
    set_dialog_size(&main_dlg[0],          -2,                -2,              SCREEN_W + 4,          SCREEN_H + 4);
    set_dialog_size(&main_dlg[1],          0,                 0,               SCREEN_W,              15);

    // Status bars
    set_dialog_size(&main_dlg[6],          0,                 SCREEN_H - 17,   SCREEN_W - 256,        17);
    set_dialog_size(&main_dlg[7],          SCREEN_W - 256,    SCREEN_H - 17,   256,                   17);
    set_dialog_size(&main_dlg[8],          3,                 SCREEN_H - 14,   SCREEN_W - 262,        11);
    set_dialog_size(&main_dlg[9],          SCREEN_W - 253,    SCREEN_H - 14,   250,                   11);

    // Edit tile area
    w = zoom_w + 4;
    h = zoom_h + 4;
    x = margin;
    y = main_dlg[6].y - margin - h;
    set_dialog_size(&edit_tile_layer[0],   x,                 y,               w,                     h);
    set_dialog_size(&edit_tile_layer[1],   x + 2,             y + 2,           w - 4,                 h - 4);
    set_dialog_size(&edit_tile_layer[2],   x + margin + w,    y + h - 14,      50,                    14);

    // Color sliders
    x += w + margin;
    w = 128;
    set_dialog_size(&edit_tile_layer[8],   x,                 y,               16,                    8);
    set_dialog_size(&edit_tile_layer[9],   x,                 y + 16,          16,                    8);
    set_dialog_size(&edit_tile_layer[10],  x,                 y + 32,          16,                    8);
    set_dialog_size(&edit_tile_layer[11],  x,                 y + 48 + 8,      16,                    8);
    set_dialog_size(&edit_tile_layer[12],  x,                 y + 64 + 8,      16,                    8);
    set_dialog_size(&edit_tile_layer[3],   x + 16,            y,               w,                     8);
    set_dialog_size(&edit_tile_layer[4],   x + 16,            y + 16,          w,                     8);
    set_dialog_size(&edit_tile_layer[5],   x + 16,            y + 32,          w,                     8);
    set_dialog_size(&edit_tile_layer[6],   x + 16,            y + 48 + 8,      w,                     8);
    set_dialog_size(&edit_tile_layer[7],   x + 16,            y + 64 + 8,      w,                     8);
    set_dialog_size(&edit_tile_layer[13],  x + 16 + w + 4,    y - 1,           11,                    10);
    set_dialog_size(&edit_tile_layer[14],  x + 16 + w + 4,    y + 16 - 1,      11,                    10);
    set_dialog_size(&edit_tile_layer[15],  x + 16 + w + 4,    y + 32 - 1,      11,                    10);
    set_dialog_size(&edit_tile_layer[20],  x + 16 + w + 18,   y + 4,           18,                    32);

    // Select tile area
    x = edit_tile_layer[20].x + edit_tile_layer[20].w + margin;
    w = SCREEN_W - x - margin;
    set_dialog_size(&edit_tile_layer[16],  x,                 y,               104,                   h);
    set_dialog_size(&edit_tile_layer[17],  x + 104,           y,               w - 104,               h);
    set_dialog_size(&edit_tile_layer[18],  x + 104 + 2,       y + 2,           w - 104 - 4 - 11,      h - 4);
    set_dialog_size(&edit_tile_layer[19],  x + w - 14,        y,               14,                    h);

    // Obstacle edit stuff
    w = 24;
    h = 24;
    x = margin;
    y = main_dlg[6].y - margin - h;
    for (i = 0; i < 5; i++) {
        set_dialog_size(&edit_obstacle_layer[i],   x + i*(w+margin),     y,     w,     h);
        set_dialog_size(&edit_obstacle_layer[i+5], x + i*(w+margin) + 2, y + 2, w - 4, h - 4);
    }

    // Edit map area
    x = margin;
    y = 16 + margin;
    w = SCREEN_W - 2 * margin;
    h = edit_obstacle_layer[0].y - margin - y;
    set_dialog_size(&main_dlg[2],          x,                 y,               w,                     h);
    set_dialog_size(&main_dlg[3],          x + 2,             y + 2,           w - 15,                h - 15);
    set_dialog_size(&main_dlg[4],          x + w - 14,        y,               14,                    h - 11);
    set_dialog_size(&main_dlg[5],          x,                 y + h - 14,      w - 11,                14);
    set_dialog_size(&main_dlg[10],         x + w - 12,        y + h - 12,      10,                    10);

    // Edit objects area
    w = 160;
    h = 120;
    x = margin;
    y = main_dlg[6].y - margin - h;
    set_dialog_size(&edit_objects_layer[0], x,                y,               w,                     h);
    set_dialog_size(&edit_objects_layer[1], w + margin * 2, main_dlg[6].y - margin - 14,  97,                    14);


    // Initialize map and tile stuff
    tileRepository = new TileRepository();

    // Import tilesets specified in rpgedit.cfg
    i = 1;
    while (i > 0) 
    {
        uszprintf(buf, sizeof buf, "tileset%d", i);

        const char* filename = get_config_string(buf, "filename", NULL);
        int tile_w = get_config_int(buf, "tile_w", 16);
        int tile_h = get_config_int(buf, "tile_h", 16);
        int tile_spacing = get_config_int(buf, "tile_spacing", 0);

        if (filename) {
            if (tile_w > 0 && tile_h > 0 && tile_spacing >= 0) {
                import_tile_bitmap(filename, tile_w, tile_h, tile_spacing);
            } else {
                allegro_message("Error, incorrect parameters for automatic tile import (%s)!", filename);
                // Print warning in log file
            }
            i++;
        } else  {
            i = -1;
        }
    }

    currentMap = new SquareMap(TILES_W, TILES_H);
    ustrcpy(map_filename, "untitled.tmx");

    // Load map specified in rpgedit.cfg
    const char* filename = get_config_string("startup", "load_map", NULL);
    if (filename) {
        if (!currentMap->loadMap(filename)) {
            ustrcpy(map_filename, filename);
            object_message(&D_MAP, MSG_NEW_MAP, 0);
            set_map_changed(false);
        } else {
            console.log(CON_LOG, CON_ALWAYS,
                    "Error while loading default map (%s)!\n", filename);
        }
    }

    update_window_title();

    map_edit_mode = EM_TILE;
    menu_item_edit_objects();
    //activate_mode(edit_objects_layer);
}
Пример #26
0
void Display::init(Game* iGame)
{
  mGame = iGame;

  // Text colors
  // Black
  mColorText = makecol(0,0,0);
  mStatusText = G_TEXT_STATUS_START;

  // Set color depth
  int tmpCd = desktop_color_depth();
  if (tmpCd < 15) tmpCd = 32;
  set_color_depth(tmpCd);

  // Display
  set_window_title(G_TITLE);
  set_gfx_mode(GFX_AUTODETECT_WINDOWED, G_SCREEN_WIDTH, G_SCREEN_HEIGHT,0,0);
  // De-activate normal mouse, it will be displayed manually
  show_mouse(NULL);

  // Create buffer for double buffering display update
  mBuffer = create_bitmap(G_SCREEN_WIDTH, G_SCREEN_HEIGHT);  

  // Load bitmaps
  BITMAP* tmpBmp = NULL;
  Sprite* tmpSprite = NULL;
  // Background
  tmpBmp = load_bitmap(G_IMG_BACKGROUND, NULL);
  tmpSprite = new Sprite();
  tmpSprite->setBitmap(tmpBmp, 0, 0, tmpBmp->w, tmpBmp->h);
  mSprites.push_back(tmpSprite);

  // -------------------------------------------------
  // BUTTONS
  // -------------------------------------------------
	BITMAP* tmpOnBmp = NULL;
  BITMAP* tmpOffBmp = NULL;
  ls_button* tmpButton = NULL;
  ls_square* tmpButtonSquare = NULL;
  ls_wall* tmpButtonWall = NULL;

  // SQUARE BUTTONS
	tmpOnBmp = load_bitmap(G_IMG_SQ_ON, NULL);
  tmpOffBmp = load_bitmap(G_IMG_SQ_OFF, NULL);
  int tmpBorderAdjustX = (G_SCREEN_WIDTH - (G_SQUARE_SIZE * G_SQUARE_COUNT_COLUMNS) - (G_WALL_SIZE * (G_SQUARE_COUNT_COLUMNS - 1)))/2;
  int tmpBorderAdjustY = G_BASE_Y_ADJUST + (G_SCREEN_HEIGHT - (G_SQUARE_SIZE * G_SQUARE_COUNT_ROWS) - (G_WALL_SIZE * (G_SQUARE_COUNT_ROWS - 1)))/2;
  for (int i = 0; i < G_SQUARE_COUNT_ROWS; i++) {
    for (int j = 0; j < G_SQUARE_COUNT_COLUMNS; j++) {
      tmpButtonSquare = new ls_square();
      createButton(tmpButtonSquare, tmpOnBmp, tmpOffBmp, tmpBorderAdjustX + j*(G_SQUARE_SIZE+G_WALL_SIZE), tmpBorderAdjustY + i*(G_SQUARE_SIZE+G_WALL_SIZE));
      mSquareButtons.push_back(tmpButtonSquare);
    }
  }
  destroy_bitmap(tmpOnBmp);
  destroy_bitmap(tmpOffBmp);

  // WALL BUTTONS
  // Vertical (Walls separating an UP and DOWN square)
  tmpOnBmp = load_bitmap(G_IMG_WALL_V_ON, NULL);
  tmpOffBmp = load_bitmap(G_IMG_WALL_V_OFF, NULL);  
  for (int i = 0; i < G_SQUARE_COUNT_ROWS; i++) {
    for (int j = 0; j < G_SQUARE_COUNT_COLUMNS-1; j++) {
      tmpButtonWall = new ls_wall();
      createButton(tmpButtonWall, tmpOnBmp, tmpOffBmp, tmpBorderAdjustX + j*(G_SQUARE_SIZE+G_WALL_SIZE) + G_SQUARE_SIZE, tmpBorderAdjustY + i*(G_SQUARE_SIZE+G_WALL_SIZE));
      mWallHoriButtons.push_back(tmpButtonWall);
      
    }
  }
  destroy_bitmap(tmpOnBmp);
  destroy_bitmap(tmpOffBmp);
  // Horizontal (Walls separating a LEFT and RIGHT square)
  tmpOnBmp = load_bitmap(G_IMG_WALL_H_ON, NULL);
  tmpOffBmp = load_bitmap(G_IMG_WALL_H_OFF, NULL);  
  for (int i = 0; i < G_SQUARE_COUNT_ROWS-1; i++) {
    for (int j = 0; j < G_SQUARE_COUNT_COLUMNS; j++) {
      tmpButtonWall = new ls_wall();
      createButton(tmpButtonWall, tmpOnBmp, tmpOffBmp, tmpBorderAdjustX + j*(G_SQUARE_SIZE+G_WALL_SIZE), tmpBorderAdjustY + i*(G_SQUARE_SIZE+G_WALL_SIZE) + G_SQUARE_SIZE);
      mWallVertButtons.push_back(tmpButtonWall);
    }
  }
  destroy_bitmap(tmpOnBmp);
  destroy_bitmap(tmpOffBmp);

  // NORMAL BUTTONS
  // Solve
	tmpOnBmp = load_bitmap(G_IMG_SOLVE_ON, NULL);
  tmpOffBmp = load_bitmap(G_IMG_SOLVE_OFF, NULL);
  tmpButton = new ls_button();
  createButton(tmpButton, tmpOnBmp, tmpOffBmp, G_SOLVE_BTN_X, G_SOLVE_BTN_Y);
  tmpButton->set_tag(eSOLVE_BTN);
  mButtons.push_back(tmpButton);
  destroy_bitmap(tmpOnBmp);
  destroy_bitmap(tmpOffBmp);
  // Solve Complete
	tmpOnBmp = load_bitmap(G_IMG_SOLVE_C_ON, NULL);
  tmpOffBmp = load_bitmap(G_IMG_SOLVE_C_OFF, NULL);
  tmpButton = new ls_button();
  createButton(tmpButton, tmpOnBmp, tmpOffBmp, G_SOLVE_C_BTN_X, G_SOLVE_C_BTN_Y);
  tmpButton->set_tag(eSOLVE_C_BTN);
  mButtons.push_back(tmpButton);
  destroy_bitmap(tmpOnBmp);
  destroy_bitmap(tmpOffBmp);
  // Clear
	tmpOnBmp = load_bitmap(G_IMG_CLEAR_ON, NULL);
  tmpOffBmp = load_bitmap(G_IMG_CLEAR_OFF, NULL);
  tmpButton = new ls_button();
  createButton(tmpButton, tmpOnBmp, tmpOffBmp, G_CLEAR_BTN_X, G_CLEAR_BTN_Y);
  tmpButton->set_tag(eCLEAR_BTN);
  mButtons.push_back(tmpButton);
  destroy_bitmap(tmpOnBmp);
  destroy_bitmap(tmpOffBmp);

}