Esempio n. 1
0
    bool loadFonts() {
        buttonFontSize = 8;
        buttonFont = al_load_ttf_font("pirulen.ttf",buttonFontSize,0 );
        if (!buttonFont){
            playerLog("Could not load 'pirulen.ttf'.\n");
            return false;
        }

        // Load font also at the same time..
        libraryFont = al_load_ttf_font("pirulen.ttf",12,0 ); //UnionBold
        if (!libraryFont){
            playerLog("Could not load 'pirulen.ttf '.\n");
            return false;
        }

        return true;
    }
Esempio n. 2
0
int fb_init(){
    BACKGROUND_COLOR=al_map_rgb(0,127,255);
    al_show_mouse_cursor(Engine_Display);
    start_button = new button();
    start_button->set_values("../res/start_button.png",DISPLAY_WIDTH/2,DISPLAY_HEIGHT/2+50,0,0);
    start_button->on_click=&start_cb;
    quit_button = new button();
    quit_button->set_values("../res/quit_button.png",DISPLAY_WIDTH/2,DISPLAY_HEIGHT/2+200,0,0);
    quit_button->on_click=&quit_cb;
    bird_frames[0]=al_load_bitmap("../res/fb_wu.png");
    bird_frames[1]=al_load_bitmap("../res/fb_wd.png");
    my_pipe::pipe_image=al_load_bitmap("../res/pipe.png");
    background = new image("../res/background.png",DISPLAY_WIDTH,DISPLAY_HEIGHT/2,-3,0);
    bird = new collision_object<image>;
    menu = new image("../res/menu.png",DISPLAY_WIDTH/2,DISPLAY_HEIGHT/2,0,0);
    bird->set_values(bird_frames[0],bird_x,DISPLAY_HEIGHT+50,0,0);
    fb_timer = al_create_timer(TIME_BETWEEN_PIPES);
    al_register_event_source(engine_event_queue, al_get_timer_event_source(fb_timer));
    if(!fb_timer){
        std::cerr << "Couldn't create fb_timer!" << std::endl;
        return -1;
    }
#ifdef NDEBUG
    hscore_font=al_load_ttf_font("../res/xkcd-Regular.otf",24,0);
#else
    hscore_font=al_load_ttf_font("../res/xkcd-Regular.otf",36,0);
#endif
    if(!hscore_font){
        std::cerr << "Couldn't load font xkcd-Regular.otf!" << std::endl;
        return -1;
    }
    score_string = new string(5,0,0,0,new char[256], hscore_font,ALLEGRO_ALIGN_LEFT,0,0);
    score_string->auto_render=1;
    score_string->color=al_map_rgb(255,255,0);
#ifdef NDEBUG
    tick_string = new string(5,30,0,0,new char[256], hscore_font,ALLEGRO_ALIGN_LEFT,0,0);
    tick_string->auto_render=1;
    tick_string->color=al_map_rgb(255,255,0);
    vel_string = new string(5,60,0,0,new char[256], hscore_font,ALLEGRO_ALIGN_LEFT,0,0);
    vel_string->auto_render=1;
    vel_string->color=al_map_rgb(255,255,0);
#endif
    create_pipe();
    al_start_timer(fb_timer);
    return 0;
}
Esempio n. 3
0
grafika::grafika()
{
	al_init();
    al_install_keyboard();
	al_init_image_addon();
	al_init_font_addon();
	al_init_ttf_addon();

	font=al_load_ttf_font("C:\\WINDOWS\\Fonts\\times.ttf",15,0);

	okno = al_create_display( 800, 600);
    al_set_window_title(okno,"Samoloty");
	al_set_target_bitmap(al_get_backbuffer(okno));
	menu=al_load_bitmap("menu.png");
	strzalka=al_load_bitmap("strzalka.bmp");
	al_convert_mask_to_alpha( strzalka, al_map_rgb( 255, 255, 255 ) ); 
	font_menu_glowne=al_load_ttf_font("C:\\WINDOWS\\Fonts\\times.ttf",35,0);
}
void allegro_font_init(Jogo* jogo){
	al_init_font_addon();
	al_init_ttf_addon();
	jogo->fonte = al_load_ttf_font("imagens/space_invaders.ttf", 25, 0);
	if(!jogo->fonte){
		al_show_native_message_box(jogo->display, "Erro", "Erro", "Falha ao iniciar a fonte.", "OK", ALLEGRO_MESSAGEBOX_ERROR);
		exit(1);
	}
}
Esempio n. 5
0
StartMenu::StartMenu(){
	mouseX = 0;
	mouseY = 0;
	fontHeight = 36;
	gotClicked = false;
	selected = -1;;	//controls when to start the game and go into the game
	font36 = al_load_ttf_font("Fonts/A_Sensible_Armadillo.ttf", 36, 0);
	background = al_load_bitmap("Bitmaps/grass1.png");
	sendbuf = "";
}
Esempio n. 6
0
GridVisualizer::GridVisualizer( Grid* pGrid )
:mpGrid(pGrid)
,mDirty(true)
{
	mpFont = al_load_ttf_font("cour.ttf", 12, 0);
	if (mpFont == NULL)
	{
		printf("ttf font file not loaded properly!\n");
		assert(0);
	}
}
void SplashScreen::Render()
{
	ALLEGRO_FONT *font = al_load_ttf_font("arial.ttf", 72, 0);
	if (!font)
	{
		out->printerr("Could not load 'arial.ttf'.\n");
		return;
	}

	al_draw_text(font, al_map_rgb(255, 255, 255), 50, 50, ALLEGRO_ALIGN_CENTER, "Im Alive!");
}
Esempio n. 8
0
CPauseScreen::CPauseScreen( CMainWindow* mainWindow, CScreen* parent ) 
    : CScreen( mainWindow, parent ) {
    m_options = new std::string[3];
    m_options[0] = "Resume game";
    m_options[1] = "About";
    m_options[2] = "Quit game";

    m_selectedOption = 0;

    m_font = al_load_ttf_font( "8bitlim.ttf", 36, 0 );
}
Esempio n. 9
0
	Font::Font(const string& filename, int size, bool antialiasing, bool hinting, bool kerning)
	: implementation(new Implementation)
	{
		checkInit();

		//I know, pretty odd...
		int flags = (antialiasing? 0 : ALLEGRO_TTF_MONOCHROME)	| (hinting? 0 : ALLEGRO_TTF_NO_AUTOHINT) | (kerning? 0 : ALLEGRO_TTF_NO_KERNING);
		this->implementation->allegroFont = al_load_ttf_font(filename.c_str(), size, flags);

		if(this->implementation->allegroFont == null)
			throw AdapterException("Font %s could not be loaded: Error %d", filename.c_str(), al_get_errno());
	}
Esempio n. 10
0
File: font.c Progetto: trezker/allua
static int allua_Font_load_ttf(lua_State * L)
{
   const char *filename = luaL_checkstring(L, 1);
   int size = luaL_checkint(L, 2);
   int options = luaL_checkint(L, 3);
   ALLUA_font font = al_load_ttf_font(filename, size, options);
   if (font)
      allua_pushFont(L, font);
   else
      lua_pushnil(L);
   return 1;
}
Esempio n. 11
0
HUD::HUD()
{
	mpFont = al_load_ttf_font("cour.ttf", 12, 0);
	if (mpFont == NULL)
	{
		printf("ttf font file not loaded properly!\n");
		assert(0);
	}
	mToggleHelp = false;
	
	initHelpText();
}
Esempio n. 12
0
void Level1_PreloadBitmaps(struct Game *game, void (*progress)(struct Game*, float)) {
	PROGRESS_INIT(Level1_PreloadSteps());
	game->level.level1.owl = LoadScaledBitmap("levels/1/owl.png", game->viewportWidth*0.08, game->viewportWidth*0.08);
	PROGRESS;
	game->level.letter_font = al_load_ttf_font(GetDataFilePath("fonts/DejaVuSans.ttf"),game->viewportHeight*0.0225,0 );
	PROGRESS;
	game->level.letter = LoadScaledBitmap("levels/1/letter.png", game->viewportHeight*1.3, game->viewportHeight*1.2);
	al_set_target_bitmap(game->level.letter);
	float y = 0.20;
	float x = 0.19;
	void draw_text(char* text) {
		al_draw_text(game->level.letter_font, al_map_rgb(0,0,0), al_get_bitmap_width(game->level.letter)*x, game->viewportHeight*y, ALLEGRO_ALIGN_LEFT, text);
		y+=0.028;
	}
Esempio n. 13
0
int main()
{
    ALLEGRO_DISPLAY *display = NULL;
    ALLEGRO_FONT* century_gothic24;

    if(!al_init())
    {
        printf("al_init Failed!\n");
        return -1;
    }
    if(!al_init_primitives_addon())
    {
        printf("al_init_primitives_addon Failed!\n");
        return -1;
    }
    display = al_create_display(640, 480);
    if(!display)
    {
        printf("al_create_display Failed!\n");
        return -1;
    }
    al_init_font_addon();
    al_init_ttf_addon();
    century_gothic24  = al_load_ttf_font("C:\\Windows\\Fonts\\GOTHIC.TTF" , 24, ALLEGRO_ALIGN_CENTRE);
    // Paint a hidden screen (a buffer), that we'll apply later.
    al_clear_to_color(al_map_rgb(0,0,0));
    // Draw an ugly red triangle to the buffer.
    al_draw_filled_triangle(10, 10, 200, 200, 350, 230, al_map_rgb(255,0,0));
    // Draw text to the buffer
    al_draw_text(century_gothic24, al_map_rgb(255,255,255), 550, 440, ALLEGRO_ALIGN_CENTRE, "Hello World!");
    // Draw a line to the buffer
    al_draw_line(400,400,500,34,al_map_rgb(255,255,255), 5);
    // Draw a circle
    al_draw_circle(300,300, 50, al_map_rgb(255,255,0), 5);
    // Draw Eclipse
    al_draw_filled_ellipse(500, 300, 40, 56, al_map_rgb(255,0,255));
    // Draw a rectangle
    al_draw_rectangle(100,200,200,300,al_map_rgb(0,255,0), 6);s
    // Draw a polygon
    al_draw_filled_rectangle(0,480,50,400,al_map_rgb(25,185,35));
    al_draw_filled_rectangle(0,480,200,450,al_map_rgb(25,185,35));
    // Apply the buffer to the front.
    al_flip_display();
    // Wait for 3 secs.
    al_rest(10.0);
    // Destroying the display we created, to avoid memory leaking.
    al_destroy_display(display);

    return 0;
}
Esempio n. 14
0
ALLEGRO_FONT* crearFuente (int tamano){
    ALLEGRO_FONT* fuente=NULL;
    
    fuente=al_load_ttf_font("PTS55F.ttf",tamano,0);      //cargo la fuente predeterminada con el tamano pedido
    
    
    if (fuente==NULL){
        fprintf(stderr,"No se pudo cargar la imagen, el programa finalizara.\n");
        al_destroy_font(fuente);
        exit -1;
    }
    
    return fuente;
    
}
Esempio n. 15
0
void RoundOver::Begin()
{
#ifdef WRITE_LOG
	fprintf( FRAMEWORK->LogFile, "Stage: RoundOver::Begin()\n" );
#endif
	currentArena = (Arena*)FRAMEWORK->ProgramStages->Previous();

	fntTitle = al_load_ttf_font( "resources/titlefont.ttf", 48, 0 );
	fntTitleHeight = al_get_font_line_height( fntTitle );

	leaving = false;
	overbanner[0] = -50.0f;
	overbanner[1] = (DISPLAY->GetHeight() / 2) - 50.0f;
	overbanner[2] = -100.0f;
	overbanner[3] = overbanner[1] + 100.0f;
	overbanner[4] = -50.0f;
	overbanner[5] = overbanner[3];
	overbanner[6] = 0.0f;
	overbanner[7] = overbanner[1];

	switch( winner )
	{
		case 0:
			// Draw
			textDisplay = "Draw!";
			break;
		case 1:
			// Player 1
			textDisplay = "Player 1 Wins";
			break;
		case 2:
			// Player 2
			textDisplay = "Player 2 Wins";
			break;
	}

	textWidth = al_get_text_width( fntTitle, textDisplay.c_str() );
	textXposition = DISPLAY->GetWidth();


	overbannerXv = (DISPLAY->GetWidth() + 100) / ROUNDOVER_STEPSINOUT;
	textXv = ( textXposition - ((DISPLAY->GetWidth() - textWidth) / 2) ) / ROUNDOVER_STEPSINOUT;

	textXposition -= textXv;
	stagetime = 0;

}
Esempio n. 16
0
File: info.c Progetto: dos1/mediator
void* Gamestate_Load(struct Game *game, void (*progress)(struct Game*)) {
    struct dosowiskoResources *data = malloc(sizeof(struct dosowiskoResources));
    data->bitmap = al_load_bitmap( GetDataFilePath(game, "bg.png"));
    data->icon = al_load_bitmap( GetDataFilePath(game, "mouse.png"));

    data->font = al_load_ttf_font(GetDataFilePath(game, "fonts/MonkeyIsland.ttf"),100,0 );
    (*progress)(game);

    data->sample = al_load_sample( GetDataFilePath(game, "warning.flac") );

    data->sound = al_create_sample_instance(data->sample);
    al_attach_sample_instance_to_mixer(data->sound, game->audio.fx);
    al_set_sample_instance_playmode(data->sound, ALLEGRO_PLAYMODE_ONCE);
    al_set_sample_instance_gain(data->sound, 1.25);

    return data;
}
Esempio n. 17
0
void drawMenu()
{
    ALLEGRO_FONT *openSans62;
    openSans62 = al_load_ttf_font("../fonts/OpenSans-Light.ttf", 62, 0);
    if(!openSans62)
        error("al_load_font()");

    al_draw_text(openSans62, WHITE, SCREEN_WIDTH*0.1, SCREEN_HEIGHT*0.1, 0, "Pong");

    al_draw_text(openSans12, WHITE, SCREEN_WIDTH*0.1, SCREEN_HEIGHT*0.5, 0, "1)    Solo");

    al_draw_text(openSans12, WHITE, SCREEN_WIDTH*0.1, SCREEN_HEIGHT*0.6, 0, "2)    Multiplayer");

    al_flip_display();

    loopMenu();
};
Esempio n. 18
0
void* Gamestate_Load(struct Game *game, void (*progress)(struct Game*)) {
	struct GamestateResources *data = malloc(sizeof(struct GamestateResources));
	data->timeline = TM_Init(game, "main");
	data->bitmap = al_create_bitmap(game->viewport.width, game->viewport.height);
	data->checkerboard = al_create_bitmap(game->viewport.width, game->viewport.height);
	data->pixelator = al_create_bitmap(game->viewport.width, game->viewport.height);

	al_set_target_bitmap(data->checkerboard);
	al_lock_bitmap(data->checkerboard, ALLEGRO_PIXEL_FORMAT_ANY, ALLEGRO_LOCK_WRITEONLY);
	int x, y;
	for (x = 0; x < al_get_bitmap_width(data->checkerboard); x=x+2) {
		for (y = 0; y < al_get_bitmap_height(data->checkerboard); y=y+2) {
			al_put_pixel(x, y, al_map_rgba(0,0,0,64));
			al_put_pixel(x+1, y, al_map_rgba(0,0,0,0));
			al_put_pixel(x, y+1, al_map_rgba(0,0,0,0));
			al_put_pixel(x+1, y+1, al_map_rgba(0,0,0,0));
		}
	}
	al_unlock_bitmap(data->checkerboard);
	al_set_target_backbuffer(game->display);
	(*progress)(game);

	data->font = al_load_ttf_font(GetDataFilePath(game, "fonts/DejaVuSansMono.ttf"),
	                              (int)(game->viewport.height*0.1666 / 8) * 8 ,0 );
	(*progress)(game);
	data->sample = al_load_sample( GetDataFilePath(game, "dosowisko.flac") );
	data->sound = al_create_sample_instance(data->sample);
	al_attach_sample_instance_to_mixer(data->sound, game->audio.music);
	al_set_sample_instance_playmode(data->sound, ALLEGRO_PLAYMODE_ONCE);
	(*progress)(game);

	data->kbd_sample = al_load_sample( GetDataFilePath(game, "kbd.flac") );
	data->kbd = al_create_sample_instance(data->kbd_sample);
	al_attach_sample_instance_to_mixer(data->kbd, game->audio.fx);
	al_set_sample_instance_playmode(data->kbd, ALLEGRO_PLAYMODE_ONCE);
	(*progress)(game);

	data->key_sample = al_load_sample( GetDataFilePath(game, "key.flac") );
	data->key = al_create_sample_instance(data->key_sample);
	al_attach_sample_instance_to_mixer(data->key, game->audio.fx);
	al_set_sample_instance_playmode(data->key, ALLEGRO_PLAYMODE_ONCE);
	(*progress)(game);

	return data;
}
Esempio n. 19
0
HUD::HUD(PortalInfo* pPortals)
{
	mpFont = al_load_ttf_font("cour.ttf", 12, 0);
	if (mpFont == NULL)
	{
		printf("ttf font file not loaded properly!\n");
		assert(0);
	}
	mToggleHelp = false;
	
	mCurrentMapName = "INVALID";
	mCurrentMapID = -1;
	mTotalMaps = -1;
	mCurrentMap = -1;
	mSelectedBlockType = "INVALID";
	mpPortals = pPortals;
	initHelpText();
}
Esempio n. 20
0
/** A Menu inicializalasas
* @param Nincs
* @return a Menu-re mutato pointer
* @author Pjatacsuk Bence
* @date 2011.10.29
*/
Menu* InitMenu()
{
	Menu* MyMenu = MallocMenu();
	
	
	MyMenu->timer= al_create_timer(1.0 / FPS);

	   if(!MyMenu->timer) 
	   {
		 printf("failed to create timer!\n");
		  return 0;
	   }

	   //display kreálása
   
	   MyMenu->display = al_create_display(SCREEN_W,SCREEN_H);
	   if(!MyMenu->display) 
	   {
		  fprintf(stderr, "failed to create display!\n");
		  al_destroy_timer(MyMenu->timer);
		  return 0;
	   } 

	   //event queue kreálása

	  MyMenu->event_queue = al_create_event_queue();
   if(!MyMenu->event_queue) {
      fprintf(stderr, "failed to create event_queue!\n");
     
      al_destroy_display(MyMenu->display);
      al_destroy_timer(MyMenu->timer);
      return 0;
   }
   
   al_init_font_addon();
   al_init_ttf_addon();

   MyMenu->bg = al_load_bitmap("data\\images\\menubg.png");
   CheckBitmap(MyMenu->bg,"data\\images\\menubg.png");
   MyMenu->font = al_load_ttf_font("TELE2.ttf",40,0);

   return MyMenu;

}
Esempio n. 21
0
File: font.c Progetto: yav/allegro
int main(int argc, char *argv[]) {
  int res = 0;

  if (!al_init()) {
    fprintf(stderr, "Failed to initialize Allegro\n");
    res = 1;
    goto X0;
  }

  al_init_font_addon();

  if (!al_init_ttf_addon()) {
    fprintf(stderr, "Failed to initialize the TTF addong\n");
    res = 3;
    goto X1;
  }

  const char *font_name = "../resources/font.ttf";
  ALLEGRO_FONT *font = al_load_ttf_font(font_name, 12, 0);
  if (font == NULL) {
    fprintf(stderr, "Failed to load font %s\n", font_name);
    res = 4;
    goto X2;
  }

  ALLEGRO_DISPLAY *display = al_create_display(640,480);
  if (display == NULL) {
    fprintf(stderr, "Failed to creat display\n");
    res = 5;
    goto X3;
  }

  al_draw_text(font, al_map_rgb(255,255,255), 0, 0, 0, "Hello Явор");
  al_flip_display();
  al_rest(3);

    al_destroy_display(display);
X3: al_destroy_font(font);
X2: al_shutdown_ttf_addon();
X1: al_shutdown_font_addon();
X0: return res;
}
Esempio n. 22
0
int main(int argc, char **argv) {
    al_init();
    al_init_font_addon();
    al_init_ttf_addon();
//    al_init_primitives_addon();
    const ALLEGRO_FONT *arial = al_load_ttf_font("arial.ttf", 12, 0);
    al_create_display(dlugosc, szerokosc);
    al_clear_to_color(czarny);
//    for (int i = 50; i < 400; i+=3) {
//        al_draw_pixel(i, 200+i, al_map_rgb_f(255, 255, 255) );
//    }
//     al_draw_text(arial, bialy, 10, 10, 0, "asda"); // X
    int min, max;
    szukaj_min_max(min, max);
    rysuj_uklad_wspolrzednych();
    rysuj_funkcje(min,max);
    al_flip_display();
    al_rest(10.0);
    return 0;
}
Esempio n. 23
0
void Text::init()
{
	font = al_load_ttf_font("Fonts/arial.ttf", 15, 0);

	image = al_load_bitmap("Sprites/timer.png");
	
	al_convert_mask_to_alpha(image, al_map_rgb(0, 0, 0));

	counter = settings.getIntOption("time");	// time
	counterTemp = 0;
	startFrame = 0;
	maxFrame = 2;
	curFrame = 0;
	frameCount = 0;
	frameDelay = 30;
	frameWidth = 16;
	frameHeight = 16;
	reset = false;	// when mario is clear the stage
	name = "Player";
}
Esempio n. 24
0
void GameScreen::loadContent()
{
	// Load in font
	font = al_load_ttf_font("./assets/fonts/font.ttf",62,0 );
	
	// Randomly decide whether to do a night or day bitmap
	if((rand() % 2) > 0)
	{
		bitmap = al_load_bitmap("./assets/imgFiles/backdropB.bmp");
	}
	else
	{
		bitmap = al_load_bitmap("./assets/imgFiles/backdropBa.bmp");
		isNight = true;
	}
	
	// Load player and obstacles
	userPlayer->loadPlayer();
	obstacles.loadObstacles();
}
Esempio n. 25
0
ScoreBoard::ScoreBoard(Player& aPlayer):player(aPlayer), buttonSize_(32), towerButtonActive_(false), scoreBoardWidth_(1280), scoreBoardHeight_(80), topLinePosition_(640)
{
  al_init();
  al_init_primitives_addon();
  al_init_font_addon();
  al_init_ttf_addon();
  al_init_image_addon();

  colorWhite_ = al_map_rgb (255, 255, 255);
  colorRed_ = al_map_rgb (255, 0, 0);

  towerButton_ = al_load_bitmap ("gfx/towerbutton.bmp");

  infoFont_ =  al_load_ttf_font ("gfx/pirulen.ttf", 18, 0);
  infoText_ = new char [128];

  Money_ = player.getMoney();
  healthPoints_ = player.getHealthPoints();
  Score_ = player.getScore();
}
Esempio n. 26
0
InputField::InputField(std::string font_path, std::string init_string, int x, int y, int width, int height,
                       ALLEGRO_COLOR outline, ALLEGRO_COLOR textcolor, ALLEGRO_COLOR backgroundcolor)
                      : x1(x), y1(y), width(width), height(height), outline_color(outline), text_color(textcolor), bckground_color(backgroundcolor)
{
    x2 = x1 + width;
    y2 = y1 + height;

    int font_size = ((float)height / 5.0) * 4.0;

    font = al_load_ttf_font(font_path.c_str(), font_size, 0);


    if(font == nullptr)
    {
        al_show_native_message_box(NULL, "Error", "Failed to load font!", font_path.c_str(), NULL, ALLEGRO_MESSAGEBOX_ERROR);
    }

    text = init_string;
    text_width =  al_get_text_width(font, text.c_str());
    text_height = al_get_font_ascent(font);

    //al_set_new_bitmap_flags(ALLEGRO_MAG_LINEAR);  //alredy called in main
    bmp = al_create_bitmap(width, height);
    al_set_target_bitmap(bmp);
    al_clear_to_color(bckground_color);
    al_set_target_backbuffer(al_get_current_display());

    detectingbutton = new Button(x1, y1, x2, y2);

    al_text = al_ustr_new(text.c_str());

    as_bitmap = al_create_bitmap(width, height);

    x = x1;
    y = y1;

    origin_x1 = x1;
    origin_y1 = y1;
    origin_x2 = x2;
    origin_y2 = y2;
}
Esempio n. 27
0
bool Init()
{
    if (LoadConfigurationData(applicationConfig, styleConfig) == false)
        return false;

    al_init();

    if (applicationConfig.bfullscreen == true)
    {
        al_set_new_display_flags(ALLEGRO_FULLSCREEN);
    }
    al_set_app_name(applicationConfig.strAppName.c_str());
    al_set_new_display_option(ALLEGRO_VSYNC, 1, ALLEGRO_REQUIRE);
    display = al_create_display(applicationConfig.iDispW, applicationConfig.iDispH);

    al_install_keyboard();
    al_install_mouse();
    al_init_primitives_addon();
    al_init_image_addon();
    al_init_font_addon();
    al_init_ttf_addon();

    timer = al_create_timer(applicationConfig.dFps);
    queue = al_create_event_queue();
    textFont = al_load_ttf_font(styleConfig.strFontPath.c_str(), styleConfig.iFontSize, NULL);

    if ((display == nullptr) || (timer == nullptr) || (queue == nullptr) || (textFont == nullptr))
    {
        std::cout << "ERROR: Either the display, timer, queue or font failed to initialize!" << std::endl
            << "0x" << display << " 0x" << timer << " 0x" << queue << " 0x" << textFont << std::endl;
        return false;
    }

    al_register_event_source(queue, al_get_keyboard_event_source());
    al_register_event_source(queue, al_get_mouse_event_source());
    al_register_event_source(queue, al_get_display_event_source(display));
    al_register_event_source(queue, al_get_timer_event_source(timer));

    return true;
}
Esempio n. 28
0
void* Gamestate_Load(struct Game *game, void (*progress)(struct Game*)) {

	struct MenuResources *data = malloc(sizeof(struct MenuResources));

	data->options.fullscreen = game->config.fullscreen;
	data->options.fps = game->config.fps;
	data->options.width = game->config.width;
	data->options.height = game->config.height;
	data->options.resolution = game->config.width / 320;
	if (game->config.height / 180 < data->options.resolution) data->options.resolution = game->config.height / 180;
	(*progress)(game);

	data->bg = al_load_bitmap( GetDataFilePath(game, "bg.png") );
	data->monster = al_load_bitmap( GetDataFilePath(game, "monster.png") );
	data->title = al_load_bitmap( GetDataFilePath(game, "title.png") );
	(*progress)(game);

	data->sample = al_load_sample( GetDataFilePath(game, "monster.flac") );
	data->click_sample = al_load_sample( GetDataFilePath(game, "click.flac") );
	(*progress)(game);

	data->music = al_create_sample_instance(data->sample);
	al_attach_sample_instance_to_mixer(data->music, game->audio.music);
	al_set_sample_instance_playmode(data->music, ALLEGRO_PLAYMODE_LOOP);

	data->click = al_create_sample_instance(data->click_sample);
	al_attach_sample_instance_to_mixer(data->click, game->audio.fx);
	al_set_sample_instance_playmode(data->click, ALLEGRO_PLAYMODE_ONCE);

	if (!data->click_sample){
		fprintf(stderr, "Audio clip sample not loaded!\n" );
		exit(-1);
	}
	(*progress)(game);

	data->font = al_load_ttf_font(GetDataFilePath(game, "fonts/MonkeyIsland.ttf"),game->viewport.height*0.05,0 );

	al_set_target_backbuffer(game->display);
	return data;
}
Esempio n. 29
0
void init(void)
{
    if (!al_init())
        abort_game("Failed to initialize allegro");
 
    if (!al_install_keyboard())
        abort_game("Failed to install keyboard");
    if (!al_init_primitives_addon())
        abort_game("Failed to install primitives");
    al_init_font_addon(); // initialize the font addon
    al_init_ttf_addon();// initialize the ttf (True Type Font) addon 

    timer = al_create_timer(1.0 / 60);
    if (!timer)
        abort_game("Failed to create timer");
 
    ALLEGRO_DISPLAY_MODE disp_data;
    al_get_display_mode(0, &disp_data);
   
    al_set_new_display_flags(ALLEGRO_WINDOWED);
    //display = al_create_display(disp_data.width, disp_data.height);
    display = al_create_display(800, 480);
    if (!display)
        abort_game("Failed to create display");
 
    event_queue = al_create_event_queue();
    if (!event_queue)
        abort_game("Failed to create event queue");
    
    al_register_event_source(event_queue, al_get_keyboard_event_source());
    al_register_event_source(event_queue, al_get_timer_event_source(timer));
    al_register_event_source(event_queue, al_get_display_event_source(display));
    
    al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA);
    
    font = al_load_ttf_font("src/Atari_Full.ttf", 16,0 );

    done = false;
}
Esempio n. 30
0
RoomDesigner::RoomDesigner()
{
  textfont = al_load_ttf_font( "resources/silkscreen.ttf", 8, ALLEGRO_TTF_MONOCHROME );

  selection_rampdelay = 0;
  selection_rampindex = 0;

	designermodes[DesignerMode::BackgroundMode] = new RoomDesignerBackground();
	designermodes[DesignerMode::PanelMode] = new RoomDesignerPanel();
	designermodes[DesignerMode::ZoneMode] = new RoomDesignerZone();
	designermodes[DesignerMode::ObjectMode] = new RoomDesignerObject();
	designermodes[DesignerMode::EnemyMode] = new RoomDesignerEnemy();

  if( GameResources::GameWorld->Rooms.size() == 0 )
  {
    GameResources::GameWorld->Rooms.push_back( new Room() );
  }

  workingroomindex = 0;
  workingroom = GameResources::GameWorld->Rooms.front();
  for( int i = 0; i < FRAMEWORK->GetFramesPerSecond() * 2; i++ )
  {
    workingroom->Update();
  }

	for(int i = 0; i < DesignerMode::ModeCount; i++ )
	{
		designermodes[i]->Init( this, workingroom, workingroomindex, textfont );
	}
	designermode = DesignerMode::PanelMode;

	AddLogText("Welcome to the designer");

	showtools = false;
	AUDIO->PlayMusic( "resources/Paul Hannay (Feekzoid) - Last_Ninja_4_loader [3].ogg", true );
}