54 procedure DrawExplosion(X, Y, Radius: integer); |
54 procedure DrawExplosion(X, Y, Radius: integer); |
55 procedure DrawLineExplosions(ar: PRangeArray; Radius: Longword; y, dY: integer; Count: Byte); |
55 procedure DrawLineExplosions(ar: PRangeArray; Radius: Longword; y, dY: integer; Count: Byte); |
56 procedure RenderHealth(var Hedgehog: THedgehog); |
56 procedure RenderHealth(var Hedgehog: THedgehog); |
57 function RenderString(var s: shortstring; Color, Pos: integer): TSDL_Rect; |
57 function RenderString(var s: shortstring; Color, Pos: integer): TSDL_Rect; |
58 procedure AddProgress; |
58 procedure AddProgress; |
59 function LoadImage(filename: string): PSDL_Surface; |
59 function LoadImage(filename: string; hasAlpha: boolean): PSDL_Surface; |
60 |
60 |
61 var PixelFormat: PSDL_PixelFormat; |
61 var PixelFormat: PSDL_PixelFormat; |
62 SDLPrimSurface: PSDL_Surface; |
62 SDLPrimSurface: PSDL_Surface; |
63 |
63 |
64 implementation |
64 implementation |
187 if SDL_MustLock(LandSurface) then |
187 if SDL_MustLock(LandSurface) then |
188 SDL_UnlockSurface(LandSurface); |
188 SDL_UnlockSurface(LandSurface); |
189 end; |
189 end; |
190 |
190 |
191 procedure StoreInit; |
191 procedure StoreInit; |
|
192 var r: TSDL_Rect; |
192 begin |
193 begin |
193 StoreSurface := SDL_CreateRGBSurface(SDL_HWSURFACE, 576, 1024, cBits, PixelFormat.RMask, PixelFormat.GMask, PixelFormat.BMask, 0); |
194 StoreSurface := SDL_CreateRGBSurface(SDL_HWSURFACE, 576, 1024, cBits, PixelFormat.RMask, PixelFormat.GMask, PixelFormat.BMask, 0); |
194 TryDo( StoreSurface <> nil, errmsgCreateSurface + ': store' , true); |
195 TryDo( StoreSurface <> nil, errmsgCreateSurface + ': store' , true); |
|
196 r.x:= 0; |
|
197 r.y:= 0; |
|
198 r.w:= 576; |
|
199 r.h:= 1024; |
|
200 SDL_FillRect(StoreSurface, @r, 0); |
195 |
201 |
196 TempSurface := SDL_CreateRGBSurface(SDL_HWSURFACE, 724, 320, cBits, PixelFormat.RMask, PixelFormat.GMask, PixelFormat.BMask, 0); |
202 TempSurface := SDL_CreateRGBSurface(SDL_HWSURFACE, 724, 320, cBits, PixelFormat.RMask, PixelFormat.GMask, PixelFormat.BMask, 0); |
197 TryDo( TempSurface <> nil, errmsgCreateSurface + ': temp' , true); |
203 TryDo( TempSurface <> nil, errmsgCreateSurface + ': temp' , true); |
198 |
204 |
199 TryDo(SDL_SetColorKey( StoreSurface, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true); |
205 TryDo(SDL_SetColorKey( StoreSurface, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true); |
203 |
209 |
204 procedure LoadToSurface(Filename: String; Surface: PSDL_Surface; X, Y: integer); |
210 procedure LoadToSurface(Filename: String; Surface: PSDL_Surface; X, Y: integer); |
205 var tmpsurf: PSDL_Surface; |
211 var tmpsurf: PSDL_Surface; |
206 rr: TSDL_Rect; |
212 rr: TSDL_Rect; |
207 begin |
213 begin |
208 tmpsurf:= LoadImage(Filename); |
214 tmpsurf:= LoadImage(Filename, false); |
209 rr.x:= X; |
215 rr.x:= X; |
210 rr.y:= Y; |
216 rr.y:= Y; |
211 SDL_UpperBlit(tmpsurf, nil, Surface, @rr); |
217 SDL_UpperBlit(tmpsurf, nil, Surface, @rr); |
212 SDL_FreeSurface(tmpsurf); |
218 SDL_FreeSurface(tmpsurf); |
213 end; |
219 end; |
404 Handle:= TTF_OpenFont(PChar(s), Height); |
410 Handle:= TTF_OpenFont(PChar(s), Height); |
405 TryDo(Handle <> nil, msgFailed, true); |
411 TryDo(Handle <> nil, msgFailed, true); |
406 WriteLnToConsole(msgOK) |
412 WriteLnToConsole(msgOK) |
407 end; |
413 end; |
408 AddProgress; |
414 AddProgress; |
409 s:= Pathz[ptMapCurrent] + cLandFileName; |
415 //s:= Pathz[ptMapCurrent] + cLandFileName; |
410 WriteToConsole(msgLoading + s + ' '); // загружаем текущее поле |
416 //WriteToConsole(msgLoading + s + ' '); |
411 //tmpsurf:= IMG_Load(PChar(s)); |
417 //tmpsurf:= IMG_Load(PChar(s)); |
412 tmpsurf:= LandSurface; |
418 tmpsurf:= LandSurface; |
413 TryDo(tmpsurf <> nil, msgFailed, true); |
419 TryDo(tmpsurf <> nil, msgFailed, true); |
414 if cFullScreen then |
420 if cFullScreen then |
415 begin |
421 begin |
416 LandSurface:= SDL_DisplayFormat(tmpsurf); |
422 LandSurface:= SDL_DisplayFormat(tmpsurf); |
417 SDL_FreeSurface(tmpsurf); |
423 SDL_FreeSurface(tmpsurf); |
418 end else LandSurface:= tmpsurf; |
424 end else LandSurface:= tmpsurf; |
419 TryDo(SDL_SetColorKey(LandSurface, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true); |
425 TryDo(SDL_SetColorKey(LandSurface, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true); |
420 WriteLnToConsole(msgOK); |
426 WriteLnToConsole(msgOK); |
421 |
427 |
422 GetExplosionBorderColor; |
428 GetExplosionBorderColor; |
423 |
429 |
424 AddProgress; |
430 AddProgress; |
433 GetSkyColor; |
439 GetSkyColor; |
434 |
440 |
435 AddProgress; |
441 AddProgress; |
436 for ii:= Low(TSprite) to High(TSprite) do |
442 for ii:= Low(TSprite) to High(TSprite) do |
437 with SpritesData[ii] do |
443 with SpritesData[ii] do |
438 begin |
444 Surface:= LoadImage(Pathz[Path] + FileName, hasAlpha); |
439 Surface:= LoadImage(Pathz[Path] + FileName); |
|
440 TryDo(SDL_SetColorKey(Surface, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true) |
|
441 end; |
|
442 |
445 |
443 AddProgress; |
446 AddProgress; |
444 tmpsurf:= LoadImage(Pathz[ptGraphics] + cHHFileName); |
447 tmpsurf:= LoadImage(Pathz[ptGraphics] + cHHFileName, false); |
|
448 TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true); |
445 HHSurface:= SDL_DisplayFormat(tmpsurf); |
449 HHSurface:= SDL_DisplayFormat(tmpsurf); |
446 SDL_FreeSurface(tmpsurf); |
450 SDL_FreeSurface(tmpsurf); |
447 TryDo(SDL_SetColorKey(HHSurface, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true); |
|
448 |
451 |
449 InitHealth; |
452 InitHealth; |
450 |
453 |
451 {$IFDEF DUMP} |
454 {$IFDEF DUMP} |
452 SDL_SaveBMP_RW(LandSurface, SDL_RWFromFile('LandSurface.bmp', 'wb'), 1); |
455 SDL_SaveBMP_RW(LandSurface, SDL_RWFromFile('LandSurface.bmp', 'wb'), 1); |
581 WriteLnToConsole('Freeing progress surface... '); |
584 WriteLnToConsole('Freeing progress surface... '); |
582 SDL_FreeSurface(ProgrSurf) |
585 SDL_FreeSurface(ProgrSurf) |
583 end; |
586 end; |
584 end; |
587 end; |
585 |
588 |
586 function LoadImage(filename: string): PSDL_Surface; |
589 function LoadImage(filename: string; hasAlpha: boolean): PSDL_Surface; |
587 var tmpsurf: PSDL_Surface; |
590 var tmpsurf: PSDL_Surface; |
588 begin |
591 begin |
589 WriteToConsole(msgLoading + filename + '... '); |
592 WriteToConsole(msgLoading + filename + '... '); |
590 tmpsurf:= IMG_Load(PChar(filename)); |
593 tmpsurf:= IMG_Load(PChar(filename)); |
591 TryDo(tmpsurf <> nil, msgFailed, true); |
594 TryDo(tmpsurf <> nil, msgFailed, true); |
|
595 TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true); |
592 if cFullScreen then |
596 if cFullScreen then |
593 begin |
597 begin |
594 Result:= SDL_DisplayFormat(tmpsurf); |
598 if hasAlpha then Result:= SDL_DisplayFormatAlpha(tmpsurf) |
|
599 else Result:= SDL_DisplayFormat(tmpsurf); |
595 SDL_FreeSurface(tmpsurf); |
600 SDL_FreeSurface(tmpsurf); |
596 end else Result:= tmpsurf; |
601 end else Result:= tmpsurf; |
597 WriteLnToConsole(msgOK) |
602 WriteLnToConsole(msgOK) |
598 end; |
603 end; |
599 |
604 |