www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/02/25/13:59:47

Message-Id: <199702251828.SAA09913@post.dialin.co.uk>
From: "Lee Simons" <lee AT dialin DOT co DOT uk>
To: <djgpp AT delorie DOT com>
Subject: Allegro: Pallete problems...
Date: Tue, 25 Feb 1997 18:46:05 -0000
MIME-Version: 1.0

Hello everyone...

I'm new to Allegro and I've been having problems with palletes.
I've got a small program which displays a graphic - waits for a key to be
entered, and then draws another two bitmaps to the screen, one smaller one
ontop of another.  But, the palletes are all messed up and I was wondering
how I can change palletes within a function of failing that in different
functions.  So that palletes will be loaded for each image.  I've included
my source, and any examples would really help me a lot.  Sorry if this
seems like a stupid question or if it's in the faq's but I'm lost.  =)

Lee

----

#include <stdlib.h>
#include <stdio.h>

#include "allegro.h"

void play(void);

main()
{
	BITMAP *titlescreen;
	PALLETE pallete;

	allegro_init();						/* Initialisation crap.*/
	install_keyboard(); 
	set_gfx_mode(GFX_ET4000, 800, 600, 0, 0);

	titlescreen = load_pcx("titlescr.pcx", pallete);
		
	blit(titlescreen, screen, 0, 0, (SCREEN_W-titlescreen->w)/2, 
		     (SCREEN_H-titlescreen->h)/2, titlescreen->w, titlescreen->h);

	destroy_bitmap(titlescreen);

	readkey();
	play();	

	exit(0);	
}

void play()
{
	int key;
	
	BITMAP *field;
	BITMAP *player;
	PALLETE pallete;

	field   = load_pcx("field.pcx", pallete);
	player  = load_pcx("player.pcx", pallete);
 
	blit(player, screen, 0, 0, (SCREEN_W-player->w)/2,
			(SCREEN_H-player->h)/2, player->w, player->h);	

	blit(field, screen, 0, 0, (SCREEN_W-field->w)/2,
			(SCREEN_H-field->h)/2, field->w, field->h);

	do 
	{
	key = readkey();
	} while ((key & 0xFF) != 27);

	destroy_bitmap(field);
	destroy_bitmap(player);
}

----

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019