275 if tmpsurf = nil then |
275 if tmpsurf = nil then |
276 tmpsurf:= LoadImage(Pathz[AltPath] + '/' + FileName, hasAlpha, true, true) |
276 tmpsurf:= LoadImage(Pathz[AltPath] + '/' + FileName, hasAlpha, true, true) |
277 end; |
277 end; |
278 if Width = 0 then Width:= tmpsurf^.w; |
278 if Width = 0 then Width:= tmpsurf^.w; |
279 if Height = 0 then Height:= tmpsurf^.h; |
279 if Height = 0 then Height:= tmpsurf^.h; |
280 Texture:= Surface2Tex(tmpsurf) |
280 Texture:= Surface2Tex(tmpsurf); |
|
281 SDL_FreeSurface(tmpsurf) |
281 end; |
282 end; |
282 |
283 |
283 GetSkyColor; |
284 GetSkyColor; |
284 |
285 |
285 AddProgress; |
286 AddProgress; |
286 |
287 |
287 HHSurface:= LoadImage(Pathz[ptGraphics] + '/' + cHHFileName, true, true, true); |
288 tmpsurf:= LoadImage(Pathz[ptGraphics] + '/' + cHHFileName, true, true, true); |
|
289 HHTexture:= Surface2Tex(tmpsurf); |
|
290 SDL_FreeSurface(tmpsurf); |
288 |
291 |
289 InitHealth; |
292 InitHealth; |
290 |
293 |
291 PauseSurface:= RenderString(trmsg[sidPaused], $FFFF00, fntBig); |
294 PauseSurface:= RenderString(trmsg[sidPaused], $FFFF00, fntBig); |
292 |
295 |
419 r.h:= Source^.h; |
422 r.h:= Source^.h; |
420 SDL_UpperBlit(Source, nil, Surface, @r) |
423 SDL_UpperBlit(Source, nil, Surface, @r) |
421 end; |
424 end; |
422 |
425 |
423 procedure DrawHedgehog(X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Surface: PSDL_Surface); |
426 procedure DrawHedgehog(X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Surface: PSDL_Surface); |
424 var r: TSDL_Rect; |
427 var l, r, t, b: real; |
425 begin |
428 begin |
426 r.x:= Step * 32; |
429 |
427 r.y:= Pos * 32; |
430 t:= Pos * 32 / HHTexture^.h; |
428 if Dir = -1 then r.x:= HHSurface^.w - 32 - r.x; |
431 b:= (Pos + 1) * 32 / HHTexture^.h; |
429 r.w:= 32; |
432 |
430 r.h:= 32; |
433 if Dir = -1 then |
431 //DrawFromRect(X, Y, @r, HHSurface, Surface) |
434 begin |
|
435 l:= (Step + 1) * 32 / HHTexture^.w; |
|
436 r:= Step * 32 / HHTexture^.w |
|
437 end else |
|
438 begin |
|
439 l:= Step * 32 / HHTexture^.w; |
|
440 r:= (Step + 1) * 32 / HHTexture^.w |
|
441 end; |
|
442 |
|
443 glBindTexture(GL_TEXTURE_2D, HHTexture^.id); |
|
444 glEnable(GL_TEXTURE_2D); |
|
445 |
|
446 glBegin(GL_QUADS); |
|
447 |
|
448 glTexCoord2f(l, t); |
|
449 glVertex2i(X, Y); |
|
450 |
|
451 glTexCoord2f(r, t); |
|
452 glVertex2i(32 + X, Y); |
|
453 |
|
454 glTexCoord2f(r, b); |
|
455 glVertex2i(32 + X, 32 + Y); |
|
456 |
|
457 glTexCoord2f(l, b); |
|
458 glVertex2i(X, 32 + Y); |
|
459 |
|
460 glEnd(); |
|
461 |
432 end; |
462 end; |
433 |
463 |
434 procedure StoreRelease; |
464 procedure StoreRelease; |
435 var ii: TSprite; |
465 var ii: TSprite; |
436 begin |
466 begin |
437 for ii:= Low(TSprite) to High(TSprite) do |
467 for ii:= Low(TSprite) to High(TSprite) do |
438 FreeTexture(SpritesData[ii].Texture); |
468 FreeTexture(SpritesData[ii].Texture); |
439 SDL_FreeSurface( HHSurface ); |
469 |
440 SDL_FreeSurface(LandSurface ) |
470 FreeTexture(HHTexture); |
|
471 FreeTexture(LandTexture); |
|
472 |
|
473 SDL_FreeSurface(LandSurface) |
441 end; |
474 end; |
442 |
475 |
443 function RenderString(s: string; Color: Longword; font: THWFont): PSDL_Surface; |
476 function RenderString(s: string; Color: Longword; font: THWFont): PSDL_Surface; |
444 var w, h: LongInt; |
477 var w, h: LongInt; |
445 Result: PSDL_Surface; |
478 Result: PSDL_Surface; |