Re: Image Not Appearing
- Posted by Lone_EverGreen_Ranger Dec 21, 2011
- 2033 views
EDIT: I made it an object, now I get the error, sequence lengths are not the same (4 != 5). What does that mean?
Means you should use equal(). I argued for getting rid of that "error" years ago, and i was disregarded. I thought it had been obsoleted in v4, but apparently not.
useless
I'm still a bit confused. Anyone able to show me what exactly I'm doing wrong with my code?
The error reported is the lengths of the sequences you are comparing using "=" . Euphoria has never liked to do that, and i learned early on to never use "=" to compare sequences. Euphoria has functions to do comparisons: equal() and compare(). Look them up in your favorite version of the Eu help files.
Basically, change code like
if screen = Screens[1]
to
if equal(screen,Screens[1])
If you are needing < or > for stuff and getting errors, use compare(). Other that that, all i can do is copy/paste the manual to you here in the forum, which i don't want to do.
useless
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"} object 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 equal(screen,Screens[1]) then screen = Screens[2] end if if equal(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()
Alright, this is my modified code, still not showing the image.