231 p:= p.Next |
231 p:= p.Next |
232 end |
232 end |
233 end; |
233 end; |
234 |
234 |
235 procedure GetSkyColor; |
235 procedure GetSkyColor; |
236 var p: Longword; |
236 var p: PByteArray; |
237 begin |
237 begin |
238 if SDL_MustLock(SpritesData[sprSky].Surface) then |
238 if SDL_MustLock(SpritesData[sprSky].Surface) then |
239 SDLTry(SDL_LockSurface(SpritesData[sprSky].Surface) >= 0, true); |
239 SDLTry(SDL_LockSurface(SpritesData[sprSky].Surface) >= 0, true); |
240 p:= Longword(SpritesData[sprSky].Surface.pixels); |
240 p:= SpritesData[sprSky].Surface.pixels; |
241 case SpritesData[sprSky].Surface.format.BytesPerPixel of |
241 case SpritesData[sprSky].Surface.format.BytesPerPixel of |
242 1: cSkyColor:= PByte(p)^; |
242 1: cSkyColor:= PByte(p)^; |
243 2: cSkyColor:= PWord(p)^; |
243 2: cSkyColor:= PWord(p)^; |
244 3: cSkyColor:= (PByte(p)^) or (PByte(p + 1)^ shl 8) or (PByte(p + 2)^ shl 16); |
244 3: cSkyColor:= (p^[0]) or (p^[1] shl 8) or (p^[2] shl 16); |
245 4: cSkyColor:= PLongword(p)^; |
245 4: cSkyColor:= PLongword(p)^; |
246 end; |
246 end; |
247 if SDL_MustLock(SpritesData[sprSky].Surface) then |
247 if SDL_MustLock(SpritesData[sprSky].Surface) then |
248 SDL_UnlockSurface(SpritesData[sprSky].Surface) |
248 SDL_UnlockSurface(SpritesData[sprSky].Surface) |
249 end; |
249 end; |
447 function RenderString(var s: shortstring; Color: integer; font: THWFont): PSDL_Surface; |
447 function RenderString(var s: shortstring; Color: integer; font: THWFont): PSDL_Surface; |
448 var w, h: integer; |
448 var w, h: integer; |
449 begin |
449 begin |
450 TTF_SizeUTF8(Fontz[font].Handle, PChar(String(s)), w, h); |
450 TTF_SizeUTF8(Fontz[font].Handle, PChar(String(s)), w, h); |
451 Result:= SDL_CreateRGBSurface(SDL_HWSURFACE, w + 6, h + 2, cBits, PixelFormat.RMask, PixelFormat.GMask, PixelFormat.BMask, 0); |
451 Result:= SDL_CreateRGBSurface(SDL_HWSURFACE, w + 6, h + 2, cBits, PixelFormat.RMask, PixelFormat.GMask, PixelFormat.BMask, 0); |
|
452 TryDo(Result <> nil, 'RenderString: fail to create surface', true); |
452 WriteInRoundRect(Result, 0, 0, Color, font, s); |
453 WriteInRoundRect(Result, 0, 0, Color, font, s); |
453 TryDo(SDL_SetColorKey(Result, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true) |
454 TryDo(SDL_SetColorKey(Result, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true) |
454 end; |
455 end; |
455 |
456 |
456 procedure RenderHealth(var Hedgehog: THedgehog); |
457 procedure RenderHealth(var Hedgehog: THedgehog); |