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