author | sheepluva |
Thu, 17 Jun 2010 13:56:30 +0200 | |
changeset 3511 | 76e2d79b91b1 |
parent 3483 | 54ff8cbabaa6 |
child 3513 | f589230fa21b |
permissions | -rw-r--r-- |
4 | 1 |
(* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
3236
4ab3917d7d44
Update (c) lines to 2010 as unc0rr requested - they all had varying values so I just took the first year mentioned, then tacked on -2010
nemo
parents:
3204
diff
changeset
|
3 |
* Copyright (c) 2004-2010 Andrey Korotaev <unC0Rr@gmail.com> |
4 | 4 |
* |
183 | 5 |
* This program is free software; you can redistribute it and/or modify |
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
4 | 8 |
* |
183 | 9 |
* This program is distributed in the hope that it will be useful, |
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
4 | 13 |
* |
183 | 14 |
* You should have received a copy of the GNU General Public License |
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
4 | 17 |
*) |
18 |
||
2630 | 19 |
{$INCLUDE "options.inc"} |
20 |
||
4 | 21 |
unit uWorld; |
22 |
interface |
|
2704
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset
|
23 |
uses SDLh, uGears, uConsts, uFloat, uRandom; |
2630 | 24 |
|
4 | 25 |
|
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2682
diff
changeset
|
26 |
var FollowGear: PGear; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2682
diff
changeset
|
27 |
WindBarWidth: LongInt; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2682
diff
changeset
|
28 |
bShowAmmoMenu: boolean; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2682
diff
changeset
|
29 |
bSelected: boolean; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2682
diff
changeset
|
30 |
bShowFinger: boolean; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2682
diff
changeset
|
31 |
Frames: Longword; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2682
diff
changeset
|
32 |
WaterColor, DeepWaterColor: TSDL_Color; |
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2713
diff
changeset
|
33 |
WorldDx: LongInt; |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2713
diff
changeset
|
34 |
WorldDy: LongInt; |
3248 | 35 |
SkyOffset: LongInt; |
36 |
HorizontOffset: LongInt; |
|
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2713
diff
changeset
|
37 |
{$IFDEF COUNTTICKS} |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2713
diff
changeset
|
38 |
cntTicks: LongWord; |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2713
diff
changeset
|
39 |
{$ENDIF} |
3463 | 40 |
cOffsetY: LongInt; |
3405 | 41 |
|
3038 | 42 |
procedure initModule; |
43 |
procedure freeModule; |
|
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2713
diff
changeset
|
44 |
|
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2713
diff
changeset
|
45 |
procedure InitWorld; |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2713
diff
changeset
|
46 |
procedure DrawWorld(Lag: LongInt); |
2905 | 47 |
procedure AddCaption(s: shortstring; Color: Longword; Group: TCapGroup); |
48 |
procedure ShowMission(caption, subcaption, text: ansistring; icon, time : LongInt); |
|
2786 | 49 |
procedure HideMission; |
3032 | 50 |
procedure ShakeCamera(amount: LongWord); |
4 | 51 |
|
52 |
implementation |
|
3407 | 53 |
uses uStore, uMisc, uTeams, uIO, uKeys, uLocale, uSound, uAmmos, uVisualGears, uChat, uLandTexture, uLand, GLunit; |
1807 | 54 |
|
4 | 55 |
type TCaptionStr = record |
762 | 56 |
Tex: PTexture; |
4 | 57 |
EndTime: LongWord; |
58 |
end; |
|
59 |
||
2161
0c8634241fa4
Some work on zooming. Hedgewars are now unplayable.
unc0rr
parents:
2152
diff
changeset
|
60 |
var cWaveWidth, cWaveHeight: LongInt; |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2682
diff
changeset
|
61 |
Captions: array[TCapGroup] of TCaptionStr; |
3434 | 62 |
AMSlotSize, AMxOffset, AMyOffset, AMWidth, AMxShift, SlotsNum: LongInt; |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2682
diff
changeset
|
63 |
tmpSurface: PSDL_Surface; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2682
diff
changeset
|
64 |
fpsTexture: PTexture; |
2850
f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset
|
65 |
timeTexture: PTexture; |
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2713
diff
changeset
|
66 |
FPS: Longword; |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2713
diff
changeset
|
67 |
CountTicks: Longword; |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2713
diff
changeset
|
68 |
SoundTimerTicks: Longword; |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2713
diff
changeset
|
69 |
prevPoint: TPoint; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
70 |
amSel: TAmmoType = amNothing; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
71 |
missionTex: PTexture; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
72 |
missionTimer: LongInt; |
4 | 73 |
|
74 |
procedure InitWorld; |
|
2704
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset
|
75 |
var i, t: LongInt; |
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset
|
76 |
cp: PClan; |
2863 | 77 |
g: ansistring; |
78 |
||
2904 | 79 |
// helper functions to create the goal/game mode string |
2908 | 80 |
function AddGoal(s: ansistring; gf: longword; si: TGoalStrId; i: LongInt): ansistring; |
2905 | 81 |
var t: ansistring; |
2904 | 82 |
begin |
83 |
if (GameFlags and gf) <> 0 then |
|
84 |
begin |
|
85 |
t:= inttostr(i); |
|
86 |
s:= s + format(trgoal[si], t) + '|' |
|
87 |
end; |
|
88 |
AddGoal:= s; |
|
89 |
end; |
|
90 |
||
2908 | 91 |
function AddGoal(s: ansistring; gf: longword; si: TGoalStrId): ansistring; |
2863 | 92 |
begin |
2904 | 93 |
if (GameFlags and gf) <> 0 then |
94 |
s:= s + trgoal[si] + '|'; |
|
2863 | 95 |
AddGoal:= s; |
96 |
end; |
|
4 | 97 |
begin |
3405 | 98 |
missionTimer:= 0; |
2786 | 99 |
|
2704
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset
|
100 |
if (GameFlags and gfRandomOrder) <> 0 then // shuffle them up a bit |
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset
|
101 |
begin |
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset
|
102 |
for i:= 0 to ClansCount * 4 do |
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset
|
103 |
begin |
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset
|
104 |
t:= GetRandom(ClansCount); |
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset
|
105 |
if t <> 0 then |
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset
|
106 |
begin |
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset
|
107 |
cp:= ClansArray[0]; |
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset
|
108 |
ClansArray[0]:= ClansArray[t]; |
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset
|
109 |
ClansArray[t]:= cp; |
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset
|
110 |
ClansArray[t]^.ClanIndex:= t; |
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset
|
111 |
ClansArray[0]^.ClanIndex:= 0; |
2856
cc70797a0b75
Adjust LocalClan when shuffling, set to -1 in case all local clans are bots.
nemo
parents:
2855
diff
changeset
|
112 |
if (LocalClan = t) then LocalClan:= 0 |
cc70797a0b75
Adjust LocalClan when shuffling, set to -1 in case all local clans are bots.
nemo
parents:
2855
diff
changeset
|
113 |
else if (LocalClan = 0) then LocalClan:= t |
2704
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset
|
114 |
end; |
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset
|
115 |
end; |
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset
|
116 |
CurrentTeam:= ClansArray[0]^.Teams[0]; |
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset
|
117 |
end; |
51cda17b7c3b
Rolling random numbers before land is generated is bad, m'kay? InitWorld probably not the best place for it.
nemo
parents:
2699
diff
changeset
|
118 |
|
2908 | 119 |
// if special game flags/settings are changed, add them to the game mode notice window and then show it |
2863 | 120 |
g:= ''; // no text/things to note yet |
2908 | 121 |
|
2958 | 122 |
// check different game flags (goals/game modes first for now) |
123 |
g:= AddGoal(g, gfKing, gidKing); // king? |
|
124 |
||
125 |
// other important flags |
|
126 |
g:= AddGoal(g, gfForts, gidForts); // forts? |
|
127 |
g:= AddGoal(g, gfLowGravity, gidLowGravity); // low gravity? |
|
128 |
g:= AddGoal(g, gfInvulnerable, gidInvulnerable); // invulnerability? |
|
129 |
g:= AddGoal(g, gfVampiric, gidVampiric); // vampirism? |
|
130 |
g:= AddGoal(g, gfKarma, gidKarma); // karma? |
|
131 |
g:= AddGoal(g, gfPlaceHog, gidPlaceHog); // placement? |
|
132 |
g:= AddGoal(g, gfArtillery, gidArtillery); // artillery? |
|
133 |
g:= AddGoal(g, gfSolidLand, gidSolidLand); // solid land? |
|
134 |
g:= AddGoal(g, gfSharedAmmo, gidSharedAmmo); // shared ammo? |
|
135 |
||
2908 | 136 |
// modified damage modificator? |
137 |
if cDamagePercent <> 100 then |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
138 |
g:= AddGoal(g, gfAny, gidDamageModifier, cDamagePercent); |
2908 | 139 |
|
3107 | 140 |
// fade in |
141 |
ScreenFade:= sfFromBlack; |
|
142 |
ScreenFadeValue:= sfMax; |
|
143 |
ScreenFadeSpeed:= 1; |
|
144 |
||
2908 | 145 |
// modified mine timers? |
146 |
if cMinesTime <> 3000 then |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
147 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
148 |
if cMinesTime = 0 then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
149 |
g:= AddGoal(g, gfMines, gidNoMineTimer) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
150 |
else if cMinesTime < 0 then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
151 |
g:= AddGoal(g, gfMines, gidRandomMineTimer) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
152 |
else |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
153 |
g:= AddGoal(g, gfMines, gidMineTimer, cMinesTime div 1000); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
154 |
end; |
2908 | 155 |
|
2863 | 156 |
// if the string has been set, show it for (default timeframe) seconds |
157 |
if g <> '' then ShowMission(trgoal[gidCaption], trgoal[gidSubCaption], g, 1, 0); |
|
158 |
||
1825 | 159 |
cWaveWidth:= SpritesData[sprWater].Width; |
2268
053eb81e60ee
little experiment to see if this improve appearance of laser/ufo/cake/laser guided missile - of course, can't actually see it until unc0rr restores waves
nemo
parents:
2226
diff
changeset
|
160 |
//cWaveHeight:= SpritesData[sprWater].Height; |
053eb81e60ee
little experiment to see if this improve appearance of laser/ufo/cake/laser guided missile - of course, can't actually see it until unc0rr restores waves
nemo
parents:
2226
diff
changeset
|
161 |
cWaveHeight:= 32; |
2292
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset
|
162 |
|
284 | 163 |
cGearScrEdgesDist:= Min(cScreenWidth div 2 - 100, cScreenHeight div 2 - 50); |
74 | 164 |
SDL_WarpMouse(cScreenWidth div 2, cScreenHeight div 2); |
2197 | 165 |
prevPoint.X:= 0; |
74 | 166 |
prevPoint.Y:= cScreenHeight div 2; |
1760 | 167 |
WorldDx:= - (LAND_WIDTH div 2) + cScreenWidth div 2; |
2139
5a083e71a71d
Properly decrement sniper rifle if timed out. Try to get camera position straight for once.
nemo
parents:
2119
diff
changeset
|
168 |
WorldDy:= - (LAND_HEIGHT - (playHeight div 2)) + (cScreenHeight div 2); |
3434 | 169 |
AMSlotSize:= 33; |
170 |
{$IFDEF IPHONEOS} |
|
171 |
AMxOffset:= 10; |
|
3464 | 172 |
AMyOffset:= 10 + 123; // moved downwards |
3434 | 173 |
AMWidth:= (cMaxSlotAmmoIndex + 1) * AMSlotSize + AMxOffset; |
174 |
{$ELSE} |
|
175 |
AMxOffset:= 10; |
|
176 |
AMyOffset:= 60; |
|
177 |
AMWidth:= (cMaxSlotAmmoIndex + 2) * AMSlotSize + AMxOffset; |
|
178 |
{$ENDIF} |
|
179 |
AMxShift:= AMWidth; |
|
3265
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
180 |
SkyOffset:= 0; |
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
181 |
HorizontOffset:= 0; |
161 | 182 |
end; |
183 |
||
3405 | 184 |
|
956 | 185 |
procedure ShowAmmoMenu; |
161 | 186 |
const MENUSPEED = 15; |
3434 | 187 |
const BORDERSIZE = 2; |
188 |
var x, y, i, t, g: LongInt; |
|
189 |
Slot, Pos, STurns: LongInt; |
|
2855
7e6adeb57427
Show the ammo menu of the last local non-bot team when not local turn. needs testing
nemo
parents:
2851
diff
changeset
|
190 |
Ammo: PHHAmmo; |
161 | 191 |
begin |
3434 | 192 |
if (TurnTimeLeft = 0) or (not CurrentTeam^.ExtDriven and (((CurAmmoGear = nil) or ((CurAmmoGear^.Ammo^.Propz and ammoprop_AltAttack) = 0)) and hideAmmoMenu)) then bShowAmmoMenu:= false; |
193 |
if bShowAmmoMenu then |
|
194 |
begin |
|
195 |
FollowGear:= nil; |
|
196 |
if AMxShift = AMWidth then prevPoint.X:= 0; |
|
197 |
if cReducedQuality then |
|
198 |
AMxShift:= 0 |
|
199 |
else |
|
200 |
if AMxShift > MENUSPEED then |
|
201 |
dec(AMxShift, MENUSPEED) |
|
202 |
else |
|
203 |
AMxShift:= 0; |
|
204 |
end else |
|
205 |
begin |
|
206 |
if AMxShift = 0 then |
|
207 |
begin |
|
208 |
CursorPoint.X:= cScreenWidth shr 1; |
|
209 |
CursorPoint.Y:= cScreenHeight shr 1; |
|
210 |
prevPoint:= CursorPoint; |
|
211 |
SDL_WarpMouse(CursorPoint.X + cScreenWidth div 2, cScreenHeight - CursorPoint.Y) |
|
212 |
end; |
|
213 |
if cReducedQuality then |
|
214 |
AMxShift:= AMWidth |
|
215 |
else |
|
216 |
if AMxShift < (AMWidth - MENUSPEED) then |
|
217 |
inc(AMxShift, MENUSPEED) |
|
218 |
else |
|
219 |
AMxShift:= AMWidth; |
|
220 |
end; |
|
221 |
Ammo:= nil; |
|
222 |
if (CurrentTeam <> nil) and (CurrentHedgehog <> nil) and (not CurrentTeam^.ExtDriven) and (CurrentHedgehog^.BotLevel = 0) then |
|
223 |
Ammo:= CurrentHedgehog^.Ammo |
|
224 |
else if (LocalAmmo <> -1) then |
|
225 |
Ammo:= GetAmmoByNum(LocalAmmo); |
|
226 |
Pos:= -1; |
|
227 |
if Ammo = nil then |
|
2971 | 228 |
begin |
3434 | 229 |
bShowAmmoMenu:= false; |
230 |
exit |
|
2971 | 231 |
end; |
3434 | 232 |
SlotsNum:= 0; |
233 |
x:= (cScreenWidth shr 1) - AMWidth + AMxShift; |
|
3395
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3390
diff
changeset
|
234 |
|
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3390
diff
changeset
|
235 |
{$IFDEF IPHONEOS} |
3434 | 236 |
Slot:= cMaxSlotIndex; |
3463 | 237 |
x:= x - cOffsetY; |
3464 | 238 |
y:= AMyOffset; |
3434 | 239 |
dec(y, BORDERSIZE); |
240 |
DrawSprite(sprAMCorners, x - BORDERSIZE, y, 0); |
|
241 |
for i:= 0 to cMaxSlotAmmoIndex do |
|
242 |
DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 0); |
|
243 |
DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 1); |
|
244 |
inc(y, BORDERSIZE); |
|
245 |
||
246 |
for i:= 0 to cMaxSlotIndex do |
|
247 |
if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then |
|
248 |
begin |
|
249 |
if (cScreenHeight - CursorPoint.Y >= y) and (cScreenHeight - CursorPoint.Y < y + AMSlotSize) then Slot:= i; |
|
250 |
inc(SlotsNum); |
|
251 |
DrawSprite(sprAMBorderVertical, x - BORDERSIZE, y, 0); |
|
252 |
t:= 0; |
|
253 |
g:= 0; |
|
254 |
while (t <= cMaxSlotAmmoIndex) and (Ammo^[i, t].Count > 0) do |
|
255 |
begin |
|
256 |
DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 1); |
|
257 |
if (Ammo^[i, t].AmmoType <> amNothing) then |
|
258 |
begin |
|
259 |
STurns:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber; |
|
260 |
||
261 |
if STurns >= 0 then |
|
262 |
begin |
|
263 |
DrawSprite(sprAMAmmosBW, x + g * AMSlotSize, y + 1, LongInt(Ammo^[i, t].AmmoType)-1); |
|
264 |
if STurns < 100 then DrawSprite(sprTurnsLeft, x + (g + 1) * AMSlotSize - 16, y + AMSlotSize - 16, STurns); |
|
265 |
end else |
|
266 |
DrawSprite(sprAMAmmos, x + g * AMSlotSize, y + 1, LongInt(Ammo^[i, t].AmmoType)-1); |
|
267 |
if (Slot = i) |
|
268 |
and (CursorPoint.X >= x + g * AMSlotSize) |
|
269 |
and (CursorPoint.X < x + (g + 1) * AMSlotSize) then |
|
270 |
begin |
|
271 |
if (STurns < 0) then DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 0); |
|
272 |
Pos:= t; |
|
273 |
end; |
|
274 |
inc(g) |
|
275 |
end; |
|
276 |
inc(t) |
|
277 |
end; |
|
278 |
for g:= g to cMaxSlotAmmoIndex do |
|
279 |
DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 1); |
|
280 |
DrawSprite(sprAMBorderVertical, x + AMWidth - AMxOffset, y, 1); |
|
281 |
inc(y, AMSlotSize); |
|
282 |
end; |
|
283 |
||
284 |
DrawSprite(sprAMCorners, x - BORDERSIZE, y, 2); |
|
285 |
for i:= 0 to cMaxSlotAmmoIndex do |
|
286 |
DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 1); |
|
287 |
DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 3); |
|
3395
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3390
diff
changeset
|
288 |
{$ELSE} |
3434 | 289 |
Slot:= 0; |
290 |
y:= cScreenHeight - AMyOffset; |
|
291 |
DrawSprite(sprAMCorners, x - BORDERSIZE, y, 2); |
|
292 |
for i:= 0 to cMaxSlotAmmoIndex + 1 do |
|
293 |
DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 1); |
|
294 |
DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 3); |
|
295 |
dec(y, AMSlotSize); |
|
296 |
DrawSprite(sprAMBorderVertical, x - BORDERSIZE, y, 0); |
|
297 |
for i:= 0 to cMaxSlotAmmoIndex do |
|
298 |
DrawSprite(sprAMSlot, x + i * AMSlotSize, y, 2); |
|
299 |
DrawSprite(sprAMSlot, x + (cMaxSlotAmmoIndex + 1) * AMSlotSize, y, 1); |
|
300 |
DrawSprite(sprAMBorderVertical, x + AMWidth - AMxOffset, y, 1); |
|
301 |
||
302 |
for i:= cMaxSlotIndex downto 0 do |
|
303 |
if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then |
|
304 |
begin |
|
305 |
if (cScreenHeight - CursorPoint.Y >= y - AMSlotSize) and (cScreenHeight - CursorPoint.Y < y) then Slot:= i; |
|
306 |
dec(y, AMSlotSize); |
|
307 |
inc(SlotsNum); |
|
308 |
DrawSprite(sprAMBorderVertical, x - BORDERSIZE, y, 0); |
|
309 |
DrawSprite(sprAMSlot, x, y, 1); |
|
310 |
DrawSprite(sprAMSlotKeys, x, y + 1, i); |
|
311 |
t:= 0; |
|
312 |
g:= 1; |
|
313 |
while (t <= cMaxSlotAmmoIndex) and (Ammo^[i, t].Count > 0) do |
|
314 |
begin |
|
315 |
DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 1); |
|
316 |
if (Ammo^[i, t].AmmoType <> amNothing) then |
|
317 |
begin |
|
318 |
STurns:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber; |
|
319 |
||
320 |
if STurns >= 0 then |
|
321 |
begin |
|
322 |
DrawSprite(sprAMAmmosBW, x + g * AMSlotSize, y + 1, LongInt(Ammo^[i, t].AmmoType)-1); |
|
323 |
if STurns < 100 then DrawSprite(sprTurnsLeft, x + (g + 1) * AMSlotSize - 16, y + AMSlotSize - 16, STurns); |
|
324 |
end else |
|
325 |
DrawSprite(sprAMAmmos, x + g * AMSlotSize, y + 1, LongInt(Ammo^[i, t].AmmoType)-1); |
|
326 |
if (Slot = i) |
|
327 |
and (CursorPoint.X >= x + g * AMSlotSize) |
|
328 |
and (CursorPoint.X < x + (g + 1) * AMSlotSize) then |
|
329 |
begin |
|
330 |
if (STurns < 0) then DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 0); |
|
331 |
Pos:= t; |
|
332 |
end; |
|
333 |
inc(g) |
|
334 |
end; |
|
335 |
inc(t) |
|
336 |
end; |
|
337 |
for g:= g to cMaxSlotAmmoIndex + 1 do |
|
338 |
DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 1); |
|
339 |
DrawSprite(sprAMBorderVertical, x + AMWidth - AMxOffset, y, 1); |
|
340 |
end; |
|
341 |
||
342 |
dec(y, BORDERSIZE); |
|
343 |
DrawSprite(sprAMCorners, x - BORDERSIZE, y, 0); |
|
344 |
for i:= 0 to cMaxSlotAmmoIndex + 1 do |
|
345 |
DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 0); |
|
346 |
DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 1); |
|
3395
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3390
diff
changeset
|
347 |
{$ENDIF} |
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3390
diff
changeset
|
348 |
|
3434 | 349 |
if (Pos >= 0) then |
350 |
begin |
|
351 |
if (Ammo^[Slot, Pos].Count > 0) and (Ammo^[Slot, Pos].AmmoType <> amNothing) then |
|
352 |
if (amSel <> Ammo^[Slot, Pos].AmmoType) or (WeaponTooltipTex = nil) then |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
353 |
begin |
3434 | 354 |
amSel:= Ammo^[Slot, Pos].AmmoType; |
355 |
RenderWeaponTooltip(amSel) |
|
356 |
end; |
|
357 |
||
358 |
{$IFNDEF IPHONEOS} |
|
359 |
DrawTexture(cScreenWidth div 2 - (AMWidth - 10) + AMxShift, cScreenHeight - AMyOffset - 25, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex); |
|
3405 | 360 |
|
3434 | 361 |
if Ammo^[Slot, Pos].Count < AMMO_INFINITE then |
362 |
DrawTexture(cScreenWidth div 2 + AMxOffset - 45, cScreenHeight - AMyOffset - 25, CountTexz[Ammo^[Slot, Pos].Count]); |
|
363 |
{$ENDIF} |
|
1529
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
364 |
|
3434 | 365 |
if bSelected and (Ammoz[Ammo^[Slot, Pos].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber < 0) then |
366 |
begin |
|
367 |
bShowAmmoMenu:= false; |
|
368 |
SetWeapon(Ammo^[Slot, Pos].AmmoType); |
|
369 |
bSelected:= false; |
|
370 |
FreeWeaponTooltip; |
|
371 |
exit |
|
3405 | 372 |
end; |
3434 | 373 |
end |
374 |
else |
|
375 |
FreeWeaponTooltip; |
|
3395
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3390
diff
changeset
|
376 |
{$IFDEF IPHONEOS} |
3434 | 377 |
if (WeaponTooltipTex <> nil) and (AMxShift = 0) then |
378 |
ShowWeaponTooltip(x - WeaponTooltipTex^.w - 3, AMyOffset - 1); |
|
3395
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3390
diff
changeset
|
379 |
{$ELSE} |
3434 | 380 |
if (WeaponTooltipTex <> nil) and (AMxShift = 0) then |
381 |
ShowWeaponTooltip(x - WeaponTooltipTex^.w - 3, min(y + 1, cScreenHeight - WeaponTooltipTex^.h - 40)); |
|
3395
095273ad0e08
adding a somewhat working autoration for ipad (uStore.pas and uWorld.pas got mixed in the last two commits)
koda
parents:
3390
diff
changeset
|
382 |
{$ENDIF} |
961
a9a349b2b3fa
Use turnsleft sprites to indicate turns left to activate ammo
unc0rr
parents:
956
diff
changeset
|
383 |
|
3434 | 384 |
bSelected:= false; |
385 |
if AMxShift = 0 then DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8) |
|
4 | 386 |
end; |
387 |
||
162 | 388 |
procedure MoveCamera; forward; |
389 |
||
3104 | 390 |
procedure DrawWater(Alpha: byte; OffsetY: LongInt); |
1915 | 391 |
var VertexBuffer: array [0..3] of TVertex2f; |
392 |
r: TSDL_Rect; |
|
2161
0c8634241fa4
Some work on zooming. Hedgewars are now unplayable.
unc0rr
parents:
2152
diff
changeset
|
393 |
lw, lh: GLfloat; |
1915 | 394 |
begin |
3405 | 395 |
WaterColorArray[0].a := Alpha; |
396 |
WaterColorArray[1].a := Alpha; |
|
397 |
WaterColorArray[2].a := Alpha; |
|
398 |
WaterColorArray[3].a := Alpha; |
|
2269
00f5704f5f39
add extra semi-opaque layer of water to discolour objects in the water.
nemo
parents:
2268
diff
changeset
|
399 |
|
3463 | 400 |
lw:= cScreenWidth / cScaleFactor; |
401 |
lh:= trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 + 16; |
|
3405 | 402 |
|
403 |
// Water |
|
404 |
r.y:= OffsetY + WorldDy + cWaterLine; |
|
3463 | 405 |
if WorldDy < trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 - cWaterLine then |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
406 |
begin |
3405 | 407 |
if r.y < 0 then |
408 |
r.y:= 0; |
|
1915 | 409 |
|
3405 | 410 |
glDisable(GL_TEXTURE_2D); |
411 |
VertexBuffer[0].X:= -lw; |
|
412 |
VertexBuffer[0].Y:= r.y; |
|
413 |
VertexBuffer[1].X:= lw; |
|
414 |
VertexBuffer[1].Y:= r.y; |
|
415 |
VertexBuffer[2].X:= lw; |
|
416 |
VertexBuffer[2].Y:= lh; |
|
417 |
VertexBuffer[3].X:= -lw; |
|
418 |
VertexBuffer[3].Y:= lh; |
|
1915 | 419 |
|
3405 | 420 |
glEnableClientState (GL_COLOR_ARRAY); |
421 |
glColorPointer(4, GL_UNSIGNED_BYTE, 0, @WaterColorArray[0]); |
|
1915 | 422 |
|
3405 | 423 |
glEnableClientState(GL_VERTEX_ARRAY); |
424 |
glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); |
|
2171
8208946331ba
Smaxx refactor of LoadImage to use flags, iphone changes by koda (mostly use of rgba instead of rgb)
nemo
parents:
2162
diff
changeset
|
425 |
|
3405 | 426 |
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); |
1915 | 427 |
|
3405 | 428 |
glDisableClientState(GL_VERTEX_ARRAY); |
429 |
glDisableClientState(GL_COLOR_ARRAY); |
|
1915 | 430 |
|
3407 | 431 |
glColor4ub($FF, $FF, $FF, $FF); // must not be Tint() as color array seems to stay active and color reset is required |
3405 | 432 |
glEnable(GL_TEXTURE_2D); |
433 |
end; |
|
1915 | 434 |
end; |
435 |
||
3376 | 436 |
procedure DrawWaves(Dir, dX, dY: LongInt; tnt: Byte); |
2292
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset
|
437 |
var VertexBuffer, TextureBuffer: array [0..3] of TVertex2f; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
438 |
lw, waves, shift: GLfloat; |
2288 | 439 |
begin |
3463 | 440 |
lw:= cScreenWidth / cScaleFactor; |
2292
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset
|
441 |
waves:= lw * 2 / cWaveWidth; |
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset
|
442 |
|
3407 | 443 |
Tint(LongInt(tnt) * WaterColorArray[2].r div 255 + 255 - tnt, |
444 |
LongInt(tnt) * WaterColorArray[2].g div 255 + 255 - tnt, |
|
445 |
LongInt(tnt) * WaterColorArray[2].b div 255 + 255 - tnt, |
|
446 |
255 |
|
3089 | 447 |
); |
448 |
||
2292
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset
|
449 |
glBindTexture(GL_TEXTURE_2D, SpritesData[sprWater].Texture^.id); |
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset
|
450 |
|
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset
|
451 |
VertexBuffer[0].X:= -lw; |
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset
|
452 |
VertexBuffer[0].Y:= cWaterLine + WorldDy + dY; |
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset
|
453 |
VertexBuffer[1].X:= lw; |
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset
|
454 |
VertexBuffer[1].Y:= VertexBuffer[0].Y; |
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset
|
455 |
VertexBuffer[2].X:= lw; |
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset
|
456 |
VertexBuffer[2].Y:= VertexBuffer[0].Y + SpritesData[sprWater].Height; |
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset
|
457 |
VertexBuffer[3].X:= -lw; |
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset
|
458 |
VertexBuffer[3].Y:= VertexBuffer[2].Y; |
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset
|
459 |
|
2374 | 460 |
shift:= - lw / cWaveWidth; |
2495 | 461 |
TextureBuffer[0].X:= shift + (( - WorldDx + LongInt(RealTicks shr 6) * Dir + dX) mod cWaveWidth) / (cWaveWidth - 1); |
2292
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset
|
462 |
TextureBuffer[0].Y:= 0; |
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset
|
463 |
TextureBuffer[1].X:= TextureBuffer[0].X + waves; |
2447
08d623a494e6
Smaxx's updated german translation + texture gap fixes + updated room list
koda
parents:
2434
diff
changeset
|
464 |
TextureBuffer[1].Y:= TextureBuffer[0].Y; |
08d623a494e6
Smaxx's updated german translation + texture gap fixes + updated room list
koda
parents:
2434
diff
changeset
|
465 |
TextureBuffer[2].X:= TextureBuffer[1].X; |
2553 | 466 |
TextureBuffer[2].Y:= SpritesData[sprWater].Texture^.ry; |
2292
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset
|
467 |
TextureBuffer[3].X:= TextureBuffer[0].X; |
2447
08d623a494e6
Smaxx's updated german translation + texture gap fixes + updated room list
koda
parents:
2434
diff
changeset
|
468 |
TextureBuffer[3].Y:= TextureBuffer[2].Y; |
2292
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset
|
469 |
|
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset
|
470 |
glEnableClientState(GL_VERTEX_ARRAY); |
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset
|
471 |
glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset
|
472 |
|
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset
|
473 |
glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); |
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset
|
474 |
glTexCoordPointer(2, GL_FLOAT, 0, @TextureBuffer[0]); |
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset
|
475 |
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); |
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset
|
476 |
|
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset
|
477 |
glDisableClientState(GL_TEXTURE_COORD_ARRAY); |
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset
|
478 |
glDisableClientState(GL_VERTEX_ARRAY); |
3390 | 479 |
Tint($FF, $FF, $FF, $FF); |
2292
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset
|
480 |
|
87af4ad0ec98
New waves rendering procedure based on using texture coodrinates > 1.0
unc0rr
parents:
2290
diff
changeset
|
481 |
{for i:= -1 to cWaterSprCount do |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
482 |
DrawSprite(sprWater, |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
483 |
i * cWaveWidth + ((WorldDx + (RealTicks shr 6) * Dir + dX) mod cWaveWidth) - (cScreenWidth div 2), |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
484 |
cWaterLine + WorldDy + dY, |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
485 |
0)} |
2288 | 486 |
end; |
487 |
||
3089 | 488 |
procedure DrawRepeated(spr, sprL, sprR: TSprite; Shift, OffsetY: LongInt); |
2426 | 489 |
var i, w, sw: LongInt; |
490 |
begin |
|
3405 | 491 |
sw:= round(cScreenWidth / cScaleFactor); |
492 |
if (SpritesData[sprL].Texture = nil) or (SpritesData[sprR].Texture = nil) then |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
493 |
begin |
3405 | 494 |
w:= SpritesData[spr].Width; |
495 |
i:= Shift mod w; |
|
496 |
if i > 0 then dec(i, w); |
|
497 |
dec(i, w * (sw div w + 1)); |
|
498 |
repeat |
|
499 |
DrawSprite(spr, i, WorldDy + LAND_HEIGHT + OffsetY - SpritesData[spr].Height, 0); |
|
500 |
inc(i, w) |
|
501 |
until i > sw |
|
502 |
end |
|
503 |
else |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
504 |
begin |
3405 | 505 |
w:= SpritesData[spr].Width; |
506 |
dec(Shift, w div 2); |
|
507 |
DrawSprite(spr, Shift, WorldDy + LAND_HEIGHT + OffsetY - SpritesData[spr].Height, 0); |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
508 |
|
3405 | 509 |
i:= Shift - SpritesData[sprL].Width; |
510 |
while i >= -sw - SpritesData[sprL].Width do |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
511 |
begin |
3405 | 512 |
DrawSprite(sprL, i, WorldDy + LAND_HEIGHT + OffsetY - SpritesData[sprL].Height, 0); |
513 |
dec(i, SpritesData[sprL].Width); |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
514 |
end; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
515 |
|
3405 | 516 |
i:= Shift + w; |
517 |
while i <= sw do |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
518 |
begin |
3405 | 519 |
DrawSprite(sprR, i, WorldDy + LAND_HEIGHT + OffsetY - SpritesData[sprR].Height, 0); |
520 |
inc(i, SpritesData[sprR].Width) |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
521 |
end |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
522 |
end |
2426 | 523 |
end; |
524 |
||
525 |
||
956 | 526 |
procedure DrawWorld(Lag: LongInt); |
371 | 527 |
var i, t: LongInt; |
4 | 528 |
r: TSDL_Rect; |
107 | 529 |
tdx, tdy: Double; |
175 | 530 |
grp: TCapGroup; |
174 | 531 |
s: string[15]; |
2803
1f446fc5c8ec
allow to compile engine as library with HWLIBRARY symbol
koda
parents:
2786
diff
changeset
|
532 |
highlight: Boolean; |
3265
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
533 |
offset, offsetX, offsetY, ScreenBottom: LongInt; |
2724 | 534 |
scale: GLfloat; |
3113 | 535 |
VertexBuffer: array [0..3] of TVertex2f; |
4 | 536 |
begin |
3444 | 537 |
if not isPaused then |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
538 |
begin |
3444 | 539 |
if ZoomValue < zoom then |
540 |
begin |
|
541 |
zoom:= zoom - 0.002 * Lag; |
|
542 |
if ZoomValue > zoom then zoom:= ZoomValue |
|
543 |
end else |
|
544 |
if ZoomValue > zoom then |
|
545 |
begin |
|
546 |
zoom:= zoom + 0.002 * Lag; |
|
547 |
if ZoomValue < zoom then zoom:= ZoomValue |
|
548 |
end |
|
549 |
end |
|
550 |
else |
|
551 |
ZoomValue:= zoom; |
|
2376 | 552 |
|
770 | 553 |
// Sky |
756 | 554 |
glClear(GL_COLOR_BUFFER_BIT); |
777 | 555 |
//glPushMatrix; |
556 |
//glScalef(1.0, 1.0, 1.0); |
|
756 | 557 |
|
281
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
244
diff
changeset
|
558 |
if not isPaused then MoveCamera; |
162 | 559 |
|
1812 | 560 |
if not cReducedQuality then |
561 |
begin |
|
3265
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
562 |
// Offsets relative to camera - spare them to wimpier cpus, no bg or flakes for them anyway |
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
563 |
ScreenBottom:= (WorldDy - trunc(cScreenHeight/cScaleFactor) - (cScreenHeight div 2) + cWaterLine); |
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
564 |
offsetY:= 10 * min(0, -145 - ScreenBottom); |
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
565 |
SkyOffset:= offsetY div 35 + cWaveHeight; |
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
566 |
HorizontOffset:= SkyOffset; |
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
567 |
if ScreenBottom > SkyOffset then |
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
568 |
HorizontOffset:= HorizontOffset + ((ScreenBottom-SkyOffset) div 20); |
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
569 |
|
1812 | 570 |
// background |
3248 | 571 |
DrawRepeated(sprSky, sprSkyL, sprSkyR, (WorldDx + LAND_WIDTH div 2) * 3 div 8, SkyOffset); |
572 |
DrawRepeated(sprHorizont, sprHorizontL, sprHorizontR, (WorldDx + LAND_WIDTH div 2) * 3 div 5, HorizontOffset); |
|
4 | 573 |
|
1812 | 574 |
DrawVisualGears(0); |
3265
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
575 |
|
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
576 |
// Waves |
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
577 |
DrawWater(255, SkyOffset); |
3376 | 578 |
DrawWaves( 1, 0 - WorldDx div 32, - cWaveHeight + offsetY div 35, 64); |
579 |
DrawWaves( -1, 25 + WorldDx div 25, - cWaveHeight + offsetY div 38, 48); |
|
580 |
DrawWaves( 1, 75 - WorldDx div 19, - cWaveHeight + offsetY div 45, 32); |
|
581 |
DrawWaves(-1, 100 + WorldDx div 14, - cWaveHeight + offsetY div 70, 24); |
|
3265
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
582 |
end |
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
583 |
else |
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
584 |
DrawWaves(-1, 100, - (cWaveHeight + (cWaveHeight shr 1)), 0); |
4 | 585 |
|
762 | 586 |
DrawLand(WorldDx, WorldDy); |
1911 | 587 |
|
3104 | 588 |
DrawWater(255, 0); |
4 | 589 |
|
1660 | 590 |
// Attack bar |
3483 | 591 |
// TODO: Add weapon offset |
1660 | 592 |
if CurrentTeam <> nil then |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
593 |
case AttackBar of |
1660 | 594 |
(* 1: begin |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
595 |
r:= StuffPoz[sPowerBar]; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
596 |
{$WARNINGS OFF} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
597 |
r.w:= (CurrentHedgehog^.Gear^.Power * 256) div cPowerDivisor; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
598 |
{$WARNINGS ON} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
599 |
DrawSpriteFromRect(r, cScreenWidth - 272, cScreenHeight - 48, 16, 0, Surface); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
600 |
end;*) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
601 |
2: with CurrentHedgehog^ do |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
602 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
603 |
tdx:= hwSign(Gear^.dX) * Sin(Gear^.Angle * Pi / cMaxAngle); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
604 |
tdy:= - Cos(Gear^.Angle * Pi / cMaxAngle); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
605 |
for i:= (Gear^.Power * 24) div cPowerDivisor downto 0 do |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
606 |
DrawSprite(sprPower, |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
607 |
hwRound(Gear^.X) + round(WorldDx + tdx * (24 + i * 2)) - 16, |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
608 |
hwRound(Gear^.Y) + round(WorldDy + tdy * (24 + i * 2)) - 12, |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
609 |
i) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
610 |
end |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
611 |
end; |
1660 | 612 |
|
2713 | 613 |
DrawVisualGears(1); |
614 |
||
956 | 615 |
DrawGears; |
4 | 616 |
|
2713 | 617 |
DrawVisualGears(2); |
1045 | 618 |
|
3104 | 619 |
DrawWater(cWaterOpacity, 0); |
2269
00f5704f5f39
add extra semi-opaque layer of water to discolour objects in the water.
nemo
parents:
2268
diff
changeset
|
620 |
|
5 | 621 |
// Waves |
3376 | 622 |
DrawWaves( 1, 25 - WorldDx div 9, - cWaveHeight, 12); |
3265
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
623 |
|
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
624 |
if not cReducedQuality then |
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
625 |
begin |
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
626 |
//DrawWater(cWaterOpacity, - offsetY div 40); |
3376 | 627 |
DrawWaves(-1, 50 + WorldDx div 6, - cWaveHeight - offsetY div 40, 8); |
3265
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
628 |
DrawWater(cWaterOpacity, - offsetY div 20); |
3376 | 629 |
DrawWaves( 1, 75 - WorldDx div 4, - cWaveHeight - offsetY div 20, 2); |
3265
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
630 |
DrawWater(cWaterOpacity, - offsetY div 10); |
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
631 |
DrawWaves( -1, 25 + WorldDx div 3, - cWaveHeight - offsetY div 10, 0); |
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
632 |
end |
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
633 |
else |
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
634 |
DrawWaves(-1, 50, - (cWaveHeight shr 1), 0); |
2161
0c8634241fa4
Some work on zooming. Hedgewars are now unplayable.
unc0rr
parents:
2152
diff
changeset
|
635 |
|
0c8634241fa4
Some work on zooming. Hedgewars are now unplayable.
unc0rr
parents:
2152
diff
changeset
|
636 |
|
2288 | 637 |
{$WARNINGS OFF} |
2161
0c8634241fa4
Some work on zooming. Hedgewars are now unplayable.
unc0rr
parents:
2152
diff
changeset
|
638 |
// Target |
3104 | 639 |
if (TargetPoint.X <> NoPointX) and (CurrentTeam <> nil) and (CurrentHedgehog <> nil) then |
640 |
begin |
|
641 |
with PHedgehog(CurrentHedgehog)^ do |
|
642 |
begin |
|
3110 | 643 |
if (Ammo^[CurSlot, CurAmmo].AmmoType = amBee) then |
644 |
DrawRotatedF(sprTargetBee, TargetPoint.X + WorldDx, TargetPoint.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360) |
|
645 |
else |
|
3104 | 646 |
DrawRotatedF(sprTargetP, TargetPoint.X + WorldDx, TargetPoint.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360); |
647 |
end; |
|
648 |
end; |
|
4 | 649 |
{$WARNINGS ON} |
2161
0c8634241fa4
Some work on zooming. Hedgewars are now unplayable.
unc0rr
parents:
2152
diff
changeset
|
650 |
|
2567 | 651 |
{$IFDEF IPHONEOS} |
2724 | 652 |
scale:= 1.5; |
2567 | 653 |
{$ELSE} |
2724 | 654 |
scale:= 2.0; |
655 |
{$ENDIF} |
|
656 |
SetScale(scale); |
|
657 |
||
658 |
||
659 |
// Turn time |
|
2803
1f446fc5c8ec
allow to compile engine as library with HWLIBRARY symbol
koda
parents:
2786
diff
changeset
|
660 |
{$IFDEF IPHONEOS} |
3025 | 661 |
offsetX:= cScreenHeight - 13; |
2803
1f446fc5c8ec
allow to compile engine as library with HWLIBRARY symbol
koda
parents:
2786
diff
changeset
|
662 |
{$ELSE} |
3025 | 663 |
offsetX:= 48; |
2803
1f446fc5c8ec
allow to compile engine as library with HWLIBRARY symbol
koda
parents:
2786
diff
changeset
|
664 |
{$ENDIF} |
3463 | 665 |
offsetY:= cOffsetY; |
4 | 666 |
if TurnTimeLeft <> 0 then |
667 |
begin |
|
668 |
i:= Succ(Pred(TurnTimeLeft) div 1000); |
|
669 |
if i>99 then t:= 112 |
|
670 |
else if i>9 then t:= 96 |
|
671 |
else t:= 80; |
|
3463 | 672 |
DrawSprite(sprFrame, -(cScreenWidth shr 1) + t + offsetY, cScreenHeight - offsetX, 1); |
4 | 673 |
while i > 0 do |
674 |
begin |
|
675 |
dec(t, 32); |
|
3463 | 676 |
DrawSprite(sprBigDigit, -(cScreenWidth shr 1) + t + offsetY, cScreenHeight - offsetX, i mod 10); |
4 | 677 |
i:= i div 10 |
678 |
end; |
|
3463 | 679 |
DrawSprite(sprFrame, -(cScreenWidth shr 1) + t - 4 + offsetY, cScreenHeight - offsetX, 0); |
4 | 680 |
end; |
79 | 681 |
|
2567 | 682 |
{$IFNDEF IPHONEOS} |
2428 | 683 |
// Timetrial |
684 |
if ((TrainingFlags and tfTimeTrial) <> 0) and (TimeTrialStartTime > 0) then |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
685 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
686 |
if TimeTrialStopTime = 0 then i:= RealTicks - TimeTrialStartTime else i:= TimeTrialStopTime - TimeTrialStartTime; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
687 |
t:= 272; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
688 |
// right frame |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
689 |
DrawSprite(sprFrame, -cScreenWidth div 2 + t, 8, 1); |
2428 | 690 |
dec(t, 32); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
691 |
// 1 ms |
2428 | 692 |
DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, i mod 10); |
693 |
dec(t, 32); |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
694 |
i:= i div 10; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
695 |
// 10 ms |
2428 | 696 |
DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, i mod 10); |
697 |
dec(t, 32); |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
698 |
i:= i div 10; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
699 |
// 100 ms |
2428 | 700 |
DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, i mod 10); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
701 |
dec(t, 16); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
702 |
// Point |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
703 |
DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, 11); |
2428 | 704 |
dec(t, 32); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
705 |
i:= i div 10; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
706 |
// 1 s |
2428 | 707 |
DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, i mod 10); |
708 |
dec(t, 32); |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
709 |
i:= i div 10; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
710 |
// 10s |
2428 | 711 |
DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, i mod 6); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
712 |
dec(t, 16); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
713 |
// Point |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
714 |
DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, 10); |
2428 | 715 |
dec(t, 32); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
716 |
i:= i div 6; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
717 |
// 1 m |
2428 | 718 |
DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, i mod 10); |
719 |
dec(t, 32); |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
720 |
i:= i div 10; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
721 |
// 10 m |
2428 | 722 |
DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, i mod 10); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
723 |
// left frame |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
724 |
DrawSprite(sprFrame, -cScreenWidth div 2 + t - 4, 8, 0); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
725 |
end; |
2567 | 726 |
{$ENDIF} |
727 |
||
4 | 728 |
// Captions |
2567 | 729 |
{$IFDEF IPHONEOS} |
2803
1f446fc5c8ec
allow to compile engine as library with HWLIBRARY symbol
koda
parents:
2786
diff
changeset
|
730 |
offset:= 40; |
2567 | 731 |
{$ELSE} |
2724 | 732 |
if ((TrainingFlags and tfTimeTrial) <> 0) and (TimeTrialStartTime > 0) then offset:= 48 |
733 |
else offset:= 8; |
|
2567 | 734 |
{$ENDIF} |
2428 | 735 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
736 |
for grp:= Low(TCapGroup) to High(TCapGroup) do |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
737 |
with Captions[grp] do |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
738 |
if Tex <> nil then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
739 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
740 |
DrawCentered(0, offset, Tex); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
741 |
inc(offset, Tex^.h + 2); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
742 |
if EndTime <= RealTicks then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
743 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
744 |
FreeTexture(Tex); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
745 |
Tex:= nil; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
746 |
EndTime:= 0 |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
747 |
end; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
748 |
end; |
4 | 749 |
|
47 | 750 |
// Teams Healths |
547 | 751 |
for t:= 0 to Pred(TeamsCount) do |
752 |
with TeamsArray[t]^ do |
|
47 | 753 |
begin |
2839 | 754 |
highlight:= bShowFinger and (CurrentTeam = TeamsArray[t]) and ((RealTicks mod 1000) < 500); |
755 |
||
2747 | 756 |
if highlight then |
3445 | 757 |
Tint(Clan^.Color); |
2839 | 758 |
|
759 |
// draw name |
|
760 |
DrawTexture(-NameTagTex^.w - 16, cScreenHeight + DrawHealthY, NameTagTex); |
|
761 |
||
762 |
// draw flag |
|
763 |
DrawTexture(-14, cScreenHeight + DrawHealthY, FlagTex); |
|
764 |
||
765 |
// draw health bar |
|
690 | 766 |
r.x:= 0; |
767 |
r.y:= 0; |
|
547 | 768 |
r.w:= 2 + TeamHealthBarWidth; |
764
7513452b1d51
Now game looks almost like it did before switching to OpenGL
unc0rr
parents:
762
diff
changeset
|
769 |
r.h:= HealthTex^.h; |
2747 | 770 |
DrawFromRect(14, cScreenHeight + DrawHealthY, @r, HealthTex); |
690 | 771 |
|
2839 | 772 |
// draw health bar's right border |
83 | 773 |
inc(r.x, cTeamHealthWidth + 2); |
774 |
r.w:= 3; |
|
2839 | 775 |
DrawFromRect(TeamHealthBarWidth + 16, cScreenHeight + DrawHealthY, @r, HealthTex); |
776 |
// if highlighted, draw flag and other contents again to keep their colors |
|
777 |
// this approach should be faster than drawing all borders one by one tinted or not |
|
778 |
if highlight then |
|
779 |
begin |
|
3390 | 780 |
Tint($FF, $FF, $FF, $FF); |
690 | 781 |
|
2839 | 782 |
// draw name |
2747 | 783 |
r.x:= 2; |
784 |
r.y:= 2; |
|
2839 | 785 |
r.w:= NameTagTex^.w - 4; |
786 |
r.h:= NameTagTex^.h - 4; |
|
787 |
DrawFromRect(-NameTagTex^.w - 14, cScreenHeight + DrawHealthY + 2, @r, NameTagTex); |
|
788 |
// draw flag |
|
2747 | 789 |
r.w:= 22; |
790 |
r.h:= 15; |
|
791 |
DrawFromRect(-12, cScreenHeight + DrawHealthY + 2, @r, FlagTex); |
|
2839 | 792 |
// draw health bar |
793 |
r.w:= TeamHealthBarWidth + 1; |
|
794 |
r.h:= HealthTex^.h - 4; |
|
795 |
DrawFromRect(16, cScreenHeight + DrawHealthY + 2, @r, HealthTex); |
|
2747 | 796 |
end; |
47 | 797 |
end; |
798 |
||
5 | 799 |
// Lag alert |
2567 | 800 |
if isInLag then DrawSprite(sprLag, 32 - (cScreenWidth shr 1), 32, (RealTicks shr 7) mod 12); |
4 | 801 |
|
5 | 802 |
// Wind bar |
2567 | 803 |
{$IFDEF IPHONEOS} |
3405 | 804 |
offsetX:= cScreenHeight - 13; |
805 |
offsetY:= (cScreenWidth shr 1) + 74; |
|
2567 | 806 |
{$ELSE} |
3405 | 807 |
offsetX:= 30; |
808 |
offsetY:= 180; |
|
2567 | 809 |
{$ENDIF} |
3405 | 810 |
DrawSprite(sprWindBar, (cScreenWidth shr 1) - offsetY, cScreenHeight - offsetX, 0); |
811 |
if WindBarWidth > 0 then |
|
812 |
begin |
|
813 |
{$WARNINGS OFF} |
|
814 |
r.x:= 8 - (RealTicks shr 6) mod 8; |
|
815 |
{$WARNINGS ON} |
|
816 |
r.y:= 0; |
|
817 |
r.w:= WindBarWidth; |
|
818 |
r.h:= 13; |
|
819 |
DrawSpriteFromRect(sprWindR, r, (cScreenWidth shr 1) - offsetY + 77, cScreenHeight - offsetX + 2, 13, 0); |
|
820 |
end |
|
821 |
else |
|
822 |
if WindBarWidth < 0 then |
|
823 |
begin |
|
824 |
{$WARNINGS OFF} |
|
3407 | 825 |
r.x:= (Longword(WindBarWidth) + RealTicks shr 6) mod 8; |
3405 | 826 |
{$WARNINGS ON} |
827 |
r.y:= 0; |
|
828 |
r.w:= - WindBarWidth; |
|
829 |
r.h:= 13; |
|
830 |
DrawSpriteFromRect(sprWindL, r, (cScreenWidth shr 1) - offsetY + 74 + WindBarWidth, cScreenHeight - offsetX + 2, 13, 0); |
|
831 |
end; |
|
5 | 832 |
|
161 | 833 |
// AmmoMenu |
3434 | 834 |
if (AMxShift < AMWidth) or bShowAmmoMenu then ShowAmmoMenu; |
161 | 835 |
|
2287 | 836 |
// Cursor |
837 |
if isCursorVisible and bShowAmmoMenu then |
|
838 |
DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8); |
|
942 | 839 |
|
2287 | 840 |
DrawChat; |
4 | 841 |
|
2567 | 842 |
if fastUntilLag then DrawCentered(0, (cScreenHeight shr 1), SyncTexture); |
843 |
if isPaused then DrawCentered(0, (cScreenHeight shr 1), PauseTexture); |
|
281
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
244
diff
changeset
|
844 |
|
3304 | 845 |
if not isFirstFrame and ((missionTimer <> 0) or isPaused or fastUntilLag or (GameState = gsConfirm)) then |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
846 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
847 |
if missionTimer > 0 then dec(missionTimer, Lag); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
848 |
if missionTimer < 0 then missionTimer:= 0; // avoid subtracting below 0 |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
849 |
if missionTex <> nil then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
850 |
DrawCentered(0, min((cScreenHeight shr 1) + 100, cScreenHeight - 48 - missionTex^.h), missionTex); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
851 |
end; |
2786 | 852 |
|
2724 | 853 |
// fps |
854 |
{$IFDEF IPHONEOS} |
|
3463 | 855 |
offsetX:= 8; |
2724 | 856 |
{$ELSE} |
3463 | 857 |
offsetX:= 10; |
2724 | 858 |
{$ENDIF} |
3463 | 859 |
offsetY:= cOffsetY; |
4 | 860 |
inc(Frames); |
2850
f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset
|
861 |
|
f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset
|
862 |
if cShowFPS or (GameType = gmtDemo) then inc(CountTicks, Lag); |
2851 | 863 |
if (GameType = gmtDemo) and (CountTicks >= 1000) then |
2850
f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset
|
864 |
begin |
3407 | 865 |
i:=GameTicks div 1000; |
866 |
t:= i mod 60; |
|
867 |
s:= inttostr(t); |
|
868 |
if t < 10 then s:= '0' + s; |
|
869 |
i:= i div 60; |
|
870 |
t:= i mod 60; |
|
871 |
s:= inttostr(t) + ':' + s; |
|
872 |
if t < 10 then s:= '0' + s; |
|
873 |
s:= inttostr(i div 60) + ':' + s; |
|
874 |
||
2851 | 875 |
if timeTexture <> nil then FreeTexture(timeTexture); |
2850
f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset
|
876 |
tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), cWhiteColorChannels); |
f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset
|
877 |
tmpSurface:= doSurfaceConversion(tmpSurface); |
f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset
|
878 |
timeTexture:= Surface2Tex(tmpSurface, false); |
f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset
|
879 |
SDL_FreeSurface(tmpSurface) |
f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset
|
880 |
end; |
f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset
|
881 |
|
f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset
|
882 |
if timeTexture <> nil then |
3463 | 883 |
DrawTexture((cScreenWidth shr 1) - 20 - timeTexture^.w - offsetY, offsetX + timeTexture^.h+5, timeTexture); |
2850
f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset
|
884 |
|
298
112e61bd2cc2
Render FPS value to its own surface one time a second
unc0rr
parents:
295
diff
changeset
|
885 |
if cShowFPS then |
4 | 886 |
begin |
298
112e61bd2cc2
Render FPS value to its own surface one time a second
unc0rr
parents:
295
diff
changeset
|
887 |
if CountTicks >= 1000 then |
112e61bd2cc2
Render FPS value to its own surface one time a second
unc0rr
parents:
295
diff
changeset
|
888 |
begin |
112e61bd2cc2
Render FPS value to its own surface one time a second
unc0rr
parents:
295
diff
changeset
|
889 |
FPS:= Frames; |
112e61bd2cc2
Render FPS value to its own surface one time a second
unc0rr
parents:
295
diff
changeset
|
890 |
Frames:= 0; |
112e61bd2cc2
Render FPS value to its own surface one time a second
unc0rr
parents:
295
diff
changeset
|
891 |
CountTicks:= 0; |
112e61bd2cc2
Render FPS value to its own surface one time a second
unc0rr
parents:
295
diff
changeset
|
892 |
s:= inttostr(FPS) + ' fps'; |
759 | 893 |
if fpsTexture <> nil then FreeTexture(fpsTexture); |
2665
50b4e544c163
complete transition of longword->sdl_color for TTF bindings
koda
parents:
2630
diff
changeset
|
894 |
tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), cWhiteColorChannels); |
2670 | 895 |
tmpSurface:= doSurfaceConversion(tmpSurface); |
2290
bf87ca44782e
Selectively enable clamping - seeing if this helps avoid weird flake problems while still fixing vertical lines in waves and sky
nemo
parents:
2288
diff
changeset
|
896 |
fpsTexture:= Surface2Tex(tmpSurface, false); |
759 | 897 |
SDL_FreeSurface(tmpSurface) |
298
112e61bd2cc2
Render FPS value to its own surface one time a second
unc0rr
parents:
295
diff
changeset
|
898 |
end; |
759 | 899 |
if fpsTexture <> nil then |
3463 | 900 |
DrawTexture((cScreenWidth shr 1) - 60 - offsetY, offsetX, fpsTexture); |
4 | 901 |
end; |
174 | 902 |
|
2850
f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset
|
903 |
if CountTicks >= 1000 then CountTicks:= 0; |
f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset
|
904 |
|
2724 | 905 |
// lag warning (?) |
174 | 906 |
inc(SoundTimerTicks, Lag); |
907 |
if SoundTimerTicks >= 50 then |
|
908 |
begin |
|
909 |
SoundTimerTicks:= 0; |
|
910 |
if cVolumeDelta <> 0 then |
|
911 |
begin |
|
912 |
str(ChangeVolume(cVolumeDelta), s); |
|
2619 | 913 |
AddCaption(Format(trmsg[sidVolume], s), cWhiteColor, capgrpVolume) |
174 | 914 |
end |
756 | 915 |
end; |
916 |
||
2724 | 917 |
if GameState = gsConfirm then |
3025 | 918 |
DrawCentered(0, (cScreenHeight shr 1), ConfirmTexture); |
2161
0c8634241fa4
Some work on zooming. Hedgewars are now unplayable.
unc0rr
parents:
2152
diff
changeset
|
919 |
|
3107 | 920 |
if ScreenFade <> sfNone then |
921 |
begin |
|
922 |
if not isFirstFrame then |
|
923 |
case ScreenFade of |
|
924 |
sfToBlack, sfToWhite: if ScreenFadeValue + Lag * ScreenFadeSpeed < sfMax then |
|
925 |
inc(ScreenFadeValue, Lag * ScreenFadeSpeed) |
|
926 |
else |
|
3123 | 927 |
ScreenFadeValue:= sfMax; |
3107 | 928 |
sfFromBlack, sfFromWhite: if ScreenFadeValue - Lag * ScreenFadeSpeed > 0 then |
929 |
dec(ScreenFadeValue, Lag * ScreenFadeSpeed) |
|
930 |
else |
|
3123 | 931 |
ScreenFadeValue:= 0; |
3107 | 932 |
end; |
933 |
if ScreenFade <> sfNone then |
|
934 |
begin |
|
935 |
case ScreenFade of |
|
3376 | 936 |
sfToBlack, sfFromBlack: Tint(0, 0, 0, ScreenFadeValue * 255 div 1000); |
937 |
sfToWhite, sfFromWhite: Tint($FF, $FF, $FF, ScreenFadeValue * 255 div 1000); |
|
3107 | 938 |
end; |
3113 | 939 |
|
940 |
VertexBuffer[0].X:= -cScreenWidth; |
|
941 |
VertexBuffer[0].Y:= cScreenHeight; |
|
942 |
VertexBuffer[1].X:= -cScreenWidth; |
|
943 |
VertexBuffer[1].Y:= 0; |
|
944 |
VertexBuffer[2].X:= cScreenWidth; |
|
945 |
VertexBuffer[2].Y:= 0; |
|
946 |
VertexBuffer[3].X:= cScreenWidth; |
|
947 |
VertexBuffer[3].Y:= cScreenHeight; |
|
948 |
||
3376 | 949 |
glDisable(GL_TEXTURE_2D); |
3113 | 950 |
glEnableClientState(GL_VERTEX_ARRAY); |
951 |
glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); |
|
952 |
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); |
|
953 |
glDisableClientState(GL_VERTEX_ARRAY); |
|
3376 | 954 |
glEnable(GL_TEXTURE_2D); |
3390 | 955 |
Tint($FF, $FF, $FF, $FF); |
3123 | 956 |
if not isFirstFrame and ((ScreenFadeValue = 0) or (ScreenFadeValue = sfMax)) then ScreenFade:= sfNone |
3107 | 957 |
end |
958 |
end; |
|
959 |
||
3123 | 960 |
SetScale(zoom); |
961 |
||
962 |
// Cursor |
|
963 |
if isCursorVisible then |
|
964 |
begin |
|
965 |
if not bShowAmmoMenu then |
|
3204 | 966 |
begin |
3123 | 967 |
with CurrentHedgehog^ do |
968 |
if (Gear^.State and gstHHChooseTarget) <> 0 then |
|
969 |
begin |
|
970 |
i:= Ammo^[CurSlot, CurAmmo].Pos; |
|
971 |
with Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType] do |
|
972 |
if PosCount > 1 then |
|
3204 | 973 |
DrawSprite(PosSprite, CursorPoint.X - (SpritesData[PosSprite].Width shr 1), cScreenHeight - CursorPoint.Y - (SpritesData[PosSprite].Height shr 1),i); |
3123 | 974 |
end; |
3204 | 975 |
DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8) |
976 |
end |
|
3123 | 977 |
end; |
3107 | 978 |
isFirstFrame:= false |
4 | 979 |
end; |
980 |
||
2905 | 981 |
procedure AddCaption(s: shortstring; Color: Longword; Group: TCapGroup); |
4 | 982 |
begin |
2142 | 983 |
//if Group in [capgrpGameState] then WriteLnToConsole(s); |
762 | 984 |
if Captions[Group].Tex <> nil then FreeTexture(Captions[Group].Tex); |
4 | 985 |
|
762 | 986 |
Captions[Group].Tex:= RenderStringTex(s, Color, fntBig); |
2142 | 987 |
|
988 |
case Group of |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
989 |
capgrpGameState: Captions[Group].EndTime:= RealTicks + 2200 |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
990 |
else |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
991 |
Captions[Group].EndTime:= RealTicks + 1400 + LongWord(Captions[Group].Tex^.w) * 3; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
992 |
end; |
4 | 993 |
end; |
994 |
||
79 | 995 |
procedure MoveCamera; |
4 | 996 |
const PrevSentPointTime: LongWord = 0; |
2428 | 997 |
var EdgesDist, wdy: LongInt; |
4 | 998 |
begin |
2970
011075f93746
Let's try this too (override following remote if in ammo menu)
nemo
parents:
2959
diff
changeset
|
999 |
if (not (CurrentTeam^.ExtDriven and isCursorVisible and not bShowAmmoMenu)) and cHasFocus then |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1000 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1001 |
SDL_GetMouseState(@CursorPoint.X, @CursorPoint.Y); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1002 |
CursorPoint.X:= CursorPoint.X - (cScreenWidth shr 1); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1003 |
CursorPoint.Y:= cScreenHeight - CursorPoint.Y; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1004 |
end; |
678 | 1005 |
|
2762
2fbc8d35eb52
Mode to place hogs at start of game. Will probably need a bit more testing.
nemo
parents:
2747
diff
changeset
|
1006 |
if (not PlacingHogs) and (FollowGear <> nil) and (not isCursorVisible) and (not fastUntilLag) then |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1007 |
if abs(CursorPoint.X - prevPoint.X) + abs(CursorPoint.Y - prevpoint.Y) > 4 then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1008 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1009 |
FollowGear:= nil; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1010 |
prevPoint:= CursorPoint; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1011 |
exit |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1012 |
end |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1013 |
else begin |
2970
011075f93746
Let's try this too (override following remote if in ammo menu)
nemo
parents:
2959
diff
changeset
|
1014 |
CursorPoint.X:= (prevPoint.X * 7 + hwRound(FollowGear^.X) + hwSign(FollowGear^.dX) * 100 + WorldDx) div 8; |
011075f93746
Let's try this too (override following remote if in ammo menu)
nemo
parents:
2959
diff
changeset
|
1015 |
CursorPoint.Y:= (prevPoint.Y * 7 + cScreenHeight - (hwRound(FollowGear^.Y) + WorldDy)) div 8; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1016 |
end; |
4 | 1017 |
|
2375 | 1018 |
wdy:= trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 - cWaterLine - cVisibleWater; |
1019 |
if WorldDy < wdy then WorldDy:= wdy; |
|
1020 |
||
2197 | 1021 |
if ((CursorPoint.X = prevPoint.X) and (CursorPoint.Y = prevpoint.Y)) then exit; |
4 | 1022 |
|
3434 | 1023 |
if AMxShift < AMWidth then |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1024 |
begin |
3463 | 1025 |
{$IFDEF IPHONEOS} |
3434 | 1026 |
if CursorPoint.X < cScreenWidth div 2 + AMxShift - AMWidth then CursorPoint.X:= cScreenWidth div 2 + AMxShift - AMWidth; |
1027 |
if CursorPoint.X > cScreenWidth div 2 + AMxShift - AMxOffset then CursorPoint.X:= cScreenWidth div 2 + AMxShift - AMxOffset; |
|
1028 |
if CursorPoint.Y < cScreenHeight - AMyOffset - SlotsNum * AMSlotSize then CursorPoint.Y:= cScreenHeight - AMyOffset - SlotsNum * AMSlotSize; |
|
1029 |
if CursorPoint.Y > cScreenHeight - AMyOffset then CursorPoint.Y:= cScreenHeight - AMyOffset; |
|
3463 | 1030 |
{$ELSE} |
3434 | 1031 |
if CursorPoint.X < cScreenWidth div 2 + AMxShift - AMWidth + AMSlotSize then CursorPoint.X:= cScreenWidth div 2 + AMxShift - AMWidth + AMSlotSize; |
1032 |
if CursorPoint.X > cScreenWidth div 2 + AMxShift - AMxOffset then CursorPoint.X:= cScreenWidth div 2 + AMxShift - AMxOffset; |
|
1033 |
if CursorPoint.Y > AMyOffset + (SlotsNum + 1) * AMSlotSize then CursorPoint.Y:= AMyOffset + (SlotsNum + 1) * AMSlotSize; |
|
1034 |
if CursorPoint.Y < AMyOffset + AMSlotSize then CursorPoint.Y:= AMyOffset + AMSlotSize; |
|
3463 | 1035 |
{$ENDIF} |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1036 |
prevPoint:= CursorPoint; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1037 |
if cHasFocus then SDL_WarpMouse(CursorPoint.X + cScreenWidth div 2, cScreenHeight - CursorPoint.Y); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1038 |
exit |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1039 |
end; |
162 | 1040 |
|
4 | 1041 |
if isCursorVisible then |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1042 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1043 |
if (not CurrentTeam^.ExtDriven) and (GameTicks >= PrevSentPointTime + cSendCursorPosTime) then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1044 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1045 |
SendIPCXY('P', CursorPoint.X - WorldDx, cScreenHeight - CursorPoint.Y - WorldDy); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1046 |
PrevSentPointTime:= GameTicks |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1047 |
end; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1048 |
end; |
351 | 1049 |
|
4 | 1050 |
if isCursorVisible or (FollowGear <> nil) then |
1051 |
begin |
|
284 | 1052 |
if isCursorVisible then EdgesDist:= cCursorEdgesDist |
1053 |
else EdgesDist:= cGearScrEdgesDist; |
|
2197 | 1054 |
if CursorPoint.X < - cScreenWidth div 2 + EdgesDist then |
4 | 1055 |
begin |
2197 | 1056 |
WorldDx:= WorldDx - CursorPoint.X - cScreenWidth div 2 + EdgesDist; |
1057 |
CursorPoint.X:= - cScreenWidth div 2 + EdgesDist |
|
4 | 1058 |
end else |
2197 | 1059 |
if CursorPoint.X > cScreenWidth div 2 - EdgesDist then |
4 | 1060 |
begin |
2197 | 1061 |
WorldDx:= WorldDx - CursorPoint.X + cScreenWidth div 2 - EdgesDist; |
2198 | 1062 |
CursorPoint.X:= cScreenWidth div 2 - EdgesDist |
4 | 1063 |
end; |
284 | 1064 |
if CursorPoint.Y < EdgesDist then |
4 | 1065 |
begin |
2197 | 1066 |
WorldDy:= WorldDy + CursorPoint.Y - EdgesDist; |
284 | 1067 |
CursorPoint.Y:= EdgesDist |
4 | 1068 |
end else |
284 | 1069 |
if CursorPoint.Y > cScreenHeight - EdgesDist then |
4 | 1070 |
begin |
2197 | 1071 |
WorldDy:= WorldDy + CursorPoint.Y - cScreenHeight + EdgesDist; |
284 | 1072 |
CursorPoint.Y:= cScreenHeight - EdgesDist |
4 | 1073 |
end; |
1074 |
end else |
|
308 | 1075 |
if cHasFocus then |
1076 |
begin |
|
70 | 1077 |
WorldDx:= WorldDx - CursorPoint.X + prevPoint.X; |
2197 | 1078 |
WorldDy:= WorldDy + CursorPoint.Y - prevPoint.Y; |
2162 | 1079 |
CursorPoint.X:= 0; |
1080 |
CursorPoint.Y:= cScreenHeight div 2; |
|
308 | 1081 |
end; |
351 | 1082 |
|
4 | 1083 |
prevPoint:= CursorPoint; |
2567 | 1084 |
if cHasFocus then SDL_WarpMouse(CursorPoint.X + (cScreenWidth shr 1), cScreenHeight - CursorPoint.Y); |
1760 | 1085 |
if WorldDy > LAND_HEIGHT + 1024 then WorldDy:= LAND_HEIGHT + 1024; |
2375 | 1086 |
if WorldDy < wdy then WorldDy:= wdy; |
2426 | 1087 |
if WorldDx < - LAND_WIDTH - 1024 then WorldDx:= - LAND_WIDTH - 1024; |
1088 |
if WorldDx > 1024 then WorldDx:= 1024; |
|
4 | 1089 |
end; |
1090 |
||
2905 | 1091 |
procedure ShowMission(caption, subcaption, text: ansistring; icon, time : LongInt); |
2786 | 1092 |
var r: TSDL_Rect; |
1093 |
begin |
|
1094 |
r.w:= 32; |
|
1095 |
r.h:= 32; |
|
1096 |
||
1097 |
if time = 0 then time:= 5000; |
|
1098 |
missionTimer:= time; |
|
1099 |
if missionTex <> nil then FreeTexture(missionTex); |
|
1100 |
||
1101 |
if icon > -1 then |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1102 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1103 |
r.x:= 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1104 |
r.y:= icon * 32; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1105 |
missionTex:= RenderHelpWindow(caption, subcaption, text, '', 0, MissionIcons, @r) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1106 |
end |
2786 | 1107 |
else |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1108 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1109 |
r.x:= ((-icon - 1) shr 5) * 32; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1110 |
r.y:= ((-icon - 1) mod 32) * 32; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1111 |
missionTex:= RenderHelpWindow(caption, subcaption, text, '', 0, SpritesData[sprAMAmmos].Surface, @r) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1112 |
end; |
2786 | 1113 |
end; |
1114 |
||
1115 |
procedure HideMission; |
|
1116 |
begin |
|
3045 | 1117 |
missionTimer:= 0; |
1118 |
if missionTex <> nil then FreeTexture(missionTex); |
|
2786 | 1119 |
end; |
1120 |
||
3032 | 1121 |
procedure ShakeCamera(amount: LongWord); |
1122 |
begin |
|
1123 |
amount:= max(1, amount); |
|
1124 |
WorldDx:= WorldDx - amount + LongInt(getRandom(1 + amount * 2)); |
|
1125 |
WorldDy:= WorldDy - amount + LongInt(getRandom(1 + amount * 2)); |
|
1126 |
end; |
|
1127 |
||
3038 | 1128 |
procedure initModule; |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2682
diff
changeset
|
1129 |
begin |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1130 |
fpsTexture:= nil; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1131 |
FollowGear:= nil; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1132 |
WindBarWidth:= 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1133 |
bShowAmmoMenu:= false; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1134 |
bSelected:= false; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1135 |
bShowFinger:= false; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1136 |
Frames:= 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1137 |
WorldDx:= -512; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1138 |
WorldDy:= -256; |
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2713
diff
changeset
|
1139 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1140 |
FPS:= 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1141 |
CountTicks:= 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1142 |
SoundTimerTicks:= 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1143 |
prevPoint.X:= 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1144 |
prevPoint.Y:= 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1145 |
missionTimer:= 0; |
3240 | 1146 |
missionTex:= nil; |
3463 | 1147 |
cOffsetY:= 0; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1148 |
|
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1149 |
FillChar(Captions, sizeof(Captions), 0) |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2682
diff
changeset
|
1150 |
end; |
4 | 1151 |
|
3038 | 1152 |
procedure freeModule; |
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2713
diff
changeset
|
1153 |
begin |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2713
diff
changeset
|
1154 |
end; |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2713
diff
changeset
|
1155 |
|
4 | 1156 |
end. |