author | nemo |
Tue, 29 Jun 2010 15:52:13 -0400 | |
changeset 3589 | 115c76f94b4a |
parent 3582 | 4debed8656d7 |
child 3594 | aeca3d8f1b29 |
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); |
3537
8f5b3108f29c
New approach to the low-res problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
nemo
parents:
3523
diff
changeset
|
489 |
var i, w, h, lw, lh, rw, rh, sw: LongInt; |
2426 | 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 |
3537
8f5b3108f29c
New approach to the low-res problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
nemo
parents:
3523
diff
changeset
|
494 |
w:= SpritesData[spr].Width * SpritesData[spr].Texture^.Scale; |
8f5b3108f29c
New approach to the low-res problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
nemo
parents:
3523
diff
changeset
|
495 |
h:= SpritesData[spr].Height * SpritesData[spr].Texture^.Scale; |
3405 | 496 |
i:= Shift mod w; |
497 |
if i > 0 then dec(i, w); |
|
498 |
dec(i, w * (sw div w + 1)); |
|
499 |
repeat |
|
3537
8f5b3108f29c
New approach to the low-res problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
nemo
parents:
3523
diff
changeset
|
500 |
DrawTexture(i, WorldDy + LAND_HEIGHT + OffsetY - h, SpritesData[spr].Texture, SpritesData[spr].Texture^.Scale); |
3405 | 501 |
inc(i, w) |
502 |
until i > sw |
|
503 |
end |
|
504 |
else |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
505 |
begin |
3537
8f5b3108f29c
New approach to the low-res problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
nemo
parents:
3523
diff
changeset
|
506 |
w:= SpritesData[spr].Width * SpritesData[spr].Texture^.Scale; |
8f5b3108f29c
New approach to the low-res problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
nemo
parents:
3523
diff
changeset
|
507 |
h:= SpritesData[spr].Height * SpritesData[spr].Texture^.Scale; |
8f5b3108f29c
New approach to the low-res problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
nemo
parents:
3523
diff
changeset
|
508 |
lw:= SpritesData[sprL].Width * SpritesData[spr].Texture^.Scale; |
8f5b3108f29c
New approach to the low-res problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
nemo
parents:
3523
diff
changeset
|
509 |
lh:= SpritesData[sprL].Height * SpritesData[spr].Texture^.Scale; |
8f5b3108f29c
New approach to the low-res problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
nemo
parents:
3523
diff
changeset
|
510 |
rw:= SpritesData[sprR].Width * SpritesData[spr].Texture^.Scale; |
8f5b3108f29c
New approach to the low-res problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
nemo
parents:
3523
diff
changeset
|
511 |
rh:= SpritesData[sprR].Height * SpritesData[spr].Texture^.Scale; |
3405 | 512 |
dec(Shift, w div 2); |
3537
8f5b3108f29c
New approach to the low-res problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
nemo
parents:
3523
diff
changeset
|
513 |
DrawTexture(Shift, WorldDy + LAND_HEIGHT + OffsetY - h, SpritesData[spr].Texture, SpritesData[spr].Texture^.Scale); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
514 |
|
3537
8f5b3108f29c
New approach to the low-res problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
nemo
parents:
3523
diff
changeset
|
515 |
i:= Shift - lw; |
8f5b3108f29c
New approach to the low-res problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
nemo
parents:
3523
diff
changeset
|
516 |
while i >= -sw - lw do |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
517 |
begin |
3537
8f5b3108f29c
New approach to the low-res problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
nemo
parents:
3523
diff
changeset
|
518 |
DrawTexture(i, WorldDy + LAND_HEIGHT + OffsetY - lh, SpritesData[sprL].Texture, SpritesData[sprL].Texture^.Scale); |
8f5b3108f29c
New approach to the low-res problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
nemo
parents:
3523
diff
changeset
|
519 |
dec(i, lw); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
520 |
end; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
521 |
|
3405 | 522 |
i:= Shift + w; |
523 |
while i <= sw do |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
524 |
begin |
3537
8f5b3108f29c
New approach to the low-res problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
nemo
parents:
3523
diff
changeset
|
525 |
DrawTexture(i, WorldDy + LAND_HEIGHT + OffsetY - rh, SpritesData[sprR].Texture, SpritesData[sprR].Texture^.Scale); |
8f5b3108f29c
New approach to the low-res problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
nemo
parents:
3523
diff
changeset
|
526 |
inc(i, rw) |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
527 |
end |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
528 |
end |
2426 | 529 |
end; |
530 |
||
531 |
||
956 | 532 |
procedure DrawWorld(Lag: LongInt); |
371 | 533 |
var i, t: LongInt; |
4 | 534 |
r: TSDL_Rect; |
107 | 535 |
tdx, tdy: Double; |
175 | 536 |
grp: TCapGroup; |
174 | 537 |
s: string[15]; |
2803
1f446fc5c8ec
allow to compile engine as library with HWLIBRARY symbol
koda
parents:
2786
diff
changeset
|
538 |
highlight: Boolean; |
3265
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
539 |
offset, offsetX, offsetY, ScreenBottom: LongInt; |
3113 | 540 |
VertexBuffer: array [0..3] of TVertex2f; |
4 | 541 |
begin |
3523 | 542 |
if not isPaused then |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
543 |
begin |
3523 | 544 |
if ZoomValue < zoom then |
3444 | 545 |
begin |
3523 | 546 |
zoom:= zoom - 0.002 * Lag; |
547 |
if ZoomValue > zoom then |
|
548 |
zoom:= ZoomValue |
|
549 |
end |
|
550 |
else |
|
551 |
if ZoomValue > zoom then |
|
3444 | 552 |
begin |
3523 | 553 |
zoom:= zoom + 0.002 * Lag; |
554 |
if ZoomValue < zoom then |
|
555 |
zoom:= ZoomValue |
|
3444 | 556 |
end |
557 |
end |
|
558 |
else |
|
559 |
ZoomValue:= zoom; |
|
2376 | 560 |
|
770 | 561 |
// Sky |
756 | 562 |
glClear(GL_COLOR_BUFFER_BIT); |
777 | 563 |
//glPushMatrix; |
564 |
//glScalef(1.0, 1.0, 1.0); |
|
756 | 565 |
|
281
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
244
diff
changeset
|
566 |
if not isPaused then MoveCamera; |
162 | 567 |
|
1812 | 568 |
if not cReducedQuality then |
569 |
begin |
|
3265
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
570 |
// 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
|
571 |
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
|
572 |
offsetY:= 10 * min(0, -145 - ScreenBottom); |
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
573 |
SkyOffset:= offsetY div 35 + cWaveHeight; |
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
574 |
HorizontOffset:= SkyOffset; |
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
575 |
if ScreenBottom > SkyOffset then |
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
576 |
HorizontOffset:= HorizontOffset + ((ScreenBottom-SkyOffset) div 20); |
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
577 |
|
1812 | 578 |
// background |
3248 | 579 |
DrawRepeated(sprSky, sprSkyL, sprSkyR, (WorldDx + LAND_WIDTH div 2) * 3 div 8, SkyOffset); |
580 |
DrawRepeated(sprHorizont, sprHorizontL, sprHorizontR, (WorldDx + LAND_WIDTH div 2) * 3 div 5, HorizontOffset); |
|
4 | 581 |
|
1812 | 582 |
DrawVisualGears(0); |
3265
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
583 |
|
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
584 |
// Waves |
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
585 |
DrawWater(255, SkyOffset); |
3376 | 586 |
DrawWaves( 1, 0 - WorldDx div 32, - cWaveHeight + offsetY div 35, 64); |
587 |
DrawWaves( -1, 25 + WorldDx div 25, - cWaveHeight + offsetY div 38, 48); |
|
588 |
DrawWaves( 1, 75 - WorldDx div 19, - cWaveHeight + offsetY div 45, 32); |
|
589 |
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
|
590 |
end |
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
591 |
else |
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
592 |
DrawWaves(-1, 100, - (cWaveHeight + (cWaveHeight shr 1)), 0); |
4 | 593 |
|
762 | 594 |
DrawLand(WorldDx, WorldDy); |
1911 | 595 |
|
3104 | 596 |
DrawWater(255, 0); |
4 | 597 |
|
1660 | 598 |
// Attack bar |
599 |
if CurrentTeam <> nil then |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
600 |
case AttackBar of |
1660 | 601 |
(* 1: begin |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
602 |
r:= StuffPoz[sPowerBar]; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
603 |
{$WARNINGS OFF} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
604 |
r.w:= (CurrentHedgehog^.Gear^.Power * 256) div cPowerDivisor; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
605 |
{$WARNINGS ON} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
606 |
DrawSpriteFromRect(r, cScreenWidth - 272, cScreenHeight - 48, 16, 0, Surface); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
607 |
end;*) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
608 |
2: with CurrentHedgehog^ do |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
609 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
610 |
tdx:= hwSign(Gear^.dX) * Sin(Gear^.Angle * Pi / cMaxAngle); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
611 |
tdy:= - Cos(Gear^.Angle * Pi / cMaxAngle); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
612 |
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
|
613 |
DrawSprite(sprPower, |
3580 | 614 |
hwRound(Gear^.X) + GetLaunchX(Ammo^[CurSlot, CurAmmo].AmmoType, hwSign(Gear^.dX), Gear^.Angle) + round(WorldDx + tdx * (24 + i * 2)) - 16, |
615 |
hwRound(Gear^.Y) + GetLaunchY(Ammo^[CurSlot, CurAmmo].AmmoType, Gear^.Angle) + round(WorldDy + tdy * (24 + i * 2)) - 16, |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
616 |
i) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
617 |
end |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
618 |
end; |
1660 | 619 |
|
2713 | 620 |
DrawVisualGears(1); |
621 |
||
956 | 622 |
DrawGears; |
4 | 623 |
|
2713 | 624 |
DrawVisualGears(2); |
1045 | 625 |
|
3104 | 626 |
DrawWater(cWaterOpacity, 0); |
2269
00f5704f5f39
add extra semi-opaque layer of water to discolour objects in the water.
nemo
parents:
2268
diff
changeset
|
627 |
|
5 | 628 |
// Waves |
3376 | 629 |
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
|
630 |
|
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
631 |
if not cReducedQuality then |
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
632 |
begin |
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
633 |
//DrawWater(cWaterOpacity, - offsetY div 40); |
3376 | 634 |
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
|
635 |
DrawWater(cWaterOpacity, - offsetY div 20); |
3376 | 636 |
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
|
637 |
DrawWater(cWaterOpacity, - offsetY div 10); |
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
638 |
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
|
639 |
end |
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
640 |
else |
5fe62296fdea
- Parallax effect for horizont when water is out of sight
palewolf
parents:
3249
diff
changeset
|
641 |
DrawWaves(-1, 50, - (cWaveHeight shr 1), 0); |
2161
0c8634241fa4
Some work on zooming. Hedgewars are now unplayable.
unc0rr
parents:
2152
diff
changeset
|
642 |
|
0c8634241fa4
Some work on zooming. Hedgewars are now unplayable.
unc0rr
parents:
2152
diff
changeset
|
643 |
|
2288 | 644 |
{$WARNINGS OFF} |
2161
0c8634241fa4
Some work on zooming. Hedgewars are now unplayable.
unc0rr
parents:
2152
diff
changeset
|
645 |
// Target |
3104 | 646 |
if (TargetPoint.X <> NoPointX) and (CurrentTeam <> nil) and (CurrentHedgehog <> nil) then |
647 |
begin |
|
648 |
with PHedgehog(CurrentHedgehog)^ do |
|
649 |
begin |
|
3110 | 650 |
if (Ammo^[CurSlot, CurAmmo].AmmoType = amBee) then |
651 |
DrawRotatedF(sprTargetBee, TargetPoint.X + WorldDx, TargetPoint.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360) |
|
652 |
else |
|
3104 | 653 |
DrawRotatedF(sprTargetP, TargetPoint.X + WorldDx, TargetPoint.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360); |
654 |
end; |
|
655 |
end; |
|
4 | 656 |
{$WARNINGS ON} |
2161
0c8634241fa4
Some work on zooming. Hedgewars are now unplayable.
unc0rr
parents:
2152
diff
changeset
|
657 |
|
3523 | 658 |
// this scale is used to keep the various widgets at the same dimension at all zoom levels |
659 |
SetScale(cDefaultZoomLevel); |
|
2724 | 660 |
|
661 |
||
662 |
// Turn time |
|
2803
1f446fc5c8ec
allow to compile engine as library with HWLIBRARY symbol
koda
parents:
2786
diff
changeset
|
663 |
{$IFDEF IPHONEOS} |
3025 | 664 |
offsetX:= cScreenHeight - 13; |
2803
1f446fc5c8ec
allow to compile engine as library with HWLIBRARY symbol
koda
parents:
2786
diff
changeset
|
665 |
{$ELSE} |
3025 | 666 |
offsetX:= 48; |
2803
1f446fc5c8ec
allow to compile engine as library with HWLIBRARY symbol
koda
parents:
2786
diff
changeset
|
667 |
{$ENDIF} |
3463 | 668 |
offsetY:= cOffsetY; |
4 | 669 |
if TurnTimeLeft <> 0 then |
670 |
begin |
|
671 |
i:= Succ(Pred(TurnTimeLeft) div 1000); |
|
672 |
if i>99 then t:= 112 |
|
673 |
else if i>9 then t:= 96 |
|
674 |
else t:= 80; |
|
3463 | 675 |
DrawSprite(sprFrame, -(cScreenWidth shr 1) + t + offsetY, cScreenHeight - offsetX, 1); |
4 | 676 |
while i > 0 do |
677 |
begin |
|
678 |
dec(t, 32); |
|
3463 | 679 |
DrawSprite(sprBigDigit, -(cScreenWidth shr 1) + t + offsetY, cScreenHeight - offsetX, i mod 10); |
4 | 680 |
i:= i div 10 |
681 |
end; |
|
3463 | 682 |
DrawSprite(sprFrame, -(cScreenWidth shr 1) + t - 4 + offsetY, cScreenHeight - offsetX, 0); |
4 | 683 |
end; |
79 | 684 |
|
2567 | 685 |
{$IFNDEF IPHONEOS} |
2428 | 686 |
// Timetrial |
687 |
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
|
688 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
689 |
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
|
690 |
t:= 272; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
691 |
// right frame |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
692 |
DrawSprite(sprFrame, -cScreenWidth div 2 + t, 8, 1); |
2428 | 693 |
dec(t, 32); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
694 |
// 1 ms |
2428 | 695 |
DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, i mod 10); |
696 |
dec(t, 32); |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
697 |
i:= i div 10; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
698 |
// 10 ms |
2428 | 699 |
DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, i mod 10); |
700 |
dec(t, 32); |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
701 |
i:= i div 10; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
702 |
// 100 ms |
2428 | 703 |
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
|
704 |
dec(t, 16); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
705 |
// Point |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
706 |
DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, 11); |
2428 | 707 |
dec(t, 32); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
708 |
i:= i div 10; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
709 |
// 1 s |
2428 | 710 |
DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, i mod 10); |
711 |
dec(t, 32); |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
712 |
i:= i div 10; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
713 |
// 10s |
2428 | 714 |
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
|
715 |
dec(t, 16); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
716 |
// Point |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
717 |
DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, 10); |
2428 | 718 |
dec(t, 32); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
719 |
i:= i div 6; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
720 |
// 1 m |
2428 | 721 |
DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, i mod 10); |
722 |
dec(t, 32); |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
723 |
i:= i div 10; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
724 |
// 10 m |
2428 | 725 |
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
|
726 |
// left frame |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
727 |
DrawSprite(sprFrame, -cScreenWidth div 2 + t - 4, 8, 0); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
728 |
end; |
2567 | 729 |
{$ENDIF} |
730 |
||
4 | 731 |
// Captions |
2567 | 732 |
{$IFDEF IPHONEOS} |
2803
1f446fc5c8ec
allow to compile engine as library with HWLIBRARY symbol
koda
parents:
2786
diff
changeset
|
733 |
offset:= 40; |
2567 | 734 |
{$ELSE} |
2724 | 735 |
if ((TrainingFlags and tfTimeTrial) <> 0) and (TimeTrialStartTime > 0) then offset:= 48 |
736 |
else offset:= 8; |
|
2567 | 737 |
{$ENDIF} |
2428 | 738 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
739 |
for grp:= Low(TCapGroup) to High(TCapGroup) do |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
740 |
with Captions[grp] do |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
741 |
if Tex <> nil then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
742 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
743 |
DrawCentered(0, offset, Tex); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
744 |
inc(offset, Tex^.h + 2); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
745 |
if EndTime <= RealTicks then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
746 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
747 |
FreeTexture(Tex); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
748 |
Tex:= nil; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
749 |
EndTime:= 0 |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
750 |
end; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
751 |
end; |
4 | 752 |
|
47 | 753 |
// Teams Healths |
547 | 754 |
for t:= 0 to Pred(TeamsCount) do |
755 |
with TeamsArray[t]^ do |
|
47 | 756 |
begin |
2839 | 757 |
highlight:= bShowFinger and (CurrentTeam = TeamsArray[t]) and ((RealTicks mod 1000) < 500); |
758 |
||
2747 | 759 |
if highlight then |
3445 | 760 |
Tint(Clan^.Color); |
2839 | 761 |
|
762 |
// draw name |
|
763 |
DrawTexture(-NameTagTex^.w - 16, cScreenHeight + DrawHealthY, NameTagTex); |
|
764 |
||
765 |
// draw flag |
|
766 |
DrawTexture(-14, cScreenHeight + DrawHealthY, FlagTex); |
|
767 |
||
768 |
// draw health bar |
|
690 | 769 |
r.x:= 0; |
770 |
r.y:= 0; |
|
547 | 771 |
r.w:= 2 + TeamHealthBarWidth; |
764
7513452b1d51
Now game looks almost like it did before switching to OpenGL
unc0rr
parents:
762
diff
changeset
|
772 |
r.h:= HealthTex^.h; |
2747 | 773 |
DrawFromRect(14, cScreenHeight + DrawHealthY, @r, HealthTex); |
690 | 774 |
|
2839 | 775 |
// draw health bar's right border |
83 | 776 |
inc(r.x, cTeamHealthWidth + 2); |
777 |
r.w:= 3; |
|
2839 | 778 |
DrawFromRect(TeamHealthBarWidth + 16, cScreenHeight + DrawHealthY, @r, HealthTex); |
779 |
// if highlighted, draw flag and other contents again to keep their colors |
|
780 |
// this approach should be faster than drawing all borders one by one tinted or not |
|
781 |
if highlight then |
|
782 |
begin |
|
3390 | 783 |
Tint($FF, $FF, $FF, $FF); |
690 | 784 |
|
2839 | 785 |
// draw name |
2747 | 786 |
r.x:= 2; |
787 |
r.y:= 2; |
|
2839 | 788 |
r.w:= NameTagTex^.w - 4; |
789 |
r.h:= NameTagTex^.h - 4; |
|
790 |
DrawFromRect(-NameTagTex^.w - 14, cScreenHeight + DrawHealthY + 2, @r, NameTagTex); |
|
791 |
// draw flag |
|
2747 | 792 |
r.w:= 22; |
793 |
r.h:= 15; |
|
794 |
DrawFromRect(-12, cScreenHeight + DrawHealthY + 2, @r, FlagTex); |
|
2839 | 795 |
// draw health bar |
796 |
r.w:= TeamHealthBarWidth + 1; |
|
797 |
r.h:= HealthTex^.h - 4; |
|
798 |
DrawFromRect(16, cScreenHeight + DrawHealthY + 2, @r, HealthTex); |
|
2747 | 799 |
end; |
47 | 800 |
end; |
801 |
||
5 | 802 |
// Lag alert |
2567 | 803 |
if isInLag then DrawSprite(sprLag, 32 - (cScreenWidth shr 1), 32, (RealTicks shr 7) mod 12); |
4 | 804 |
|
5 | 805 |
// Wind bar |
2567 | 806 |
{$IFDEF IPHONEOS} |
3405 | 807 |
offsetX:= cScreenHeight - 13; |
808 |
offsetY:= (cScreenWidth shr 1) + 74; |
|
2567 | 809 |
{$ELSE} |
3405 | 810 |
offsetX:= 30; |
811 |
offsetY:= 180; |
|
2567 | 812 |
{$ENDIF} |
3405 | 813 |
DrawSprite(sprWindBar, (cScreenWidth shr 1) - offsetY, cScreenHeight - offsetX, 0); |
814 |
if WindBarWidth > 0 then |
|
815 |
begin |
|
816 |
{$WARNINGS OFF} |
|
817 |
r.x:= 8 - (RealTicks shr 6) mod 8; |
|
818 |
{$WARNINGS ON} |
|
819 |
r.y:= 0; |
|
820 |
r.w:= WindBarWidth; |
|
821 |
r.h:= 13; |
|
822 |
DrawSpriteFromRect(sprWindR, r, (cScreenWidth shr 1) - offsetY + 77, cScreenHeight - offsetX + 2, 13, 0); |
|
823 |
end |
|
824 |
else |
|
825 |
if WindBarWidth < 0 then |
|
826 |
begin |
|
827 |
{$WARNINGS OFF} |
|
3407 | 828 |
r.x:= (Longword(WindBarWidth) + RealTicks shr 6) mod 8; |
3405 | 829 |
{$WARNINGS ON} |
830 |
r.y:= 0; |
|
831 |
r.w:= - WindBarWidth; |
|
832 |
r.h:= 13; |
|
833 |
DrawSpriteFromRect(sprWindL, r, (cScreenWidth shr 1) - offsetY + 74 + WindBarWidth, cScreenHeight - offsetX + 2, 13, 0); |
|
834 |
end; |
|
5 | 835 |
|
161 | 836 |
// AmmoMenu |
3434 | 837 |
if (AMxShift < AMWidth) or bShowAmmoMenu then ShowAmmoMenu; |
161 | 838 |
|
2287 | 839 |
// Cursor |
840 |
if isCursorVisible and bShowAmmoMenu then |
|
841 |
DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8); |
|
942 | 842 |
|
2287 | 843 |
DrawChat; |
4 | 844 |
|
2567 | 845 |
if fastUntilLag then DrawCentered(0, (cScreenHeight shr 1), SyncTexture); |
846 |
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
|
847 |
|
3304 | 848 |
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
|
849 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
850 |
if missionTimer > 0 then dec(missionTimer, Lag); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
851 |
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
|
852 |
if missionTex <> nil then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
853 |
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
|
854 |
end; |
2786 | 855 |
|
2724 | 856 |
// fps |
857 |
{$IFDEF IPHONEOS} |
|
3463 | 858 |
offsetX:= 8; |
2724 | 859 |
{$ELSE} |
3463 | 860 |
offsetX:= 10; |
2724 | 861 |
{$ENDIF} |
3463 | 862 |
offsetY:= cOffsetY; |
4 | 863 |
inc(Frames); |
2850
f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset
|
864 |
|
f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset
|
865 |
if cShowFPS or (GameType = gmtDemo) then inc(CountTicks, Lag); |
2851 | 866 |
if (GameType = gmtDemo) and (CountTicks >= 1000) then |
2850
f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset
|
867 |
begin |
3407 | 868 |
i:=GameTicks div 1000; |
869 |
t:= i mod 60; |
|
870 |
s:= inttostr(t); |
|
871 |
if t < 10 then s:= '0' + s; |
|
872 |
i:= i div 60; |
|
873 |
t:= i mod 60; |
|
874 |
s:= inttostr(t) + ':' + s; |
|
875 |
if t < 10 then s:= '0' + s; |
|
876 |
s:= inttostr(i div 60) + ':' + s; |
|
877 |
||
3513
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3483
diff
changeset
|
878 |
if timeTexture <> nil then |
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3483
diff
changeset
|
879 |
FreeTexture(timeTexture); |
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3483
diff
changeset
|
880 |
timeTexture:= nil; |
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3483
diff
changeset
|
881 |
|
2850
f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset
|
882 |
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
|
883 |
tmpSurface:= doSurfaceConversion(tmpSurface); |
f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset
|
884 |
timeTexture:= Surface2Tex(tmpSurface, false); |
f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset
|
885 |
SDL_FreeSurface(tmpSurface) |
f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset
|
886 |
end; |
f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset
|
887 |
|
f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset
|
888 |
if timeTexture <> nil then |
3463 | 889 |
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
|
890 |
|
298
112e61bd2cc2
Render FPS value to its own surface one time a second
unc0rr
parents:
295
diff
changeset
|
891 |
if cShowFPS then |
4 | 892 |
begin |
298
112e61bd2cc2
Render FPS value to its own surface one time a second
unc0rr
parents:
295
diff
changeset
|
893 |
if CountTicks >= 1000 then |
112e61bd2cc2
Render FPS value to its own surface one time a second
unc0rr
parents:
295
diff
changeset
|
894 |
begin |
112e61bd2cc2
Render FPS value to its own surface one time a second
unc0rr
parents:
295
diff
changeset
|
895 |
FPS:= Frames; |
112e61bd2cc2
Render FPS value to its own surface one time a second
unc0rr
parents:
295
diff
changeset
|
896 |
Frames:= 0; |
112e61bd2cc2
Render FPS value to its own surface one time a second
unc0rr
parents:
295
diff
changeset
|
897 |
CountTicks:= 0; |
112e61bd2cc2
Render FPS value to its own surface one time a second
unc0rr
parents:
295
diff
changeset
|
898 |
s:= inttostr(FPS) + ' fps'; |
3513
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3483
diff
changeset
|
899 |
if fpsTexture <> nil then |
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3483
diff
changeset
|
900 |
FreeTexture(fpsTexture); |
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3483
diff
changeset
|
901 |
fpsTexture:= nil; |
2665
50b4e544c163
complete transition of longword->sdl_color for TTF bindings
koda
parents:
2630
diff
changeset
|
902 |
tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), cWhiteColorChannels); |
2670 | 903 |
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
|
904 |
fpsTexture:= Surface2Tex(tmpSurface, false); |
759 | 905 |
SDL_FreeSurface(tmpSurface) |
298
112e61bd2cc2
Render FPS value to its own surface one time a second
unc0rr
parents:
295
diff
changeset
|
906 |
end; |
759 | 907 |
if fpsTexture <> nil then |
3463 | 908 |
DrawTexture((cScreenWidth shr 1) - 60 - offsetY, offsetX, fpsTexture); |
4 | 909 |
end; |
174 | 910 |
|
2850
f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset
|
911 |
if CountTicks >= 1000 then CountTicks:= 0; |
f6f8db825ce7
A little clock for convenience in finding things in demos
nemo
parents:
2839
diff
changeset
|
912 |
|
2724 | 913 |
// lag warning (?) |
174 | 914 |
inc(SoundTimerTicks, Lag); |
915 |
if SoundTimerTicks >= 50 then |
|
916 |
begin |
|
917 |
SoundTimerTicks:= 0; |
|
918 |
if cVolumeDelta <> 0 then |
|
919 |
begin |
|
920 |
str(ChangeVolume(cVolumeDelta), s); |
|
2619 | 921 |
AddCaption(Format(trmsg[sidVolume], s), cWhiteColor, capgrpVolume) |
174 | 922 |
end |
756 | 923 |
end; |
924 |
||
2724 | 925 |
if GameState = gsConfirm then |
3025 | 926 |
DrawCentered(0, (cScreenHeight shr 1), ConfirmTexture); |
2161
0c8634241fa4
Some work on zooming. Hedgewars are now unplayable.
unc0rr
parents:
2152
diff
changeset
|
927 |
|
3107 | 928 |
if ScreenFade <> sfNone then |
929 |
begin |
|
930 |
if not isFirstFrame then |
|
931 |
case ScreenFade of |
|
932 |
sfToBlack, sfToWhite: if ScreenFadeValue + Lag * ScreenFadeSpeed < sfMax then |
|
933 |
inc(ScreenFadeValue, Lag * ScreenFadeSpeed) |
|
934 |
else |
|
3123 | 935 |
ScreenFadeValue:= sfMax; |
3107 | 936 |
sfFromBlack, sfFromWhite: if ScreenFadeValue - Lag * ScreenFadeSpeed > 0 then |
937 |
dec(ScreenFadeValue, Lag * ScreenFadeSpeed) |
|
938 |
else |
|
3123 | 939 |
ScreenFadeValue:= 0; |
3107 | 940 |
end; |
941 |
if ScreenFade <> sfNone then |
|
942 |
begin |
|
943 |
case ScreenFade of |
|
3376 | 944 |
sfToBlack, sfFromBlack: Tint(0, 0, 0, ScreenFadeValue * 255 div 1000); |
945 |
sfToWhite, sfFromWhite: Tint($FF, $FF, $FF, ScreenFadeValue * 255 div 1000); |
|
3107 | 946 |
end; |
3113 | 947 |
|
948 |
VertexBuffer[0].X:= -cScreenWidth; |
|
949 |
VertexBuffer[0].Y:= cScreenHeight; |
|
950 |
VertexBuffer[1].X:= -cScreenWidth; |
|
951 |
VertexBuffer[1].Y:= 0; |
|
952 |
VertexBuffer[2].X:= cScreenWidth; |
|
953 |
VertexBuffer[2].Y:= 0; |
|
954 |
VertexBuffer[3].X:= cScreenWidth; |
|
955 |
VertexBuffer[3].Y:= cScreenHeight; |
|
956 |
||
3376 | 957 |
glDisable(GL_TEXTURE_2D); |
3113 | 958 |
glEnableClientState(GL_VERTEX_ARRAY); |
959 |
glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); |
|
960 |
glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); |
|
961 |
glDisableClientState(GL_VERTEX_ARRAY); |
|
3376 | 962 |
glEnable(GL_TEXTURE_2D); |
3390 | 963 |
Tint($FF, $FF, $FF, $FF); |
3123 | 964 |
if not isFirstFrame and ((ScreenFadeValue = 0) or (ScreenFadeValue = sfMax)) then ScreenFade:= sfNone |
3107 | 965 |
end |
966 |
end; |
|
967 |
||
3123 | 968 |
SetScale(zoom); |
969 |
||
970 |
// Cursor |
|
971 |
if isCursorVisible then |
|
972 |
begin |
|
973 |
if not bShowAmmoMenu then |
|
3204 | 974 |
begin |
3123 | 975 |
with CurrentHedgehog^ do |
3582
4debed8656d7
fix segfault on HH-gear being 0 (e.g. after drowning) in cursor/target selection mode, thanks "ivze" for the heads-up!
sheepluva
parents:
3580
diff
changeset
|
976 |
if (Gear <> nil) and ((Gear^.State and gstHHChooseTarget) <> 0) then |
3123 | 977 |
begin |
978 |
i:= Ammo^[CurSlot, CurAmmo].Pos; |
|
979 |
with Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType] do |
|
980 |
if PosCount > 1 then |
|
3204 | 981 |
DrawSprite(PosSprite, CursorPoint.X - (SpritesData[PosSprite].Width shr 1), cScreenHeight - CursorPoint.Y - (SpritesData[PosSprite].Height shr 1),i); |
3123 | 982 |
end; |
3204 | 983 |
DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8) |
984 |
end |
|
3123 | 985 |
end; |
3107 | 986 |
isFirstFrame:= false |
4 | 987 |
end; |
988 |
||
2905 | 989 |
procedure AddCaption(s: shortstring; Color: Longword; Group: TCapGroup); |
4 | 990 |
begin |
2142 | 991 |
//if Group in [capgrpGameState] then WriteLnToConsole(s); |
3513
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3483
diff
changeset
|
992 |
if Captions[Group].Tex <> nil then |
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3483
diff
changeset
|
993 |
FreeTexture(Captions[Group].Tex); |
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3483
diff
changeset
|
994 |
Captions[Group].Tex:= nil; |
2142 | 995 |
|
3513
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3483
diff
changeset
|
996 |
Captions[Group].Tex:= RenderStringTex(s, Color, fntBig); |
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3483
diff
changeset
|
997 |
|
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3483
diff
changeset
|
998 |
case Group of |
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3483
diff
changeset
|
999 |
capgrpGameState: Captions[Group].EndTime:= RealTicks + 2200 |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1000 |
else |
3513
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3483
diff
changeset
|
1001 |
Captions[Group].EndTime:= RealTicks + 1400 + LongWord(Captions[Group].Tex^.w) * 3; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1002 |
end; |
4 | 1003 |
end; |
1004 |
||
79 | 1005 |
procedure MoveCamera; |
4 | 1006 |
const PrevSentPointTime: LongWord = 0; |
2428 | 1007 |
var EdgesDist, wdy: LongInt; |
4 | 1008 |
begin |
3551 | 1009 |
{$IFNDEF IPHONEOS} |
2970
011075f93746
Let's try this too (override following remote if in ammo menu)
nemo
parents:
2959
diff
changeset
|
1010 |
if (not (CurrentTeam^.ExtDriven and isCursorVisible and not bShowAmmoMenu)) and cHasFocus then |
3551 | 1011 |
begin |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1012 |
SDL_GetMouseState(@CursorPoint.X, @CursorPoint.Y); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1013 |
CursorPoint.X:= CursorPoint.X - (cScreenWidth shr 1); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1014 |
CursorPoint.Y:= cScreenHeight - CursorPoint.Y; |
3551 | 1015 |
end; |
1016 |
{$ENDIF} |
|
678 | 1017 |
|
2762
2fbc8d35eb52
Mode to place hogs at start of game. Will probably need a bit more testing.
nemo
parents:
2747
diff
changeset
|
1018 |
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
|
1019 |
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
|
1020 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1021 |
FollowGear:= nil; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1022 |
prevPoint:= CursorPoint; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1023 |
exit |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1024 |
end |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1025 |
else begin |
2970
011075f93746
Let's try this too (override following remote if in ammo menu)
nemo
parents:
2959
diff
changeset
|
1026 |
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
|
1027 |
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
|
1028 |
end; |
4 | 1029 |
|
2375 | 1030 |
wdy:= trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 - cWaterLine - cVisibleWater; |
1031 |
if WorldDy < wdy then WorldDy:= wdy; |
|
1032 |
||
2197 | 1033 |
if ((CursorPoint.X = prevPoint.X) and (CursorPoint.Y = prevpoint.Y)) then exit; |
4 | 1034 |
|
3434 | 1035 |
if AMxShift < AMWidth then |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1036 |
begin |
3463 | 1037 |
{$IFDEF IPHONEOS} |
3434 | 1038 |
if CursorPoint.X < cScreenWidth div 2 + AMxShift - AMWidth then CursorPoint.X:= cScreenWidth div 2 + AMxShift - AMWidth; |
1039 |
if CursorPoint.X > cScreenWidth div 2 + AMxShift - AMxOffset then CursorPoint.X:= cScreenWidth div 2 + AMxShift - AMxOffset; |
|
1040 |
if CursorPoint.Y < cScreenHeight - AMyOffset - SlotsNum * AMSlotSize then CursorPoint.Y:= cScreenHeight - AMyOffset - SlotsNum * AMSlotSize; |
|
1041 |
if CursorPoint.Y > cScreenHeight - AMyOffset then CursorPoint.Y:= cScreenHeight - AMyOffset; |
|
3463 | 1042 |
{$ELSE} |
3434 | 1043 |
if CursorPoint.X < cScreenWidth div 2 + AMxShift - AMWidth + AMSlotSize then CursorPoint.X:= cScreenWidth div 2 + AMxShift - AMWidth + AMSlotSize; |
1044 |
if CursorPoint.X > cScreenWidth div 2 + AMxShift - AMxOffset then CursorPoint.X:= cScreenWidth div 2 + AMxShift - AMxOffset; |
|
1045 |
if CursorPoint.Y > AMyOffset + (SlotsNum + 1) * AMSlotSize then CursorPoint.Y:= AMyOffset + (SlotsNum + 1) * AMSlotSize; |
|
1046 |
if CursorPoint.Y < AMyOffset + AMSlotSize then CursorPoint.Y:= AMyOffset + AMSlotSize; |
|
3463 | 1047 |
{$ENDIF} |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1048 |
prevPoint:= CursorPoint; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1049 |
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
|
1050 |
exit |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1051 |
end; |
162 | 1052 |
|
4 | 1053 |
if isCursorVisible then |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1054 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1055 |
if (not CurrentTeam^.ExtDriven) and (GameTicks >= PrevSentPointTime + cSendCursorPosTime) then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1056 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1057 |
SendIPCXY('P', CursorPoint.X - WorldDx, cScreenHeight - CursorPoint.Y - WorldDy); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1058 |
PrevSentPointTime:= GameTicks |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1059 |
end; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1060 |
end; |
351 | 1061 |
|
4 | 1062 |
if isCursorVisible or (FollowGear <> nil) then |
1063 |
begin |
|
284 | 1064 |
if isCursorVisible then EdgesDist:= cCursorEdgesDist |
1065 |
else EdgesDist:= cGearScrEdgesDist; |
|
2197 | 1066 |
if CursorPoint.X < - cScreenWidth div 2 + EdgesDist then |
4 | 1067 |
begin |
2197 | 1068 |
WorldDx:= WorldDx - CursorPoint.X - cScreenWidth div 2 + EdgesDist; |
1069 |
CursorPoint.X:= - cScreenWidth div 2 + EdgesDist |
|
4 | 1070 |
end else |
2197 | 1071 |
if CursorPoint.X > cScreenWidth div 2 - EdgesDist then |
4 | 1072 |
begin |
2197 | 1073 |
WorldDx:= WorldDx - CursorPoint.X + cScreenWidth div 2 - EdgesDist; |
2198 | 1074 |
CursorPoint.X:= cScreenWidth div 2 - EdgesDist |
4 | 1075 |
end; |
284 | 1076 |
if CursorPoint.Y < EdgesDist then |
4 | 1077 |
begin |
2197 | 1078 |
WorldDy:= WorldDy + CursorPoint.Y - EdgesDist; |
284 | 1079 |
CursorPoint.Y:= EdgesDist |
4 | 1080 |
end else |
284 | 1081 |
if CursorPoint.Y > cScreenHeight - EdgesDist then |
4 | 1082 |
begin |
2197 | 1083 |
WorldDy:= WorldDy + CursorPoint.Y - cScreenHeight + EdgesDist; |
284 | 1084 |
CursorPoint.Y:= cScreenHeight - EdgesDist |
4 | 1085 |
end; |
1086 |
end else |
|
308 | 1087 |
if cHasFocus then |
1088 |
begin |
|
70 | 1089 |
WorldDx:= WorldDx - CursorPoint.X + prevPoint.X; |
2197 | 1090 |
WorldDy:= WorldDy + CursorPoint.Y - prevPoint.Y; |
2162 | 1091 |
CursorPoint.X:= 0; |
1092 |
CursorPoint.Y:= cScreenHeight div 2; |
|
308 | 1093 |
end; |
351 | 1094 |
|
4 | 1095 |
prevPoint:= CursorPoint; |
2567 | 1096 |
if cHasFocus then SDL_WarpMouse(CursorPoint.X + (cScreenWidth shr 1), cScreenHeight - CursorPoint.Y); |
1760 | 1097 |
if WorldDy > LAND_HEIGHT + 1024 then WorldDy:= LAND_HEIGHT + 1024; |
2375 | 1098 |
if WorldDy < wdy then WorldDy:= wdy; |
2426 | 1099 |
if WorldDx < - LAND_WIDTH - 1024 then WorldDx:= - LAND_WIDTH - 1024; |
1100 |
if WorldDx > 1024 then WorldDx:= 1024; |
|
4 | 1101 |
end; |
1102 |
||
2905 | 1103 |
procedure ShowMission(caption, subcaption, text: ansistring; icon, time : LongInt); |
2786 | 1104 |
var r: TSDL_Rect; |
1105 |
begin |
|
1106 |
r.w:= 32; |
|
1107 |
r.h:= 32; |
|
1108 |
||
1109 |
if time = 0 then time:= 5000; |
|
1110 |
missionTimer:= time; |
|
3513
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3483
diff
changeset
|
1111 |
if missionTex <> nil then |
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3483
diff
changeset
|
1112 |
FreeTexture(missionTex); |
f589230fa21b
now it's possible to select the scheme file in the ifrontendfix a type about loading an image (iphone file system IS case senstive)
koda
parents:
3483
diff
changeset
|
1113 |
missionTex:= nil; |
2786 | 1114 |
|
1115 |
if icon > -1 then |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1116 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1117 |
r.x:= 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1118 |
r.y:= icon * 32; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1119 |
missionTex:= RenderHelpWindow(caption, subcaption, text, '', 0, MissionIcons, @r) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1120 |
end |
2786 | 1121 |
else |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1122 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1123 |
r.x:= ((-icon - 1) shr 5) * 32; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1124 |
r.y:= ((-icon - 1) mod 32) * 32; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1125 |
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
|
1126 |
end; |
2786 | 1127 |
end; |
1128 |
||
1129 |
procedure HideMission; |
|
1130 |
begin |
|
3045 | 1131 |
missionTimer:= 0; |
1132 |
if missionTex <> nil then FreeTexture(missionTex); |
|
2786 | 1133 |
end; |
1134 |
||
3032 | 1135 |
procedure ShakeCamera(amount: LongWord); |
1136 |
begin |
|
1137 |
amount:= max(1, amount); |
|
1138 |
WorldDx:= WorldDx - amount + LongInt(getRandom(1 + amount * 2)); |
|
1139 |
WorldDy:= WorldDy - amount + LongInt(getRandom(1 + amount * 2)); |
|
1140 |
end; |
|
1141 |
||
3038 | 1142 |
procedure initModule; |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2682
diff
changeset
|
1143 |
begin |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1144 |
fpsTexture:= nil; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1145 |
FollowGear:= nil; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1146 |
WindBarWidth:= 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1147 |
bShowAmmoMenu:= false; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1148 |
bSelected:= false; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1149 |
bShowFinger:= false; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1150 |
Frames:= 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1151 |
WorldDx:= -512; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1152 |
WorldDy:= -256; |
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2713
diff
changeset
|
1153 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1154 |
FPS:= 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1155 |
CountTicks:= 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1156 |
SoundTimerTicks:= 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1157 |
prevPoint.X:= 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1158 |
prevPoint.Y:= 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1159 |
missionTimer:= 0; |
3240 | 1160 |
missionTex:= nil; |
3463 | 1161 |
cOffsetY:= 0; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1162 |
|
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2931
diff
changeset
|
1163 |
FillChar(Captions, sizeof(Captions), 0) |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2682
diff
changeset
|
1164 |
end; |
4 | 1165 |
|
3038 | 1166 |
procedure freeModule; |
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2713
diff
changeset
|
1167 |
begin |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2713
diff
changeset
|
1168 |
end; |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2713
diff
changeset
|
1169 |
|
4 | 1170 |
end. |