author | unc0rr |
Fri, 20 Feb 2009 14:12:16 +0000 | |
changeset 1812 | 3d4692e825e7 |
parent 1807 | 795f97007833 |
child 1825 | c929f9111141 |
permissions | -rw-r--r-- |
4 | 1 |
(* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
1689 | 3 |
* Copyright (c) 2004-2009 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 |
||
19 |
unit uWorld; |
|
20 |
interface |
|
351 | 21 |
uses SDLh, uGears, uConsts, uFloat; |
4 | 22 |
{$INCLUDE options.inc} |
371 | 23 |
const WorldDx: LongInt = -512; |
24 |
WorldDy: LongInt = -256; |
|
4 | 25 |
|
26 |
procedure InitWorld; |
|
956 | 27 |
procedure DrawWorld(Lag: LongInt); |
108 | 28 |
procedure AddCaption(s: string; Color: Longword; Group: TCapGroup); |
4 | 29 |
|
30 |
{$IFDEF COUNTTICKS} |
|
31 |
var cntTicks: LongWord; |
|
32 |
{$ENDIF} |
|
33 |
var FollowGear: PGear = nil; |
|
1256 | 34 |
WindBarWidth: LongInt = 0; |
35 |
bShowAmmoMenu: boolean = false; |
|
36 |
bSelected: boolean = false; |
|
37 |
bShowFinger: boolean = false; |
|
38 |
Frames: Longword = 0; |
|
39 |
WaterColor, DeepWaterColor: TSDL_Color; |
|
4 | 40 |
|
41 |
implementation |
|
803 | 42 |
uses uStore, uMisc, uTeams, uIO, uConsole, uKeys, uLocale, uSound, GL, |
1806 | 43 |
uAmmos, uVisualGears, uChat, uLandTexture; |
1807 | 44 |
|
564 | 45 |
const FPS: Longword = 0; |
4 | 46 |
CountTicks: Longword = 0; |
174 | 47 |
SoundTimerTicks: Longword = 0; |
4 | 48 |
prevPoint: TPoint = (X: 0; Y: 0); |
161 | 49 |
|
4 | 50 |
type TCaptionStr = record |
762 | 51 |
Tex: PTexture; |
4 | 52 |
EndTime: LongWord; |
53 |
end; |
|
54 |
||
371 | 55 |
var cWaterSprCount: LongInt; |
1256 | 56 |
Captions: array[TCapGroup] of TCaptionStr; |
57 |
AMxShift, SlotsNum: LongInt; |
|
58 |
tmpSurface: PSDL_Surface; |
|
59 |
fpsTexture: PTexture = nil; |
|
4 | 60 |
|
61 |
procedure InitWorld; |
|
62 |
begin |
|
74 | 63 |
cWaterSprCount:= 1 + cScreenWidth div (SpritesData[sprWater].Width); |
284 | 64 |
cGearScrEdgesDist:= Min(cScreenWidth div 2 - 100, cScreenHeight div 2 - 50); |
74 | 65 |
SDL_WarpMouse(cScreenWidth div 2, cScreenHeight div 2); |
66 |
prevPoint.X:= cScreenWidth div 2; |
|
67 |
prevPoint.Y:= cScreenHeight div 2; |
|
1760 | 68 |
WorldDx:= - (LAND_WIDTH div 2) + cScreenWidth div 2; |
69 |
WorldDy:= - (LAND_HEIGHT div 2) + cScreenHeight div 2; |
|
1120 | 70 |
AMxShift:= 210 |
161 | 71 |
end; |
72 |
||
956 | 73 |
procedure ShowAmmoMenu; |
161 | 74 |
const MENUSPEED = 15; |
961
a9a349b2b3fa
Use turnsleft sprites to indicate turns left to activate ammo
unc0rr
parents:
956
diff
changeset
|
75 |
var x, y, i, t, l: LongInt; |
371 | 76 |
Slot, Pos: LongInt; |
161 | 77 |
begin |
78 |
if (TurnTimeLeft = 0) or KbdKeyPressed then bShowAmmoMenu:= false; |
|
165 | 79 |
if bShowAmmoMenu then |
80 |
begin |
|
1120 | 81 |
if AMxShift = 210 then prevPoint.X:= 0; |
1812 | 82 |
if cReducedQuality then |
83 |
AMxShift:= 0 |
|
84 |
else |
|
85 |
if AMxShift > 0 then dec(AMxShift, MENUSPEED); |
|
165 | 86 |
end else |
87 |
begin |
|
1120 | 88 |
if AMxShift = 0 then |
165 | 89 |
begin |
90 |
CursorPoint.X:= cScreenWidth div 2; |
|
91 |
CursorPoint.Y:= cScreenHeight div 2; |
|
92 |
prevPoint:= CursorPoint; |
|
93 |
SDL_WarpMouse(CursorPoint.X, CursorPoint.Y) |
|
94 |
end; |
|
1812 | 95 |
if cReducedQuality then |
96 |
AMxShift:= 210 |
|
97 |
else |
|
98 |
if AMxShift < 210 then inc(AMxShift, MENUSPEED); |
|
165 | 99 |
end; |
161 | 100 |
|
101 |
if CurrentTeam = nil then exit; |
|
162 | 102 |
Slot:= 0; |
103 |
Pos:= -1; |
|
602 | 104 |
with CurrentHedgehog^ do |
1529
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
105 |
begin |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
106 |
if Ammo = nil then exit; |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
107 |
SlotsNum:= 0; |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
108 |
x:= cScreenWidth - 210 + AMxShift; |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
109 |
y:= cScreenHeight - 40; |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
110 |
dec(y); |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
111 |
DrawSprite(sprAMBorders, x, y, 0); |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
112 |
dec(y); |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
113 |
DrawSprite(sprAMBorders, x, y, 1); |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
114 |
dec(y, 33); |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
115 |
DrawSprite(sprAMSlotName, x, y, 0); |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
116 |
for i:= cMaxSlotIndex downto 0 do |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
117 |
if Ammo^[i, 0].Count > 0 then |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
118 |
begin |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
119 |
if (CursorPoint.Y >= y - 33) and (CursorPoint.Y < y) then Slot:= i; |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
120 |
dec(y, 33); |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
121 |
inc(SlotsNum); |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
122 |
DrawSprite(sprAMSlot, x, y, 0); |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
123 |
DrawSprite(sprAMSlotKeys, x + 2, y + 1, i); |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
124 |
t:= 0; |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
125 |
while (t <= cMaxSlotAmmoIndex) and (Ammo^[i, t].Count > 0) do |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
126 |
begin |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
127 |
l:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber; |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
128 |
|
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
129 |
if l >= 0 then |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
130 |
begin |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
131 |
DrawSprite(sprAMAmmosBW, x + t * 33 + 35, y + 1, LongInt(Ammo^[i, t].AmmoType)); |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
132 |
DrawSprite(sprTurnsLeft, x + t * 33 + 51, y + 17, l); |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
133 |
end else |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
134 |
DrawSprite(sprAMAmmos, x + t * 33 + 35, y + 1, LongInt(Ammo^[i, t].AmmoType)); |
961
a9a349b2b3fa
Use turnsleft sprites to indicate turns left to activate ammo
unc0rr
parents:
956
diff
changeset
|
135 |
|
1529
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
136 |
if (Slot = i) |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
137 |
and (CursorPoint.X >= x + t * 33 + 35) |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
138 |
and (CursorPoint.X < x + t * 33 + 68) then |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
139 |
begin |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
140 |
if (l < 0) then DrawSprite(sprAMSelection, x + t * 33 + 35, y + 1, 0); |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
141 |
Pos:= t; |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
142 |
end; |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
143 |
inc(t) |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
144 |
end |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
145 |
end; |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
146 |
dec(y, 1); |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
147 |
DrawSprite(sprAMBorders, x, y, 0); |
961
a9a349b2b3fa
Use turnsleft sprites to indicate turns left to activate ammo
unc0rr
parents:
956
diff
changeset
|
148 |
|
1529
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
149 |
if (Pos >= 0) then |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
150 |
if Ammo^[Slot, Pos].Count > 0 then |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
151 |
begin |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
152 |
DrawTexture(cScreenWidth - 200 + AMxShift, cScreenHeight - 68, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex); |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
153 |
|
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
154 |
if Ammo^[Slot, Pos].Count < AMMO_INFINITE then |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
155 |
DrawTexture(cScreenWidth + AMxShift - 35, cScreenHeight - 68, CountTexz[Ammo^[Slot, Pos].Count]); |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
156 |
|
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
157 |
if bSelected and (Ammoz[Ammo^[Slot, Pos].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber < 0) then |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
158 |
begin |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
159 |
bShowAmmoMenu:= false; |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
160 |
SetWeapon(Ammo^[Slot, Pos].AmmoType); |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
161 |
bSelected:= false; |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
162 |
exit |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
163 |
end; |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
164 |
end; |
3bc916b419cd
Don't hide ammo menu when user clicks on not yet available weapon
unc0rr
parents:
1439
diff
changeset
|
165 |
end; |
162 | 166 |
|
167 |
bSelected:= false; |
|
1120 | 168 |
if AMxShift = 0 then DrawSprite(sprArrow, CursorPoint.X, CursorPoint.Y, (RealTicks shr 6) mod 8) |
4 | 169 |
end; |
170 |
||
162 | 171 |
procedure MoveCamera; forward; |
172 |
||
956 | 173 |
procedure DrawWorld(Lag: LongInt); |
371 | 174 |
var i, t: LongInt; |
4 | 175 |
r: TSDL_Rect; |
107 | 176 |
tdx, tdy: Double; |
175 | 177 |
grp: TCapGroup; |
174 | 178 |
s: string[15]; |
80 | 179 |
|
371 | 180 |
procedure DrawRepeated(spr: TSprite; Shift: LongInt); |
181 |
var i, w: LongInt; |
|
80 | 182 |
begin |
183 |
w:= SpritesData[spr].Width; |
|
82 | 184 |
i:= Shift mod w; |
80 | 185 |
if i > 0 then dec(i, w); |
186 |
repeat |
|
1760 | 187 |
DrawSprite(spr, i, WorldDy + LAND_HEIGHT - SpritesData[spr].Height, 0); |
80 | 188 |
inc(i, w) |
189 |
until i > cScreenWidth |
|
190 |
end; |
|
191 |
||
4 | 192 |
begin |
770 | 193 |
// Sky |
756 | 194 |
glClear(GL_COLOR_BUFFER_BIT); |
195 |
glEnable(GL_BLEND); |
|
775 | 196 |
glEnable(GL_TEXTURE_2D); |
777 | 197 |
//glPushMatrix; |
198 |
//glScalef(1.0, 1.0, 1.0); |
|
756 | 199 |
|
281
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
244
diff
changeset
|
200 |
if not isPaused then MoveCamera; |
162 | 201 |
|
1812 | 202 |
if not cReducedQuality then |
203 |
begin |
|
204 |
// background |
|
205 |
DrawRepeated(sprSky, WorldDx * 3 div 8); |
|
206 |
DrawRepeated(sprHorizont, WorldDx * 3 div 5); |
|
4 | 207 |
|
1812 | 208 |
DrawVisualGears(0); |
803 | 209 |
|
1812 | 210 |
// Waves |
211 |
{$WARNINGS OFF} |
|
212 |
for i:= -1 to cWaterSprCount do DrawSprite(sprWater, i * 125 + ((WorldDx + (RealTicks shr 6) ) mod 125), cWaterLine + WorldDy - 64, 0); |
|
213 |
for i:= -1 to cWaterSprCount do DrawSprite(sprWater, i * 125 + ((WorldDx - (RealTicks shr 6) + 100) mod 125), cWaterLine + WorldDy - 48, 0); |
|
214 |
{$WARNINGS ON} |
|
215 |
end; |
|
216 |
||
4 | 217 |
|
762 | 218 |
DrawLand(WorldDx, WorldDy); |
5 | 219 |
// Water |
4 | 220 |
r.y:= WorldDy + cWaterLine + 32; |
221 |
if r.y < cScreenHeight then |
|
222 |
begin |
|
23 | 223 |
if r.y < 0 then r.y:= 0; |
780 | 224 |
|
225 |
glDisable(GL_TEXTURE_2D); |
|
226 |
glBegin(GL_QUADS); |
|
1256 | 227 |
glColor3ub(WaterColor.r, WaterColor.g, WaterColor. b); // water color |
780 | 228 |
glVertex2i(0, r.y); |
229 |
glVertex2i(cScreenWidth, r.y); |
|
1256 | 230 |
glColor3ub(DeepWaterColor.r, DeepWaterColor.g, DeepWaterColor. b); // deep water color |
780 | 231 |
glVertex2i(cScreenWidth, cScreenHeight); |
232 |
glVertex2i(0, cScreenHeight); |
|
233 |
glEnd(); |
|
234 |
glColor4f(1, 1, 1, 1); // disable coloring |
|
235 |
glEnable(GL_TEXTURE_2D) |
|
4 | 236 |
end; |
237 |
||
1660 | 238 |
// Attack bar |
239 |
if CurrentTeam <> nil then |
|
240 |
case AttackBar of |
|
241 |
(* 1: begin |
|
242 |
r:= StuffPoz[sPowerBar]; |
|
243 |
{$WARNINGS OFF} |
|
244 |
r.w:= (CurrentHedgehog^.Gear^.Power * 256) div cPowerDivisor; |
|
245 |
{$WARNINGS ON} |
|
246 |
DrawSpriteFromRect(r, cScreenWidth - 272, cScreenHeight - 48, 16, 0, Surface); |
|
247 |
end;*) |
|
248 |
2: with CurrentHedgehog^ do |
|
249 |
begin |
|
250 |
tdx:= hwSign(Gear^.dX) * Sin(Gear^.Angle * Pi / cMaxAngle); |
|
251 |
tdy:= - Cos(Gear^.Angle * Pi / cMaxAngle); |
|
252 |
for i:= (Gear^.Power * 24) div cPowerDivisor downto 0 do |
|
253 |
DrawSprite(sprPower, |
|
254 |
hwRound(Gear^.X) + system.round(WorldDx + tdx * (24 + i * 2)) - 16, |
|
255 |
hwRound(Gear^.Y) + system.round(WorldDy + tdy * (24 + i * 2)) - 12, |
|
256 |
i) |
|
257 |
end |
|
258 |
end; |
|
259 |
||
956 | 260 |
DrawGears; |
4 | 261 |
|
1812 | 262 |
if not cReducedQuality then DrawVisualGears(1); |
1045 | 263 |
|
5 | 264 |
// Waves |
4 | 265 |
{$WARNINGS OFF} |
1439 | 266 |
for i:= -1 to cWaterSprCount do DrawSprite(sprWater, i * 125 + ((WorldDx + (RealTicks shr 6) + 25) mod 125), cWaterLine + WorldDy - 32, 0); |
267 |
for i:= -1 to cWaterSprCount do DrawSprite(sprWater, i * 125 + ((WorldDx - (RealTicks shr 6) + 50) mod 125), cWaterLine + WorldDy - 16, 0); |
|
268 |
for i:= -1 to cWaterSprCount do DrawSprite(sprWater, i * 125 + ((WorldDx + (RealTicks shr 6) + 75) mod 125), cWaterLine + WorldDy , 0); |
|
4 | 269 |
{$WARNINGS ON} |
79 | 270 |
// Turn time |
4 | 271 |
if TurnTimeLeft <> 0 then |
272 |
begin |
|
273 |
i:= Succ(Pred(TurnTimeLeft) div 1000); |
|
274 |
if i>99 then t:= 112 |
|
275 |
else if i>9 then t:= 96 |
|
276 |
else t:= 80; |
|
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
803
diff
changeset
|
277 |
DrawSprite(sprFrame, t, cScreenHeight - 48, 1); |
4 | 278 |
while i > 0 do |
279 |
begin |
|
280 |
dec(t, 32); |
|
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
803
diff
changeset
|
281 |
DrawSprite(sprBigDigit, t, cScreenHeight - 48, i mod 10); |
4 | 282 |
i:= i div 10 |
283 |
end; |
|
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
803
diff
changeset
|
284 |
DrawSprite(sprFrame, t - 4, cScreenHeight - 48, 0); |
4 | 285 |
end; |
79 | 286 |
|
5 | 287 |
// Target |
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
803
diff
changeset
|
288 |
if TargetPoint.X <> NoPointX then DrawSprite(sprTargetP, TargetPoint.X + WorldDx - 16, TargetPoint.Y + WorldDy - 16, 0); |
4 | 289 |
|
777 | 290 |
//glPopMatrix; |
291 |
||
4 | 292 |
// Captions |
175 | 293 |
i:= 8; |
294 |
for grp:= Low(TCapGroup) to High(TCapGroup) do |
|
295 |
with Captions[grp] do |
|
762 | 296 |
if Tex <> nil then |
175 | 297 |
begin |
988 | 298 |
DrawCentered(cScreenWidth div 2, i, Tex); |
762 | 299 |
inc(i, Tex^.h + 2); |
564 | 300 |
if EndTime <= RealTicks then |
175 | 301 |
begin |
762 | 302 |
FreeTexture(Tex); |
303 |
Tex:= nil; |
|
175 | 304 |
EndTime:= 0 |
305 |
end |
|
306 |
end; |
|
4 | 307 |
|
47 | 308 |
// Teams Healths |
547 | 309 |
for t:= 0 to Pred(TeamsCount) do |
310 |
with TeamsArray[t]^ do |
|
47 | 311 |
begin |
1120 | 312 |
DrawTexture(cScreenWidth div 2 - NameTagTex^.w - 3, cScreenHeight + DrawHealthY, NameTagTex); |
690 | 313 |
|
314 |
r.x:= 0; |
|
315 |
r.y:= 0; |
|
547 | 316 |
r.w:= 2 + TeamHealthBarWidth; |
764
7513452b1d51
Now game looks almost like it did before switching to OpenGL
unc0rr
parents:
762
diff
changeset
|
317 |
r.h:= HealthTex^.h; |
690 | 318 |
|
764
7513452b1d51
Now game looks almost like it did before switching to OpenGL
unc0rr
parents:
762
diff
changeset
|
319 |
DrawFromRect(cScreenWidth div 2, |
1120 | 320 |
cScreenHeight + DrawHealthY, |
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
803
diff
changeset
|
321 |
@r, HealthTex); |
690 | 322 |
|
83 | 323 |
inc(r.x, cTeamHealthWidth + 2); |
324 |
r.w:= 3; |
|
690 | 325 |
|
764
7513452b1d51
Now game looks almost like it did before switching to OpenGL
unc0rr
parents:
762
diff
changeset
|
326 |
DrawFromRect(cScreenWidth div 2 + TeamHealthBarWidth + 2, |
1120 | 327 |
cScreenHeight + DrawHealthY, |
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
803
diff
changeset
|
328 |
@r, HealthTex); |
47 | 329 |
end; |
330 |
||
5 | 331 |
// Lag alert |
988 | 332 |
if isInLag then DrawSprite(sprLag, 32, 32, (RealTicks shr 7) mod 12); |
4 | 333 |
|
5 | 334 |
// Wind bar |
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
803
diff
changeset
|
335 |
DrawSprite(sprWindBar, cScreenWidth - 180, cScreenHeight - 30, 0); |
6 | 336 |
if WindBarWidth > 0 then |
5 | 337 |
begin |
689 | 338 |
{$WARNINGS OFF} |
339 |
r.x:= 8 - (RealTicks shr 6) mod 8; |
|
340 |
{$WARNINGS ON} |
|
341 |
r.y:= 0; |
|
342 |
r.w:= WindBarWidth; |
|
343 |
r.h:= 13; |
|
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
803
diff
changeset
|
344 |
DrawSpriteFromRect(sprWindR, r, cScreenWidth - 103, cScreenHeight - 28, 13, 0); |
5 | 345 |
end else |
6 | 346 |
if WindBarWidth < 0 then |
5 | 347 |
begin |
689 | 348 |
{$WARNINGS OFF} |
349 |
r.x:= (WindBarWidth + RealTicks shr 6) mod 8; |
|
350 |
{$WARNINGS ON} |
|
351 |
r.y:= 0; |
|
352 |
r.w:= - WindBarWidth; |
|
353 |
r.h:= 13; |
|
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
803
diff
changeset
|
354 |
DrawSpriteFromRect(sprWindL, r, cScreenWidth - 106 + WindBarWidth, cScreenHeight - 28, 13, 0); |
5 | 355 |
end; |
356 |
||
161 | 357 |
// AmmoMenu |
1120 | 358 |
if (AMxShift < 210) or bShowAmmoMenu then ShowAmmoMenu; |
161 | 359 |
|
942 | 360 |
DrawChat; |
361 |
||
5 | 362 |
// Cursor |
408 | 363 |
if isCursorVisible then |
364 |
begin |
|
365 |
if not bShowAmmoMenu then |
|
602 | 366 |
with CurrentHedgehog^ do |
408 | 367 |
if (Gear^.State and gstHHChooseTarget) <> 0 then |
368 |
begin |
|
369 |
i:= Ammo^[CurSlot, CurAmmo].Pos; |
|
370 |
with Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType] do |
|
371 |
if PosCount > 1 then |
|
762 | 372 |
DrawSprite(PosSprite, CursorPoint.X - SpritesData[PosSprite].Width div 2, |
373 |
CursorPoint.Y - SpritesData[PosSprite].Height div 2, |
|
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
803
diff
changeset
|
374 |
i); |
408 | 375 |
end; |
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
803
diff
changeset
|
376 |
DrawSprite(sprArrow, CursorPoint.X, CursorPoint.Y, (RealTicks shr 6) mod 8) |
408 | 377 |
end; |
4 | 378 |
|
762 | 379 |
if isPaused then DrawCentered(cScreenWidth div 2, cScreenHeight div 2, PauseTexture); |
281
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
244
diff
changeset
|
380 |
|
4 | 381 |
inc(Frames); |
298
112e61bd2cc2
Render FPS value to its own surface one time a second
unc0rr
parents:
295
diff
changeset
|
382 |
if cShowFPS then |
4 | 383 |
begin |
298
112e61bd2cc2
Render FPS value to its own surface one time a second
unc0rr
parents:
295
diff
changeset
|
384 |
inc(CountTicks, Lag); |
112e61bd2cc2
Render FPS value to its own surface one time a second
unc0rr
parents:
295
diff
changeset
|
385 |
if CountTicks >= 1000 then |
112e61bd2cc2
Render FPS value to its own surface one time a second
unc0rr
parents:
295
diff
changeset
|
386 |
begin |
112e61bd2cc2
Render FPS value to its own surface one time a second
unc0rr
parents:
295
diff
changeset
|
387 |
FPS:= Frames; |
112e61bd2cc2
Render FPS value to its own surface one time a second
unc0rr
parents:
295
diff
changeset
|
388 |
Frames:= 0; |
112e61bd2cc2
Render FPS value to its own surface one time a second
unc0rr
parents:
295
diff
changeset
|
389 |
CountTicks:= 0; |
112e61bd2cc2
Render FPS value to its own surface one time a second
unc0rr
parents:
295
diff
changeset
|
390 |
s:= inttostr(FPS) + ' fps'; |
759 | 391 |
if fpsTexture <> nil then FreeTexture(fpsTexture); |
392 |
tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), $FFFFFF); |
|
393 |
fpsTexture:= Surface2Tex(tmpSurface); |
|
394 |
SDL_FreeSurface(tmpSurface) |
|
298
112e61bd2cc2
Render FPS value to its own surface one time a second
unc0rr
parents:
295
diff
changeset
|
395 |
end; |
759 | 396 |
if fpsTexture <> nil then |
841
0700e3d3474d
Get rid if deprecated Surface parameter of Draw* calls
unc0rr
parents:
803
diff
changeset
|
397 |
DrawTexture(cScreenWidth - 50, 10, fpsTexture); |
4 | 398 |
end; |
174 | 399 |
|
400 |
inc(SoundTimerTicks, Lag); |
|
401 |
if SoundTimerTicks >= 50 then |
|
402 |
begin |
|
403 |
SoundTimerTicks:= 0; |
|
404 |
if cVolumeDelta <> 0 then |
|
405 |
begin |
|
406 |
str(ChangeVolume(cVolumeDelta), s); |
|
175 | 407 |
AddCaption(Format(trmsg[sidVolume], s), $FFFFFF, capgrpVolume) |
174 | 408 |
end |
756 | 409 |
end; |
410 |
||
1023 | 411 |
if GameState = gsConfirm then DrawCentered(cScreenWidth div 2, cScreenHeight div 2, ConfirmTexture); |
412 |
||
775 | 413 |
glDisable(GL_TEXTURE_2D); |
756 | 414 |
glDisable(GL_BLEND) |
4 | 415 |
end; |
416 |
||
108 | 417 |
procedure AddCaption(s: string; Color: Longword; Group: TCapGroup); |
4 | 418 |
begin |
83 | 419 |
if Group in [capgrpGameState, capgrpNetSay] then WriteLnToConsole(s); |
762 | 420 |
if Captions[Group].Tex <> nil then FreeTexture(Captions[Group].Tex); |
4 | 421 |
|
762 | 422 |
Captions[Group].Tex:= RenderStringTex(s, Color, fntBig); |
564 | 423 |
Captions[Group].EndTime:= RealTicks + 1500 |
4 | 424 |
end; |
425 |
||
79 | 426 |
procedure MoveCamera; |
4 | 427 |
const PrevSentPointTime: LongWord = 0; |
371 | 428 |
var EdgesDist: LongInt; |
4 | 429 |
begin |
678 | 430 |
if (not (CurrentTeam^.ExtDriven and isCursorVisible)) |
1689 | 431 |
and cHasFocus then SDL_GetMouseState(@CursorPoint.X, @CursorPoint.Y); |
678 | 432 |
|
1595
33529f567d2d
Don't set focus on gears when curor is visible (should fix cursor jumping)
unc0rr
parents:
1529
diff
changeset
|
433 |
if (FollowGear <> nil) and (not isCursorVisible) then |
1689 | 434 |
if abs(CursorPoint.X - prevPoint.X) + abs(CursorPoint.Y - prevpoint.Y) > 4 then |
435 |
begin |
|
436 |
FollowGear:= nil; |
|
437 |
prevPoint.X:= CursorPoint.X; |
|
438 |
prevPoint.Y:= CursorPoint.Y; |
|
439 |
exit |
|
440 |
end |
|
441 |
else begin |
|
442 |
CursorPoint.x:= (prevPoint.x * 7 + (hwRound(FollowGear^.X) + hwSign(FollowGear^.dX) * 100) + WorldDx) div 8; |
|
443 |
CursorPoint.y:= (prevPoint.y * 7 + (hwRound(FollowGear^.Y) + WorldDy)) div 8 |
|
444 |
end; |
|
4 | 445 |
|
446 |
if ((CursorPoint.X = prevPoint.X)and(CursorPoint.Y = prevpoint.Y)) then exit; |
|
447 |
||
1120 | 448 |
if AMxShift < 210 then |
1689 | 449 |
begin |
450 |
if CursorPoint.X < cScreenWidth + AMxShift - 175 then CursorPoint.X:= cScreenWidth + AMxShift - 175; |
|
451 |
if CursorPoint.X > cScreenWidth + AMxShift - 10 then CursorPoint.X:= cScreenWidth + AMxShift - 10; |
|
452 |
if CursorPoint.Y < cScreenHeight - 75 - SlotsNum * 33 then CursorPoint.Y:= cScreenHeight - 75 - SlotsNum * 33; |
|
453 |
if CursorPoint.Y > cScreenHeight - 76 then CursorPoint.Y:= cScreenHeight - 76; |
|
454 |
prevPoint:= CursorPoint; |
|
455 |
if cHasFocus then SDL_WarpMouse(CursorPoint.X, CursorPoint.Y); |
|
456 |
exit |
|
457 |
end; |
|
162 | 458 |
|
4 | 459 |
if isCursorVisible then |
1689 | 460 |
begin |
461 |
if (not CurrentTeam^.ExtDriven)and(GameTicks >= PrevSentPointTime + cSendCursorPosTime) then |
|
462 |
begin |
|
463 |
SendIPCXY('P', CursorPoint.X - WorldDx, CursorPoint.Y - WorldDy); |
|
464 |
PrevSentPointTime:= GameTicks |
|
465 |
end; |
|
466 |
end; |
|
351 | 467 |
|
4 | 468 |
if isCursorVisible or (FollowGear <> nil) then |
469 |
begin |
|
284 | 470 |
if isCursorVisible then EdgesDist:= cCursorEdgesDist |
471 |
else EdgesDist:= cGearScrEdgesDist; |
|
472 |
if CursorPoint.X < EdgesDist then |
|
4 | 473 |
begin |
284 | 474 |
WorldDx:= WorldDx - CursorPoint.X + EdgesDist; |
475 |
CursorPoint.X:= EdgesDist |
|
4 | 476 |
end else |
284 | 477 |
if CursorPoint.X > cScreenWidth - EdgesDist then |
4 | 478 |
begin |
284 | 479 |
WorldDx:= WorldDx - CursorPoint.X + cScreenWidth - EdgesDist; |
480 |
CursorPoint.X:= cScreenWidth - EdgesDist |
|
4 | 481 |
end; |
284 | 482 |
if CursorPoint.Y < EdgesDist then |
4 | 483 |
begin |
284 | 484 |
WorldDy:= WorldDy - CursorPoint.Y + EdgesDist; |
485 |
CursorPoint.Y:= EdgesDist |
|
4 | 486 |
end else |
284 | 487 |
if CursorPoint.Y > cScreenHeight - EdgesDist then |
4 | 488 |
begin |
284 | 489 |
WorldDy:= WorldDy - CursorPoint.Y + cScreenHeight - EdgesDist; |
490 |
CursorPoint.Y:= cScreenHeight - EdgesDist |
|
4 | 491 |
end; |
492 |
end else |
|
308 | 493 |
if cHasFocus then |
494 |
begin |
|
70 | 495 |
WorldDx:= WorldDx - CursorPoint.X + prevPoint.X; |
496 |
WorldDy:= WorldDy - CursorPoint.Y + prevPoint.Y; |
|
4 | 497 |
CursorPoint.X:= (cScreenWidth shr 1); |
498 |
CursorPoint.Y:= (cScreenHeight shr 1); |
|
308 | 499 |
end; |
351 | 500 |
|
308 | 501 |
if cHasFocus then SDL_WarpMouse(CursorPoint.X, CursorPoint.Y); |
4 | 502 |
prevPoint:= CursorPoint; |
75 | 503 |
if WorldDy < cScreenHeight - cWaterLine - cVisibleWater then WorldDy:= cScreenHeight - cWaterLine - cVisibleWater; |
1760 | 504 |
if WorldDy > LAND_HEIGHT + 1024 then WorldDy:= LAND_HEIGHT + 1024; |
1753 | 505 |
if WorldDx < -LAND_WIDTH then WorldDx:= -LAND_WIDTH; |
1760 | 506 |
if WorldDx > cScreenWidth then WorldDx:= cScreenWidth; |
4 | 507 |
end; |
508 |
||
509 |
initialization |
|
510 |
FillChar(Captions, sizeof(Captions), 0) |
|
511 |
||
512 |
end. |