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