-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFog.cpp
More file actions
71 lines (61 loc) · 1.19 KB
/
Fog.cpp
File metadata and controls
71 lines (61 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "DXUT.h"
#include "Fog.h"
Fog::Fog()
{
Create(L"fog.png");
_pivot = { 0,0 };
_layer = 2;
SetFog();
}
void Fog::SetFog()
{
texture->_texture->LockRect(0, &LockRect, 0, D3DLOCK_DISCARD);
pColor = (DWORD*)LockRect.pBits;
for (int y = 0; y < 5000; ++y)
{
for (int x = 0; x < 5000; ++x)
{
int nIdx = y * 5000 + x;
COLOR xclr = pColor[nIdx];
xclr2[nIdx].r = xclr.r;
xclr2[nIdx].g = xclr.g;
xclr2[nIdx].b = xclr.b;
xclr.r = 0.01f;
xclr.g = 0.01f;
xclr.b = 0.01f;
xclr.a = 0.8f;
pColor[nIdx] = xclr;
}
}
texture->_texture->UnlockRect(0);
}
void Fog::SetFog(vector2 _pos)
{
texture->_texture->LockRect(0, &LockRect, 0, D3DLOCK_DISCARD);
pColor = (DWORD*)LockRect.pBits;
for (int i = _pos.y - 100; i <= _pos.y + 100; i++)
{
for (int j = _pos.x - 100; j <= _pos.x + 100; j++)
{
int d = (int)sqrt((i - _pos.y) * (i - _pos.y) + (j - _pos.x) * (j - _pos.x));
if (d <= 100)
{
int nIdx = i * 5000 + j;
if (nIdx >= 25000000 || nIdx <= 0)
{
return;
}
COLOR xclr = pColor[nIdx];
if (xclr.a > 0)
{
xclr.a = 0;
pColor[nIdx] = xclr;
}
}
}
}
texture->_texture->UnlockRect(0);
}
void Fog::Update()
{
}