~ubuntu-branches/ubuntu/wily/hedgewars/wily

« back to all changes in this revision

Viewing changes to hedgewars/uWorld.pas

  • Committer: Package Import Robot
  • Author(s): Dmitry E. Oboukhov
  • Date: 2011-09-23 10:16:55 UTC
  • mfrom: (1.2.11 upstream)
  • Revision ID: package-import@ubuntu.com-20110923101655-3977th2gc5n0a3pv
Tags: 0.9.16-1
* New upstream version.
 + Downloadable content! Simply click to install any content.
   New voices, hats, maps, themes, translations, music, scripts...
   Hedgewars is now more customisable than ever before! As time goes
   by we will be soliciting community content to feature on this page,
   so remember to check it from time to time. If you decide you want
   to go back to standard Hedgewars, just remove the Data directory
   from your Hedgewars config directory.
 + 3-D rendering! Diorama-like rendering of the game in a variety
   of 3D modes. Let us know which ones work best for you, we didn't
   really have the equipment to test them all.
 + Resizable game window.
 + New utilities! The Time Box will remove one of your hedgehogs
   from the game for a while, protecting from attack until it returns,
   somewhere else on the map. Land spray will allow you to build bridges,
   seal up holes, or just make life unpleasant for your enemies.
 + New single player: Bamboo Thicket, That Sinking Feeling, Newton and
   the Tree and multi-player: The Specialists, Space Invaders,
   Racer - scripts! And a ton more script hooks for scripters
 + New twists on old weapons. Drill strike, seduction and fire have
   been adjusted. Defective mines have been added, rope can attach to
   hogs/crates/barrels again, grenades now have variable bounce (use
   precise key + 1-5). Portal gun is now more usable in flight and
   all game actions are a lot faster.
 + New theme - Golf, dozens of new community hats and a new
   localised Default voice, Ukranian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
(*
2
2
 * Hedgewars, a free turn based strategy game
3
 
 * Copyright (c) 2004-2010 Andrey Korotaev <unC0Rr@gmail.com>
 
3
 * Copyright (c) 2004-2011 Andrey Korotaev <unC0Rr@gmail.com>
4
4
 *
5
5
 * This program is free software; you can redistribute it and/or modify
6
6
 * it under the terms of the GNU General Public License as published by
17
17
 *)
18
18
 
19
19
{$INCLUDE "options.inc"}
 
20
{$IF GLunit = GL}{$DEFINE GLunit:=GL,GLext}{$ENDIF}
20
21
 
21
22
unit uWorld;
22
23
interface
27
28
 
28
29
procedure InitWorld;
29
30
procedure DrawWorld(Lag: LongInt);
 
31
procedure DrawWorldStereo(Lag: LongInt; RM: TRenderMode);
30
32
procedure ShowMission(caption, subcaption, text: ansistring; icon, time : LongInt);
31
33
procedure HideMission;
32
34
procedure ShakeCamera(amount: LongWord);
 
35
procedure InitCameraBorders;
33
36
procedure MoveCamera;
 
37
procedure onFocusStateChanged;
34
38
 
35
39
implementation
36
40
uses
48
52
    uUtils,
49
53
    uTextures,
50
54
    uRender,
51
 
    uCaptions
 
55
    uCaptions,
 
56
    uCursor,
 
57
    uCommands
52
58
    ;
53
59
 
54
60
var cWaveWidth, cWaveHeight: LongInt;
63
69
    amSel: TAmmoType = amNothing;
64
70
    missionTex: PTexture;
65
71
    missionTimer: LongInt;
 
72
    stereoDepth: GLfloat;
 
73
 
 
74
const cStereo_Sky           = 0.0500;
 
75
      cStereo_Horizon       = 0.0250;
 
76
      cStereo_Water_distant = 0.0125;
 
77
      cStereo_Land          = 0.0075;
 
78
      cStereo_Water_near    = 0.0025;
 
79
      cStereo_Outside       = 0.0400;
66
80
 
67
81
procedure InitWorld;
68
82
var i, t: LongInt;
112
126
// if special game flags/settings are changed, add them to the game mode notice window and then show it
113
127
g:= ''; // no text/things to note yet
114
128
 
 
129
// add custom goals from lua script if there are any
 
130
if LuaGoals <> '' then g:= LuaGoals + '|';
 
131
 
115
132
// check different game flags (goals/game modes first for now)
116
133
g:= AddGoal(g, gfKing, gidKing); // king?
 
134
g:= AddGoal(g, gfTagTeam, gidTagTeam); // tag team mode?
117
135
 
118
136
// other important flags
119
137
g:= AddGoal(g, gfForts, gidForts); // forts?
158
176
//cWaveHeight:= SpritesData[sprWater].Height;
159
177
cWaveHeight:= 32;
160
178
 
161
 
cGearScrEdgesDist:= Min(cScreenWidth div 2 - 100, cScreenHeight div 2 - 50);
162
 
SDL_WarpMouse(cScreenWidth div 2, cScreenHeight div 2);
 
179
InitCameraBorders();
 
180
uCursor.init();
163
181
prevPoint.X:= 0;
164
182
prevPoint.Y:= cScreenHeight div 2;
165
183
WorldDx:=  - (LAND_WIDTH div 2) + cScreenWidth div 2;
179
197
HorizontOffset:= 0;
180
198
end;
181
199
 
 
200
procedure InitCameraBorders;
 
201
begin
 
202
cGearScrEdgesDist:= min(2 * cScreenHeight div 5, 2 * cScreenWidth div 5);
 
203
end;
182
204
 
183
205
procedure ShowAmmoMenu;
184
206
const MENUSPEED = 15;
197
219
       AMxShift:= 0
198
220
   else
199
221
       if AMxShift > MENUSPEED then
200
 
           dec(AMxShift, MENUSPEED)
 
222
           dec(AMxShift, MENUSPEED)
201
223
       else
202
224
           AMxShift:= 0;
203
225
   end else
207
229
      CursorPoint.X:= cScreenWidth shr 1;
208
230
      CursorPoint.Y:= cScreenHeight shr 1;
209
231
      prevPoint:= CursorPoint;
210
 
      SDL_WarpMouse(CursorPoint.X  + cScreenWidth div 2, cScreenHeight - CursorPoint.Y)
211
232
      end;
212
233
   if (cReducedQuality and rqSlowMenu) <> 0 then
213
234
       AMxShift:= AMWidth
238
259
dec(y, BORDERSIZE);
239
260
DrawSprite(sprAMCorners, x - BORDERSIZE, y, 0);
240
261
for i:= 0 to cMaxSlotAmmoIndex do
241
 
        DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 0);
 
262
    DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 0);
242
263
DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 1);
243
264
inc(y, BORDERSIZE);
244
265
 
289
310
y:= cScreenHeight - AMyOffset;
290
311
DrawSprite(sprAMCorners, x - BORDERSIZE, y, 2);
291
312
for i:= 0 to cMaxSlotAmmoIndex + 1 do
292
 
        DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 1);
 
313
    DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 1);
293
314
DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 3);
294
315
dec(y, AMSlotSize);
295
316
DrawSprite(sprAMBorderVertical, x - BORDERSIZE, y, 0);
296
317
for i:= 0 to cMaxSlotAmmoIndex do
297
 
        DrawSprite(sprAMSlot, x + i * AMSlotSize, y, 2);
 
318
    DrawSprite(sprAMSlot, x + i * AMSlotSize, y, 2);
298
319
DrawSprite(sprAMSlot, x + (cMaxSlotAmmoIndex + 1) * AMSlotSize, y, 1);
299
320
DrawSprite(sprAMBorderVertical, x + AMWidth - AMxOffset, y, 1);
300
321
 
341
362
dec(y, BORDERSIZE);
342
363
DrawSprite(sprAMCorners, x - BORDERSIZE, y, 0);
343
364
for i:= 0 to cMaxSlotAmmoIndex + 1 do
344
 
        DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 0);
 
365
    DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 0);
345
366
DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 1);
346
367
{$ENDIF}
347
368
 
394
415
    r: TSDL_Rect;
395
416
    lw, lh: GLfloat;
396
417
begin
397
 
    WaterColorArray[0].a := Alpha;
398
 
    WaterColorArray[1].a := Alpha;
399
 
    WaterColorArray[2].a := Alpha;
400
 
    WaterColorArray[3].a := Alpha;
 
418
    if SuddenDeathDmg then
 
419
        begin
 
420
        SDWaterColorArray[0].a := Alpha;
 
421
        SDWaterColorArray[1].a := Alpha;
 
422
        SDWaterColorArray[2].a := Alpha;
 
423
        SDWaterColorArray[3].a := Alpha
 
424
        end
 
425
    else
 
426
        begin
 
427
        WaterColorArray[0].a := Alpha;
 
428
        WaterColorArray[1].a := Alpha;
 
429
        WaterColorArray[2].a := Alpha;
 
430
        WaterColorArray[3].a := Alpha
 
431
        end;
401
432
 
402
433
    lw:= cScreenWidth / cScaleFactor;
403
434
    lh:= trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 + 16;
421
452
 
422
453
        glDisableClientState(GL_TEXTURE_COORD_ARRAY);
423
454
        glEnableClientState(GL_COLOR_ARRAY);
424
 
        glColorPointer(4, GL_UNSIGNED_BYTE, 0, @WaterColorArray[0]);
 
455
        if SuddenDeathDmg then
 
456
            glColorPointer(4, GL_UNSIGNED_BYTE, 0, @SDWaterColorArray[0])
 
457
        else
 
458
            glColorPointer(4, GL_UNSIGNED_BYTE, 0, @WaterColorArray[0]);
425
459
 
426
460
        glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]);
427
461
 
437
471
procedure DrawWaves(Dir, dX, dY: LongInt; tnt: Byte);
438
472
var VertexBuffer, TextureBuffer: array [0..3] of TVertex2f;
439
473
    lw, waves, shift: GLfloat;
 
474
    sprite: TSprite;
440
475
begin
 
476
if SuddenDeathDmg then
 
477
    sprite:= sprSDWater
 
478
else
 
479
    sprite:= sprWater;
 
480
 
 
481
cWaveWidth:= SpritesData[sprite].Width;
 
482
 
441
483
lw:= cScreenWidth / cScaleFactor;
442
484
waves:= lw * 2 / cWaveWidth;
443
485
 
444
 
Tint(LongInt(tnt) * WaterColorArray[2].r div 255 + 255 - tnt,
445
 
     LongInt(tnt) * WaterColorArray[2].g div 255 + 255 - tnt,
446
 
     LongInt(tnt) * WaterColorArray[2].b div 255 + 255 - tnt,
447
 
     255
448
 
);
 
486
if SuddenDeathDmg then
 
487
    Tint(LongInt(tnt) * SDWaterColorArray[2].r div 255 + 255 - tnt,
 
488
         LongInt(tnt) * SDWaterColorArray[2].g div 255 + 255 - tnt,
 
489
         LongInt(tnt) * SDWaterColorArray[2].b div 255 + 255 - tnt,
 
490
         255
 
491
    )
 
492
else
 
493
    Tint(LongInt(tnt) * WaterColorArray[2].r div 255 + 255 - tnt,
 
494
         LongInt(tnt) * WaterColorArray[2].g div 255 + 255 - tnt,
 
495
         LongInt(tnt) * WaterColorArray[2].b div 255 + 255 - tnt,
 
496
         255
 
497
    );
449
498
 
450
 
glBindTexture(GL_TEXTURE_2D, SpritesData[sprWater].Texture^.id);
 
499
glBindTexture(GL_TEXTURE_2D, SpritesData[sprite].Texture^.id);
451
500
 
452
501
VertexBuffer[0].X:= -lw;
453
502
VertexBuffer[0].Y:= cWaterLine + WorldDy + dY;
454
503
VertexBuffer[1].X:= lw;
455
504
VertexBuffer[1].Y:= VertexBuffer[0].Y;
456
505
VertexBuffer[2].X:= lw;
457
 
VertexBuffer[2].Y:= VertexBuffer[0].Y + SpritesData[sprWater].Height;
 
506
VertexBuffer[2].Y:= VertexBuffer[0].Y + SpritesData[sprite].Height;
458
507
VertexBuffer[3].X:= -lw;
459
508
VertexBuffer[3].Y:= VertexBuffer[2].Y;
460
509
 
464
513
TextureBuffer[1].X:= TextureBuffer[0].X + waves;
465
514
TextureBuffer[1].Y:= TextureBuffer[0].Y;
466
515
TextureBuffer[2].X:= TextureBuffer[1].X;
467
 
TextureBuffer[2].Y:= SpritesData[sprWater].Texture^.ry;
 
516
TextureBuffer[2].Y:= SpritesData[sprite].Texture^.ry;
468
517
TextureBuffer[3].X:= TextureBuffer[0].X;
469
518
TextureBuffer[3].Y:= TextureBuffer[2].Y;
470
519
 
486
535
var i, w, h, lw, lh, rw, rh, sw: LongInt;
487
536
begin
488
537
    sw:= round(cScreenWidth / cScaleFactor);
489
 
    if (SpritesData[sprL].Texture = nil) or (SpritesData[sprR].Texture = nil) then
490
 
    begin
 
538
    if ((SpritesData[sprL].Texture = nil) or (SpritesData[sprR].Texture = nil)) and (SpritesData[spr].Texture <> nil) then
 
539
        begin
491
540
        w:= SpritesData[spr].Width * SpritesData[spr].Texture^.Scale;
492
541
        h:= SpritesData[spr].Height * SpritesData[spr].Texture^.Scale;
493
542
        i:= Shift mod w;
497
546
            DrawTexture(i, WorldDy + LAND_HEIGHT + OffsetY - h, SpritesData[spr].Texture, SpritesData[spr].Texture^.Scale);
498
547
            inc(i, w)
499
548
        until i > sw
500
 
    end
501
 
    else
502
 
    begin
 
549
        end
 
550
    else if SpritesData[spr].Texture <> nil then
 
551
        begin
503
552
        w:= SpritesData[spr].Width * SpritesData[spr].Texture^.Scale;
504
553
        h:= SpritesData[spr].Height * SpritesData[spr].Texture^.Scale;
505
554
        lw:= SpritesData[sprL].Width * SpritesData[spr].Texture^.Scale;
511
560
 
512
561
        i:= Shift - lw;
513
562
        while i >= -sw - lw do
514
 
        begin
 
563
            begin
515
564
            DrawTexture(i, WorldDy + LAND_HEIGHT + OffsetY - lh, SpritesData[sprL].Texture, SpritesData[sprL].Texture^.Scale);
516
565
            dec(i, lw);
517
 
        end;
 
566
            end;
518
567
 
519
568
        i:= Shift + w;
520
569
        while i <= sw do
521
 
        begin
 
570
            begin
522
571
            DrawTexture(i, WorldDy + LAND_HEIGHT + OffsetY - rh, SpritesData[sprR].Texture, SpritesData[sprR].Texture^.Scale);
523
572
            inc(i, rw)
 
573
            end
524
574
        end
525
 
    end
526
575
end;
527
576
 
528
577
 
529
578
procedure DrawWorld(Lag: LongInt);
530
 
var i, t: LongInt;
531
 
    r: TSDL_Rect;
532
 
    tdx, tdy: Double;
533
 
    s: string[15];
534
 
    highlight: Boolean;
535
 
    offsetX, offsetY, ScreenBottom: LongInt;
536
 
    VertexBuffer: array [0..3] of TVertex2f;
537
579
begin
538
580
    if not isPaused then
539
581
    begin
562
604
    if not isPaused then
563
605
        MoveCamera;
564
606
 
 
607
    if cStereoMode = smNone then
 
608
        begin
 
609
        glClear(GL_COLOR_BUFFER_BIT);
 
610
        DrawWorldStereo(Lag, rmDefault)
 
611
        end
 
612
{$IFNDEF S3D_DISABLED}
 
613
    else if (cStereoMode = smAFR) then
 
614
        begin
 
615
        AFRToggle:= not AFRToggle;
 
616
        glClear(GL_COLOR_BUFFER_BIT);
 
617
        if AFRToggle then
 
618
            DrawWorldStereo(Lag, rmLeftEye)
 
619
        else
 
620
            DrawWorldStereo(Lag, rmRightEye)
 
621
        end
 
622
    else if (cStereoMode = smHorizontal) or (cStereoMode = smVertical) then
 
623
        begin
 
624
        // create left fb
 
625
        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framel);
 
626
        glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
 
627
        DrawWorldStereo(Lag, rmLeftEye);
 
628
 
 
629
        // create right fb
 
630
        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framer);
 
631
        glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
 
632
        DrawWorldStereo(0, rmRightEye);
 
633
 
 
634
        // detatch drawing from fbs
 
635
        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
 
636
        glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
 
637
        SetScale(cDefaultZoomLevel);
 
638
 
 
639
        // draw left frame
 
640
        glBindTexture(GL_TEXTURE_2D, texl);
 
641
        glBegin(GL_QUADS);
 
642
            if cStereoMode = smHorizontal then
 
643
                begin
 
644
                glTexCoord2f(0.0, 0.0);
 
645
                glVertex2d(cScreenWidth / -2, cScreenHeight);
 
646
                glTexCoord2f(1.0, 0.0);
 
647
                glVertex2d(0, cScreenHeight);
 
648
                glTexCoord2f(1.0, 1.0);
 
649
                glVertex2d(0, 0);
 
650
                glTexCoord2f(0.0, 1.0);
 
651
                glVertex2d(cScreenWidth / -2, 0);
 
652
                end
 
653
            else
 
654
                begin
 
655
                glTexCoord2f(0.0, 0.0);
 
656
                glVertex2d(cScreenWidth / -2, cScreenHeight / 2);
 
657
                glTexCoord2f(1.0, 0.0);
 
658
                glVertex2d(cScreenWidth / 2, cScreenHeight / 2);
 
659
                glTexCoord2f(1.0, 1.0);
 
660
                glVertex2d(cScreenWidth / 2, 0);
 
661
                glTexCoord2f(0.0, 1.0);
 
662
                glVertex2d(cScreenWidth / -2, 0);
 
663
                end;
 
664
        glEnd();
 
665
 
 
666
        // draw right frame
 
667
        glBindTexture(GL_TEXTURE_2D, texr);
 
668
        glBegin(GL_QUADS);
 
669
            if cStereoMode = smHorizontal then
 
670
                begin
 
671
                glTexCoord2f(0.0, 0.0);
 
672
                glVertex2d(0, cScreenHeight);
 
673
                glTexCoord2f(1.0, 0.0);
 
674
                glVertex2d(cScreenWidth / 2, cScreenHeight);
 
675
                glTexCoord2f(1.0, 1.0);
 
676
                glVertex2d(cScreenWidth / 2, 0);
 
677
                glTexCoord2f(0.0, 1.0);
 
678
                glVertex2d(0, 0);
 
679
                end
 
680
            else
 
681
                begin
 
682
                glTexCoord2f(0.0, 0.0);
 
683
                glVertex2d(cScreenWidth / -2, cScreenHeight);
 
684
                glTexCoord2f(1.0, 0.0);
 
685
                glVertex2d(cScreenWidth / 2, cScreenHeight);
 
686
                glTexCoord2f(1.0, 1.0);
 
687
                glVertex2d(cScreenWidth / 2, cScreenHeight / 2);
 
688
                glTexCoord2f(0.0, 1.0);
 
689
                glVertex2d(cScreenWidth / -2, cScreenHeight / 2);
 
690
                end;
 
691
        glEnd();
 
692
        SetScale(zoom);
 
693
        end
 
694
    else
 
695
        begin
 
696
        // clear scene
 
697
        glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
 
698
        glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
 
699
        // draw left eye in red channel only
 
700
        if cStereoMode = smGreenRed then
 
701
            glColorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_TRUE)
 
702
        else if cStereoMode = smBlueRed then
 
703
            glColorMask(GL_FALSE, GL_FALSE, GL_TRUE, GL_TRUE)
 
704
        else if cStereoMode = smCyanRed then
 
705
            glColorMask(GL_FALSE, GL_TRUE, GL_TRUE, GL_TRUE)
 
706
        else
 
707
            glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_TRUE);
 
708
        DrawWorldStereo(Lag, rmLeftEye);
 
709
        // draw right eye in selected channel(s) only
 
710
        if cStereoMode = smRedGreen then
 
711
            glColorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_TRUE)
 
712
        else if cStereoMode = smRedBlue then
 
713
            glColorMask(GL_FALSE, GL_FALSE, GL_TRUE, GL_TRUE)
 
714
        else if cStereoMode = smRedCyan then
 
715
            glColorMask(GL_FALSE, GL_TRUE, GL_TRUE, GL_TRUE)
 
716
        else
 
717
            glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_TRUE);
 
718
        DrawWorldStereo(Lag, rmRightEye);
 
719
        end
 
720
{$ENDIF}
 
721
end;
 
722
 
 
723
procedure ChangeDepth(rm: TRenderMode; d: GLfloat);
 
724
begin
 
725
{$IFDEF S3D_DISABLED}
 
726
    rm:= rm; d:= d; // avoid hint
 
727
    exit;
 
728
{$ELSE}
 
729
    d:= d / 5;
 
730
    if rm = rmDefault then exit
 
731
    else if rm = rmLeftEye then d:= -d;
 
732
    stereoDepth:= stereoDepth + d;
 
733
    glMatrixMode(GL_PROJECTION);
 
734
    glTranslatef(d, 0, 0);
 
735
    glMatrixMode(GL_MODELVIEW);
 
736
{$ENDIF}
 
737
end;
 
738
 
 
739
procedure ResetDepth(rm: TRenderMode);
 
740
begin
 
741
{$IFDEF S3D_DISABLED}
 
742
    rm:= rm; // avoid hint
 
743
    exit;
 
744
{$ELSE}
 
745
    if rm = rmDefault then exit;
 
746
    glMatrixMode(GL_PROJECTION);
 
747
    glTranslatef(-stereoDepth, 0, 0);
 
748
    glMatrixMode(GL_MODELVIEW);
 
749
    stereoDepth:= 0;
 
750
{$ENDIF}
 
751
end;
 
752
 
 
753
procedure DrawWorldStereo(Lag: LongInt; RM: TRenderMode);
 
754
var i, t: LongInt;
 
755
    r: TSDL_Rect;
 
756
    tdx, tdy: Double;
 
757
    s: string[15];
 
758
    highlight: Boolean;
 
759
    smallScreenOffset, offsetX, offsetY, screenBottom: LongInt;
 
760
    VertexBuffer: array [0..3] of TVertex2f;
 
761
begin
565
762
    if (cReducedQuality and rqNoBackground) = 0 then
566
763
    begin
567
764
        // Offsets relative to camera - spare them to wimpier cpus, no bg or flakes for them anyway
573
770
            HorizontOffset:= HorizontOffset + ((ScreenBottom-SkyOffset) div 20);
574
771
 
575
772
        // background
 
773
        ChangeDepth(RM, cStereo_Sky);
 
774
        if SuddenDeathDmg then Tint(SDTint, SDTint, SDTint, $FF);
576
775
        DrawRepeated(sprSky, sprSkyL, sprSkyR, (WorldDx + LAND_WIDTH div 2) * 3 div 8, SkyOffset);
 
776
        ChangeDepth(RM, -cStereo_Horizon);
577
777
        DrawRepeated(sprHorizont, sprHorizontL, sprHorizontR, (WorldDx + LAND_WIDTH div 2) * 3 div 5, HorizontOffset);
 
778
        if SuddenDeathDmg then Tint($FF, $FF, $FF, $FF);
578
779
    end;
579
780
 
580
781
    DrawVisualGears(0);
582
783
    if (cReducedQuality and rq2DWater) = 0 then
583
784
    begin
584
785
        // Waves
585
 
        DrawWater(255, SkyOffset);
 
786
        DrawWater(255, SkyOffset); 
 
787
        ChangeDepth(RM, -cStereo_Water_distant);
586
788
        DrawWaves( 1,  0 - WorldDx div 32, - cWaveHeight + offsetY div 35, 64);
 
789
        ChangeDepth(RM, -cStereo_Water_distant);
587
790
        DrawWaves( -1,  25 + WorldDx div 25, - cWaveHeight + offsetY div 38, 48);
 
791
        ChangeDepth(RM, -cStereo_Water_distant);
588
792
        DrawWaves( 1,  75 - WorldDx div 19, - cWaveHeight + offsetY div 45, 32);
 
793
        ChangeDepth(RM, -cStereo_Water_distant);
589
794
        DrawWaves(-1, 100 + WorldDx div 14, - cWaveHeight + offsetY div 70, 24);
590
795
    end
591
796
    else
592
797
        DrawWaves(-1, 100, - (cWaveHeight + (cWaveHeight shr 1)), 0);
593
798
 
 
799
    changeDepth(RM, cStereo_Land);
594
800
    DrawLand(WorldDx, WorldDy);
595
801
 
596
802
    DrawWater(255, 0);
618
824
        end;
619
825
 
620
826
    DrawVisualGears(1);
621
 
 
622
827
    DrawGears;
623
828
 
624
 
    DrawVisualGears(2);
625
 
 
626
 
    DrawWater(cWaterOpacity, 0);
 
829
    if SuddenDeathDmg then
 
830
        DrawWater(cSDWaterOpacity, 0)
 
831
    else
 
832
        DrawWater(cWaterOpacity, 0);
627
833
 
628
834
    // Waves
 
835
    ChangeDepth(RM, cStereo_Water_near);
629
836
    DrawWaves( 1, 25 - WorldDx div 9, - cWaveHeight, 12);
630
837
 
631
838
    if (cReducedQuality and rq2DWater) = 0 then
632
839
    begin
633
840
        //DrawWater(cWaterOpacity, - offsetY div 40);
 
841
        ChangeDepth(RM, cStereo_Water_near);
634
842
        DrawWaves(-1, 50 + WorldDx div 6, - cWaveHeight - offsetY div 40, 8);
635
 
        DrawWater(cWaterOpacity, - offsetY div 20);
 
843
        if SuddenDeathDmg then
 
844
            DrawWater(cSDWaterOpacity, - offsetY div 20)
 
845
        else
 
846
            DrawWater(cWaterOpacity, - offsetY div 20);
 
847
        ChangeDepth(RM, cStereo_Water_near);
636
848
        DrawWaves( 1, 75 - WorldDx div 4, - cWaveHeight - offsetY div 20, 2);
637
 
        DrawWater(cWaterOpacity, - offsetY div 10);
 
849
        if SuddenDeathDmg then
 
850
            DrawWater(cSDWaterOpacity, - offsetY div 10)
 
851
        else
 
852
            DrawWater(cWaterOpacity, - offsetY div 10);
 
853
        ChangeDepth(RM, cStereo_Water_near);
638
854
        DrawWaves( -1, 25 + WorldDx div 3, - cWaveHeight - offsetY div 10, 0);
639
855
    end
640
856
    else
641
857
        DrawWaves(-1, 50, - (cWaveHeight shr 1), 0);
642
858
 
 
859
// everything after this ChangeDepth will be drawn outside the screen
 
860
// note: negative parallax gears should last very little for a smooth stereo effect
 
861
    ChangeDepth(RM, cStereo_Outside);
 
862
    DrawVisualGears(2);
 
863
 
 
864
// everything after this ResetDepth will be drawn at screen level (depth = 0)
 
865
// note: everything that needs to be readable should be on this level
 
866
    ResetDepth(RM);
 
867
    DrawVisualGears(3);
643
868
 
644
869
{$WARNINGS OFF}
645
870
// Target
647
872
    begin
648
873
    with PHedgehog(CurrentHedgehog)^ do
649
874
        begin
650
 
        if (CurAmmoType = amBee) then
 
875
        if CurAmmoType = amBee then
651
876
            DrawRotatedF(sprTargetBee, TargetPoint.X + WorldDx, TargetPoint.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360)
652
877
        else
653
 
            DrawRotatedF(sprTargetP, TargetPoint.X + WorldDx, TargetPoint.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360);
654
 
        end;
 
878
            DrawRotatedF(sprTargetP, TargetPoint.X + WorldDx, TargetPoint.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360)
 
879
        end
655
880
    end;
656
881
{$WARNINGS ON}
657
882
 
658
883
// this scale is used to keep the various widgets at the same dimension at all zoom levels
659
884
SetScale(cDefaultZoomLevel);
660
885
 
661
 
 
662
886
// Turn time
663
887
{$IFDEF IPHONEOS}
664
888
offsetX:= cScreenHeight - 13;
686
910
   DrawSprite(sprFrame, -(cScreenWidth shr 1) + t - 4 + offsetY, cScreenHeight - offsetX, 0);
687
911
   end;
688
912
 
689
 
{$IFNDEF IPHONEOS}
690
 
// Timetrial
691
 
if ((TrainingFlags and tfTimeTrial) <> 0) and (TimeTrialStartTime > 0) then
692
 
    begin
693
 
    if TimeTrialStopTime = 0 then i:= RealTicks - TimeTrialStartTime else i:= TimeTrialStopTime - TimeTrialStartTime;
694
 
    t:= 272;
695
 
    // right frame
696
 
    DrawSprite(sprFrame, -cScreenWidth div 2 + t, 8, 1);
697
 
    dec(t, 32);
698
 
    // 1 ms
699
 
    DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, i mod 10);
700
 
    dec(t, 32);
701
 
    i:= i div 10;
702
 
    // 10 ms
703
 
    DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, i mod 10);
704
 
    dec(t, 32);
705
 
    i:= i div 10;
706
 
    // 100 ms
707
 
    DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, i mod 10);
708
 
    dec(t, 16);
709
 
    // Point
710
 
    DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, 11);
711
 
    dec(t, 32);
712
 
    i:= i div 10;
713
 
    // 1 s
714
 
    DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, i mod 10);
715
 
    dec(t, 32);
716
 
    i:= i div 10;
717
 
    // 10s
718
 
    DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, i mod 6);
719
 
    dec(t, 16);
720
 
    // Point
721
 
    DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, 10);
722
 
    dec(t, 32);
723
 
    i:= i div 6;
724
 
    // 1 m
725
 
    DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, i mod 10);
726
 
    dec(t, 32);
727
 
    i:= i div 10;
728
 
    // 10 m
729
 
    DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, i mod 10);
730
 
    // left frame
731
 
    DrawSprite(sprFrame, -cScreenWidth div 2 + t - 4, 8, 0);
732
 
    end;
733
 
{$ENDIF}
734
 
 
735
913
// Captions
736
914
DrawCaptions;
737
915
 
738
916
// Teams Healths
 
917
if TeamsCount * 20 > cScreenHeight div 7 then  // take up less screen on small displays
 
918
    begin
 
919
    SetScale(1.5);
 
920
    smallScreenOffset:= cScreenHeight div 6;
 
921
    if TeamsCount * 20 > cScreenHeight div 5 then Tint($FF,$FF,$FF,$80);
 
922
    end
 
923
else smallScreenOffset:= 0;
739
924
for t:= 0 to Pred(TeamsCount) do
740
925
   with TeamsArray[t]^ do
741
926
      begin
742
927
      highlight:= bShowFinger and (CurrentTeam = TeamsArray[t]) and ((RealTicks mod 1000) < 500);
743
928
 
744
929
      if highlight then
745
 
         Tint(Clan^.Color);
 
930
         Tint(Clan^.Color shl 8 or $FF);
746
931
 
747
932
      // draw name
748
 
      DrawTexture(-NameTagTex^.w - 16, cScreenHeight + DrawHealthY, NameTagTex);
 
933
      DrawTexture(-NameTagTex^.w - 16, cScreenHeight + DrawHealthY + smallScreenOffset, NameTagTex);
749
934
 
750
935
      // draw flag
751
 
      DrawTexture(-14, cScreenHeight + DrawHealthY, FlagTex);
 
936
      DrawTexture(-14, cScreenHeight + DrawHealthY + smallScreenOffset, FlagTex);
752
937
 
753
938
      // draw health bar
754
939
      r.x:= 0;
755
940
      r.y:= 0;
756
941
      r.w:= 2 + TeamHealthBarWidth;
757
942
      r.h:= HealthTex^.h;
758
 
      DrawFromRect(14, cScreenHeight + DrawHealthY, @r, HealthTex);
 
943
      DrawFromRect(14, cScreenHeight + DrawHealthY + smallScreenOffset, @r, HealthTex);
759
944
 
760
 
      // draw health bar's right border
 
945
      // draw health bars right border
761
946
      inc(r.x, cTeamHealthWidth + 2);
762
947
      r.w:= 3;
763
 
      DrawFromRect(TeamHealthBarWidth + 16, cScreenHeight + DrawHealthY, @r, HealthTex);
 
948
      DrawFromRect(TeamHealthBarWidth + 16, cScreenHeight + DrawHealthY + smallScreenOffset, @r, HealthTex);
764
949
 
765
950
      // draw ai kill counter for gfAISurvival
766
951
      if (GameFlags and gfAISurvival) <> 0 then begin
767
 
          DrawTexture(TeamHealthBarWidth + 22, cScreenHeight + DrawHealthY,
 
952
          DrawTexture(TeamHealthBarWidth + 22, cScreenHeight + DrawHealthY + smallScreenOffset,
768
953
              AIKillsTex);
769
954
      end;
770
955
 
772
957
      // this approach should be faster than drawing all borders one by one tinted or not
773
958
      if highlight then
774
959
         begin
775
 
         Tint($FF, $FF, $FF, $FF);
 
960
         if TeamsCount * 20 > cScreenHeight div 5 then Tint($FF,$FF,$FF,$80)
 
961
         else Tint($FF, $FF, $FF, $FF);
776
962
 
777
963
         // draw name
778
964
         r.x:= 2;
779
965
         r.y:= 2;
780
966
         r.w:= NameTagTex^.w - 4;
781
967
         r.h:= NameTagTex^.h - 4;
782
 
         DrawFromRect(-NameTagTex^.w - 14, cScreenHeight + DrawHealthY + 2, @r, NameTagTex);
 
968
         DrawFromRect(-NameTagTex^.w - 14, cScreenHeight + DrawHealthY + smallScreenOffset + 2, @r, NameTagTex);
783
969
         // draw flag
784
970
         r.w:= 22;
785
971
         r.h:= 15;
786
 
         DrawFromRect(-12, cScreenHeight + DrawHealthY + 2, @r, FlagTex);
 
972
         DrawFromRect(-12, cScreenHeight + DrawHealthY + smallScreenOffset + 2, @r, FlagTex);
787
973
         // draw health bar
788
974
         r.w:= TeamHealthBarWidth + 1;
789
975
         r.h:= HealthTex^.h - 4;
790
 
         DrawFromRect(16, cScreenHeight + DrawHealthY + 2, @r, HealthTex);
 
976
         DrawFromRect(16, cScreenHeight + DrawHealthY + smallScreenOffset + 2, @r, HealthTex);
791
977
         end;
792
978
      end;
 
979
if smallScreenOffset <> 0 then
 
980
    begin
 
981
    SetScale(cDefaultZoomLevel);
 
982
    if TeamsCount * 20 > cScreenHeight div 5 then Tint($FF,$FF,$FF,$FF);
 
983
    end;
793
984
 
794
985
// Lag alert
795
986
if isInLag then DrawSprite(sprLag, 32 - (cScreenWidth shr 1), 32, (RealTicks shr 7) mod 12);
832
1023
if isCursorVisible and bShowAmmoMenu then
833
1024
   DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8);
834
1025
 
 
1026
// Chat
835
1027
DrawChat;
836
1028
 
 
1029
// various captions
837
1030
if fastUntilLag then DrawCentered(0, (cScreenHeight shr 1), SyncTexture);
838
1031
if isPaused then DrawCentered(0, (cScreenHeight shr 1), PauseTexture);
839
1032
if not isFirstFrame and (missionTimer <> 0) or isPaused or fastUntilLag or (GameState = gsConfirm) then
851
1044
offsetX:= 10;
852
1045
{$ENDIF}
853
1046
offsetY:= cOffsetY;
854
 
inc(Frames);
855
 
 
856
 
if cShowFPS or (GameType = gmtDemo) then inc(CountTicks, Lag);
857
 
if (GameType = gmtDemo) and (CountTicks >= 1000) then
858
 
   begin
859
 
   i:=GameTicks div 1000;
860
 
   t:= i mod 60;
861
 
   s:= inttostr(t);
862
 
   if t < 10 then s:= '0' + s;
863
 
   i:= i div 60;
864
 
   t:= i mod 60;
865
 
   s:= inttostr(t) + ':' + s;
866
 
   if t < 10 then s:= '0' + s;
867
 
   s:= inttostr(i div 60) + ':' + s;
868
 
 
869
 
   if timeTexture <> nil then
870
 
        FreeTexture(timeTexture);
871
 
    timeTexture:= nil;
872
 
 
873
 
   tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), cWhiteColorChannels);
874
 
   tmpSurface:= doSurfaceConversion(tmpSurface);
875
 
   timeTexture:= Surface2Tex(tmpSurface, false);
876
 
   SDL_FreeSurface(tmpSurface)
877
 
   end;
878
 
 
879
 
if timeTexture <> nil then
880
 
   DrawTexture((cScreenWidth shr 1) - 20 - timeTexture^.w - offsetY, offsetX + timeTexture^.h+5, timeTexture);
881
 
 
882
 
if cShowFPS then
883
 
   begin
884
 
   if CountTicks >= 1000 then
885
 
      begin
886
 
      FPS:= Frames;
887
 
      Frames:= 0;
888
 
      CountTicks:= 0;
889
 
      s:= inttostr(FPS) + ' fps';
890
 
      if fpsTexture <> nil then
891
 
        FreeTexture(fpsTexture);
892
 
    fpsTexture:= nil;
893
 
      tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), cWhiteColorChannels);
894
 
      tmpSurface:= doSurfaceConversion(tmpSurface);
895
 
      fpsTexture:= Surface2Tex(tmpSurface, false);
896
 
      SDL_FreeSurface(tmpSurface)
897
 
      end;
898
 
   if fpsTexture <> nil then
899
 
      DrawTexture((cScreenWidth shr 1) - 60 - offsetY, offsetX, fpsTexture);
900
 
   end;
901
 
 
902
 
if CountTicks >= 1000 then CountTicks:= 0;
903
 
 
904
 
// lag warning (?)
905
 
inc(SoundTimerTicks, Lag);
 
1047
if (RM = rmDefault) or (RM = rmRightEye) then
 
1048
begin
 
1049
    inc(Frames);
 
1050
 
 
1051
    if cShowFPS or (GameType = gmtDemo) then
 
1052
        inc(CountTicks, Lag);
 
1053
    if (GameType = gmtDemo) and (CountTicks >= 1000) then
 
1054
    begin
 
1055
        i:=GameTicks div 1000;
 
1056
        t:= i mod 60;
 
1057
        s:= inttostr(t);
 
1058
        if t < 10 then s:= '0' + s;
 
1059
        i:= i div 60;
 
1060
        t:= i mod 60;
 
1061
        s:= inttostr(t) + ':' + s;
 
1062
        if t < 10 then s:= '0' + s;
 
1063
        s:= inttostr(i div 60) + ':' + s;
 
1064
   
 
1065
        if timeTexture <> nil then
 
1066
            FreeTexture(timeTexture);
 
1067
        timeTexture:= nil;
 
1068
    
 
1069
        tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), cWhiteColorChannels);
 
1070
        tmpSurface:= doSurfaceConversion(tmpSurface);
 
1071
        timeTexture:= Surface2Tex(tmpSurface, false);
 
1072
        SDL_FreeSurface(tmpSurface)
 
1073
    end;
 
1074
 
 
1075
    if timeTexture <> nil then
 
1076
        DrawTexture((cScreenWidth shr 1) - 20 - timeTexture^.w - offsetY, offsetX + timeTexture^.h+5, timeTexture);
 
1077
 
 
1078
    if cShowFPS then
 
1079
    begin
 
1080
        if CountTicks >= 1000 then
 
1081
        begin
 
1082
            FPS:= Frames;
 
1083
            Frames:= 0;
 
1084
            CountTicks:= 0;
 
1085
            s:= inttostr(FPS) + ' fps';
 
1086
            if fpsTexture <> nil then
 
1087
                FreeTexture(fpsTexture);
 
1088
            fpsTexture:= nil;
 
1089
            tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), cWhiteColorChannels);
 
1090
            tmpSurface:= doSurfaceConversion(tmpSurface);
 
1091
            fpsTexture:= Surface2Tex(tmpSurface, false);
 
1092
            SDL_FreeSurface(tmpSurface)
 
1093
        end;
 
1094
        if fpsTexture <> nil then
 
1095
            DrawTexture((cScreenWidth shr 1) - 60 - offsetY, offsetX, fpsTexture);
 
1096
    end;
 
1097
 
 
1098
    if CountTicks >= 1000 then CountTicks:= 0;
 
1099
 
 
1100
    // lag warning (?)
 
1101
    inc(SoundTimerTicks, Lag);
 
1102
end;
 
1103
 
906
1104
if SoundTimerTicks >= 50 then
907
1105
   begin
908
1106
   SoundTimerTicks:= 0;
966
1164
     with CurrentHedgehog^ do
967
1165
       if (Gear <> nil) and ((Gear^.State and gstHHChooseTarget) <> 0) then
968
1166
         begin
 
1167
         if (CurAmmoType = amNapalm) or (CurAmmoType = amMineStrike) then
 
1168
           DrawLine(-3000, topY-300, 7000, topY-300, 3.0, (Team^.Clan^.Color shr 16), (Team^.Clan^.Color shr 8) and $FF, Team^.Clan^.Color and $FF, $FF);
969
1169
         i:= GetAmmoEntry(CurrentHedgehog^)^.Pos;
970
1170
         with Ammoz[CurAmmoType] do
971
1171
           if PosCount > 1 then
978
1178
end;
979
1179
 
980
1180
procedure MoveCamera;
981
 
var EdgesDist,  wdy: LongInt;
 
1181
var EdgesDist, wdy, shs,z: LongInt;
982
1182
    PrevSentPointTime: LongWord = 0;
983
1183
begin
984
1184
{$IFNDEF IPHONEOS}
985
 
if (not (CurrentTeam^.ExtDriven and isCursorVisible and not bShowAmmoMenu)) and cHasFocus then
986
 
begin
987
 
    SDL_GetMouseState(@CursorPoint.X, @CursorPoint.Y);
988
 
    CursorPoint.X:= CursorPoint.X - (cScreenWidth shr 1);
989
 
    CursorPoint.Y:= cScreenHeight - CursorPoint.Y;
990
 
end;
 
1185
if (not (CurrentTeam^.ExtDriven and isCursorVisible and not bShowAmmoMenu)) and cHasFocus and (GameState <> gsConfirm) then
 
1186
    uCursor.updatePosition();
991
1187
{$ENDIF}
992
 
 
 
1188
z:= round(200/zoom);
993
1189
if (not PlacingHogs) and (FollowGear <> nil) and (not isCursorVisible) and (not fastUntilLag) then
994
 
    if abs(CursorPoint.X - prevPoint.X) + abs(CursorPoint.Y - prevpoint.Y) > 4 then
 
1190
    if (not autoCameraOn) or ((abs(CursorPoint.X - prevPoint.X) + abs(CursorPoint.Y - prevpoint.Y)) > 4) then
995
1191
    begin
996
1192
        FollowGear:= nil;
997
1193
        prevPoint:= CursorPoint;
999
1195
    end
1000
1196
    else
1001
1197
    begin
1002
 
        CursorPoint.X:= (prevPoint.X * 7 + hwRound(FollowGear^.X) + hwSign(FollowGear^.dX) * 100 + WorldDx) div 8;
1003
 
        CursorPoint.Y:= (prevPoint.Y * 7 + cScreenHeight - (hwRound(FollowGear^.Y) + WorldDy)) div 8;
 
1198
        CursorPoint.X:= (prevPoint.X * 7 + hwRound(FollowGear^.X) + hwSign(FollowGear^.dX) * z + WorldDx) div 8;
 
1199
        CursorPoint.Y:= (prevPoint.Y * 7 + cScreenHeight - (hwRound(FollowGear^.Y)+ hwSign(FollowGear^.dY) * z + WorldDy)) div 8;
1004
1200
    end;
1005
1201
 
1006
1202
wdy:= trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 - cWaterLine - cVisibleWater;
1022
1218
    if CursorPoint.Y < AMyOffset + AMSlotSize then CursorPoint.Y:= AMyOffset + AMSlotSize;
1023
1219
{$ENDIF}
1024
1220
    prevPoint:= CursorPoint;
1025
 
    if cHasFocus then SDL_WarpMouse(CursorPoint.X + cScreenWidth div 2, cScreenHeight - CursorPoint.Y);
 
1221
    //if cHasFocus then SDL_WarpMouse(CursorPoint.X + cScreenWidth div 2, cScreenHeight - CursorPoint.Y);
1026
1222
    exit
1027
1223
end;
1028
1224
 
1052
1248
            WorldDx:= WorldDx - CursorPoint.X + cScreenWidth div 2 - EdgesDist;
1053
1249
            CursorPoint.X:= cScreenWidth div 2 - EdgesDist
1054
1250
        end;
1055
 
    if CursorPoint.Y < EdgesDist then
 
1251
 
 
1252
    shs:= min(cScreenHeight div 2 - trunc(cScreenHeight / cScaleFactor) + EdgesDist, cScreenHeight - EdgesDist);
 
1253
    if CursorPoint.Y < shs then
1056
1254
    begin
1057
 
        WorldDy:= WorldDy + CursorPoint.Y - EdgesDist;
1058
 
        CursorPoint.Y:= EdgesDist
 
1255
        WorldDy:= WorldDy + CursorPoint.Y - shs;
 
1256
        CursorPoint.Y:= shs;
1059
1257
    end
1060
1258
    else
1061
 
        if CursorPoint.Y > cScreenHeight - EdgesDist then
 
1259
        if (CursorPoint.Y > cScreenHeight - EdgesDist) then
1062
1260
        begin
1063
1261
           WorldDy:= WorldDy + CursorPoint.Y - cScreenHeight + EdgesDist;
1064
1262
           CursorPoint.Y:= cScreenHeight - EdgesDist
1075
1273
 
1076
1274
// this moves the camera according to CursorPoint X and Y
1077
1275
prevPoint:= CursorPoint;
1078
 
if cHasFocus then SDL_WarpMouse(CursorPoint.X + (cScreenWidth shr 1), cScreenHeight - CursorPoint.Y);
 
1276
//if cHasFocus then SDL_WarpMouse(CursorPoint.X + (cScreenWidth shr 1), cScreenHeight - CursorPoint.Y);
1079
1277
if WorldDy > LAND_HEIGHT + 1024 then WorldDy:= LAND_HEIGHT + 1024;
1080
1278
if WorldDy < wdy then WorldDy:= wdy;
1081
1279
if WorldDx < - LAND_WIDTH - 1024 then WorldDx:= - LAND_WIDTH - 1024;
1116
1314
 
1117
1315
procedure ShakeCamera(amount: LongWord);
1118
1316
begin
1119
 
    amount:= Max(1, amount);
1120
 
    WorldDx:= WorldDx - amount + LongInt(getRandom(1 + amount * 2));
1121
 
    WorldDy:= WorldDy - amount + LongInt(getRandom(1 + amount * 2));
1122
 
end;
 
1317
    if isCursorVisible then exit;
 
1318
    amount:= Max(1, round(amount*zoom/2));
 
1319
    WorldDx:= WorldDx - amount + LongInt(random(1 + amount * 2));
 
1320
    WorldDy:= WorldDy - amount + LongInt(random(1 + amount * 2));
 
1321
    //CursorPoint.X:= CursorPoint.X - amount + LongInt(random(1 + amount * 2));
 
1322
    //CursorPoint.Y:= CursorPoint.Y - amount + LongInt(random(1 + amount * 2))
 
1323
end;
 
1324
 
 
1325
 
 
1326
procedure onFocusStateChanged;
 
1327
begin
 
1328
if (not cHasFocus) and (GameState <> gsConfirm) then
 
1329
    ParseCommand('quit', true);
 
1330
end;
 
1331
 
1123
1332
 
1124
1333
procedure initModule;
1125
1334
begin
1141
1350
    missionTimer:= 0;
1142
1351
    missionTex:= nil;
1143
1352
    cOffsetY:= 0;
 
1353
    stereoDepth:= 0;
1144
1354
end;
1145
1355
 
1146
1356
procedure freeModule;
1147
1357
begin
 
1358
    stereoDepth:= stereoDepth; // avoid hint
 
1359
    FreeTexture(fpsTexture);
 
1360
    FreeTexture(timeTexture);
 
1361
    FreeTexture(missionTex);
1148
1362
end;
1149
1363
 
1150
1364
end.