author | alfadur |
Thu, 01 Nov 2018 21:30:21 +0300 | |
changeset 14064 | c6745a1c827a |
parent 13670 | 5664650befcd |
child 14236 | 74bf2d906097 |
permissions | -rw-r--r-- |
13670
5664650befcd
Move common sprite tint values into Utils Lua library
Wuzzy <Wuzzy2@mail.ru>
parents:
13220
diff
changeset
|
1 |
-- Library for miscellaneous utilitiy functions and global helper variables |
4873
98dbb9b985e5
add a new lua library with misc tools and removed redundant tracker functions
Henek
parents:
diff
changeset
|
2 |
|
13670
5664650befcd
Move common sprite tint values into Utils Lua library
Wuzzy <Wuzzy2@mail.ru>
parents:
13220
diff
changeset
|
3 |
--[[ FUNCTIONS ]] |
4873
98dbb9b985e5
add a new lua library with misc tools and removed redundant tracker functions
Henek
parents:
diff
changeset
|
4 |
-- Check if a gear is inside a box |
98dbb9b985e5
add a new lua library with misc tools and removed redundant tracker functions
Henek
parents:
diff
changeset
|
5 |
function gearIsInBox(gear, x, y, w, h) |
98dbb9b985e5
add a new lua library with misc tools and removed redundant tracker functions
Henek
parents:
diff
changeset
|
6 |
gx, gy = GetGearPosition(gear) |
98dbb9b985e5
add a new lua library with misc tools and removed redundant tracker functions
Henek
parents:
diff
changeset
|
7 |
if gx >= x and gy >= y and gx <= x + w and gy <= y + h then |
98dbb9b985e5
add a new lua library with misc tools and removed redundant tracker functions
Henek
parents:
diff
changeset
|
8 |
return true |
98dbb9b985e5
add a new lua library with misc tools and removed redundant tracker functions
Henek
parents:
diff
changeset
|
9 |
end |
98dbb9b985e5
add a new lua library with misc tools and removed redundant tracker functions
Henek
parents:
diff
changeset
|
10 |
return false |
98dbb9b985e5
add a new lua library with misc tools and removed redundant tracker functions
Henek
parents:
diff
changeset
|
11 |
end |
98dbb9b985e5
add a new lua library with misc tools and removed redundant tracker functions
Henek
parents:
diff
changeset
|
12 |
|
98dbb9b985e5
add a new lua library with misc tools and removed redundant tracker functions
Henek
parents:
diff
changeset
|
13 |
-- Check if a gear is inside a circle |
98dbb9b985e5
add a new lua library with misc tools and removed redundant tracker functions
Henek
parents:
diff
changeset
|
14 |
function gearIsInCircle(gear, x, y, r, useRadius) |
98dbb9b985e5
add a new lua library with misc tools and removed redundant tracker functions
Henek
parents:
diff
changeset
|
15 |
gx, gy = GetGearPosition(gear) |
98dbb9b985e5
add a new lua library with misc tools and removed redundant tracker functions
Henek
parents:
diff
changeset
|
16 |
if useRadius then |
98dbb9b985e5
add a new lua library with misc tools and removed redundant tracker functions
Henek
parents:
diff
changeset
|
17 |
r = r + GetGearRadius(gear) |
98dbb9b985e5
add a new lua library with misc tools and removed redundant tracker functions
Henek
parents:
diff
changeset
|
18 |
end |
98dbb9b985e5
add a new lua library with misc tools and removed redundant tracker functions
Henek
parents:
diff
changeset
|
19 |
if r ^ 2 >= (x - gx) ^ 2 + (y - gy) ^ 2 then |
98dbb9b985e5
add a new lua library with misc tools and removed redundant tracker functions
Henek
parents:
diff
changeset
|
20 |
return true |
98dbb9b985e5
add a new lua library with misc tools and removed redundant tracker functions
Henek
parents:
diff
changeset
|
21 |
end |
98dbb9b985e5
add a new lua library with misc tools and removed redundant tracker functions
Henek
parents:
diff
changeset
|
22 |
return false |
98dbb9b985e5
add a new lua library with misc tools and removed redundant tracker functions
Henek
parents:
diff
changeset
|
23 |
end |
13220 | 24 |
|
25 |
local function drawFullMap(erase, flush) |
|
26 |
for x = 200,4000,600 do |
|
27 |
for y = 100,2000,150 do |
|
28 |
AddPoint(x, y, 63, erase) |
|
29 |
end |
|
30 |
end |
|
31 |
if flush ~= false then |
|
32 |
FlushPoints() |
|
33 |
end |
|
34 |
end |
|
35 |
||
36 |
-- Completely fill the map with land. Requires MapGen=mgDrawn. |
|
37 |
-- If flush is false, FlushPoints() is not called. |
|
38 |
function fillMap(flush) |
|
39 |
drawFullMap(false, flush) |
|
40 |
end |
|
41 |
||
42 |
-- Completely erase all land from drawn maps. Requires MapGen=mgDrawn. |
|
43 |
-- If flush is false, FlushPoints() is not called. |
|
44 |
function eraseMap(flush) |
|
45 |
drawFullMap(true, flush) |
|
46 |
end |
|
47 |
||
13670
5664650befcd
Move common sprite tint values into Utils Lua library
Wuzzy <Wuzzy2@mail.ru>
parents:
13220
diff
changeset
|
48 |
|
5664650befcd
Move common sprite tint values into Utils Lua library
Wuzzy <Wuzzy2@mail.ru>
parents:
13220
diff
changeset
|
49 |
--[[ GLOBAL VARIABLES ]] |
5664650befcd
Move common sprite tint values into Utils Lua library
Wuzzy <Wuzzy2@mail.ru>
parents:
13220
diff
changeset
|
50 |
|
5664650befcd
Move common sprite tint values into Utils Lua library
Wuzzy <Wuzzy2@mail.ru>
parents:
13220
diff
changeset
|
51 |
-- Shared common land color values for land sprites. |
5664650befcd
Move common sprite tint values into Utils Lua library
Wuzzy <Wuzzy2@mail.ru>
parents:
13220
diff
changeset
|
52 |
-- These are useful if you want to make the land type visible. |
5664650befcd
Move common sprite tint values into Utils Lua library
Wuzzy <Wuzzy2@mail.ru>
parents:
13220
diff
changeset
|
53 |
-- To be used as tint argument of PlaceSprite. |
5664650befcd
Move common sprite tint values into Utils Lua library
Wuzzy <Wuzzy2@mail.ru>
parents:
13220
diff
changeset
|
54 |
U_LAND_TINT_NORMAL = 0xFFFFFFFF -- tint for normal land |
5664650befcd
Move common sprite tint values into Utils Lua library
Wuzzy <Wuzzy2@mail.ru>
parents:
13220
diff
changeset
|
55 |
U_LAND_TINT_INDESTRUCTIBLE = 0x960000FF -- tint for indestructible land |
5664650befcd
Move common sprite tint values into Utils Lua library
Wuzzy <Wuzzy2@mail.ru>
parents:
13220
diff
changeset
|
56 |
U_LAND_TINT_ICE = 0x00FAFAFA -- tint for icy land |
5664650befcd
Move common sprite tint values into Utils Lua library
Wuzzy <Wuzzy2@mail.ru>
parents:
13220
diff
changeset
|
57 |
U_LAND_TINT_BOUNCY = 0x00FA00FF -- tint for bouncy land |