Image Not Appearing

new topic     » topic index » view thread      » older message » newer message

Hello, I'm using Euphoria 4.0 and the most current version of the SDL wrapper. I am trying to blit an image to the screen, yet it is not showing on the screen. I have posted my code.

without warning 
without type_check 
 
include std/get.e 
include std/sort.e 
include std/rand.e 
include std/math.e 
include std/mathcons.e 
include std/eds.e 
include std/filesys.e 
include std/wildcard.e 
 
include Sdl_Wrap.ew 
include SDL_image.ew 
 
constant TRUE = 1 
constant FALSE = 0 
 
constant MAX_HEALTH = 100 
constant MAX_LIVES = 3 
constant ENEMY_LIVES = 1 
 
constant MAX_WIDTH = 800 
constant MAX_HEIGHT = 600 
constant MAX_DEPTH = 32 
 
atom dummy 
atom surface,buffer 
atom keyState,curKey,prevKey 
atom run 
atom title,logo --gfx 
atom ship,missle,enemy --gfx  
atom backdrop --gfx 
atom shiprect,misslerect,enemyrect --rects 
integer shipx,shipy,shipwidth,shipheight 
integer misslex,missley,misslewidth,missleheight 
integer enemyx,enemyy,enemywidth,enemyheight 
atom shipvelx,shipvely 
atom enemyvelx,enemyvely 
atom misslevelx,misslevely 
atom format 
 
integer Missle_Fired = FALSE 
 
atom health = MAX_HEALTH 
atom lives = MAX_LIVES 
 
atom score 
 
sequence sTitle = "4000 A.D. - Geek Punk Games" 
sequence sIcon = "" 
 
integer enemypoints 
integer ticks,last_tick 
atom deltatime 
 
sequence Screens = {"Logo","Title","Game"} 
atom screen 
 
procedure CalcRect(atom rect, integer sx, integer sy, integer tx, integer ty) 
 
	poke(rect,and_bits(sx,255)) 
	poke(rect+1,floor(sx/256)) 
	poke(rect+2,and_bits(sy,255)) 
	poke(rect+3,floor(sy/256)) 
	poke(rect+4,and_bits(tx,255)) 
	poke(rect+5,floor(tx/256)) 
	poke(rect+6,and_bits(ty,255)) 
	poke(rect+7,floor(ty/256)) 
	 
end procedure 
 
procedure Init() 
 
	dummy = SDL_Init(SDL_INIT_EVERYTHING) 
	 
	if dummy = -1 then 
		puts(1,"Could not init SDL") 
	end if 
	 
	surface = SDL_SetVideoMode(MAX_WIDTH,MAX_HEIGHT,MAX_DEPTH,SDL_HWSURFACE) 
	 
	SDL_WM_SetCaption(sTitle,sIcon) 
	 
	format = peek4u(surface+4) 
	 
	shiprect = allocate(16) 
	enemyrect = allocate(16) 
	misslerect = allocate(16) 
	 
	title = IMG_LoadJPG("Title.jpg") 
	logo = IMG_LoadJPG("Logo.jpg") 
	backdrop = IMG_LoadJPG("Backdrop.jpg") 
	ship = IMG_LoadJPG("Ship.jpg") 
	enemy = IMG_LoadJPG("Enemy.jpg") 
	missle = IMG_LoadJPG("Missle.jpg") 
	 
	--get rid of background color on image(the whitespace) 
	dummy = SDL_SetColorKey(ship,SDL_SRCCOLORKEY,SDL_MapRGB(format,255,255,255)) 
	if dummy = -1 then 
		puts(1,"Could not apply color key") 
	end if 
	 
	dummy = SDL_SetColorKey(enemy,SDL_SRCCOLORKEY,SDL_MapRGB(format,255,255,255)) 
	if dummy = -1 then 
		puts(1,"Could not apply color key") 
	end if 
	 
	dummy = SDL_SetColorKey(missle,SDL_SRCCOLORKEY,SDL_MapRGB(format,255,255,255)) 
	if dummy = -1 then 
		puts(1,"Could not apply color key") 
	end if 
	 
end procedure 
 
procedure Run() 
 
	run = 1 
	screen = Screens[1] 
	 
	while run = 1 do 
	 
		ticks = SDL_GetTicks() 
	 
		SDL_PumpEvents() 
		 
		keyState = SDL_GetKeyState(NULL) 
		if peek(keyState+SDLK_ESCAPE) > 0 then 
			run = 0 
		end if 
		 
		dummy = SDL_BlitSurface(logo,NULL,surface,NULL) 
		if dummy = -1 then 
			puts(1,"Could not blit surface") 
		end if 
		 
		if peek(keyState+SDLK_RETURN) > 0 and screen = Screens[1] then 
			screen = Screens[2] 
		end if 
		 
		if screen = Screens[2] then 
			dummy = SDL_BlitSurface(title,NULL,surface,NULL) 
			if dummy = -1 then 
				puts(1,"Could not blit surface") 
			end if 
		end if 
	 
	end while 
	 
end procedure 
 
procedure Quit() 
	 
	SDL_FreeSurface(ship) 
	SDL_FreeSurface(enemy) 
	SDL_FreeSurface(missle) 
	SDL_FreeSurface(title) 
	SDL_FreeSurface(logo) 
	SDL_FreeSurface(backdrop) 
	 
	free(shiprect) 
	free(enemyrect) 
	free(misslerect) 
 
	SDL_Quit() 
	 
end procedure 
 
Init() 
Run() 
Quit() 
new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu