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