World of Might and Magic
0.2.0
Open reimplementation of Might and Magic 6 7 8 game engine
Титульная страница
Описания
Группы
Пространства имен
Пространства имен
Члены пространств имен
Указатель
Функции
Перечисления
Классы
Классы
Алфавитный указатель классов
Иерархия классов
Члены классов
Указатель
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Функции
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
y
z
~
Переменные
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Определения типов
Перечисления
Элементы перечислений
Относящиеся к классу функции
Файлы
Файлы
Список членов всех файлов
Указатель
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Функции
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
z
Переменные
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
z
Определения типов
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Перечисления
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
Элементы перечислений
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
Примеры
•
Указатель
Классы
Пространства имен
Файлы
Функции
Переменные
Определения типов
Перечисления
Элементы перечислений
Друзья
Группы
Страницы
Weather.cpp
См. документацию.
1
#include "
Engine/Graphics/IRender.h
"
2
3
#include "
Engine/Engine.h
"
4
5
#include "
Engine/Graphics/Viewport.h
"
6
#include "
Engine/Graphics/Weather.h
"
7
8
Weather
*
pWeather
=
new
Weather
;
9
10
void
Weather::DrawSnow
() {
11
for
(
unsigned
int
i = 0; i <
Screen_Coord
.size(); ++i) {
12
int
size
= 1;
13
int
base = 3;
14
if
(i >= 950) {
15
size
= 4;
16
base = 10;
17
}
else
if
(i >= 700) {
18
size
= 2;
19
base = 5;
20
}
21
Screen_Coord
[i].x += rand() % base - base / 2;
22
Screen_Coord
[i].y += rand() %
size
+
size
;
23
if
(
Screen_Coord
[i].
x
< (
int
)
viewparams
->
uScreen_topL_X
) {
24
Screen_Coord
[i].x =
viewparams
->
uScreen_BttmR_X
+ rand() % base;
25
}
else
if
(
Screen_Coord
[i].
x
>=
26
((
int
)
viewparams
->
uScreen_BttmR_X
-
size
)) {
27
Screen_Coord
[i].x =
viewparams
->
uScreen_topL_X
- rand() % base;
28
}
29
if
(
Screen_Coord
[i].
y
>= ((
int
)
viewparams
->
uScreen_BttmR_Y
-
size
)) {
30
Screen_Coord
[i].y =
viewparams
->
uScreen_topL_Y
;
31
Screen_Coord
[i].x =
viewparams
->
uScreen_topL_X
+
32
(rand() % (
viewparams
->
uScreen_BttmR_X
-
33
viewparams
->
uScreen_topL_X
-
size
));
34
}
35
36
render
->FillRectFast(
Screen_Coord
[i].
x
,
Screen_Coord
[i].
y
,
size
,
size
,
37
0xFFFF);
38
}
39
}
40
41
void
Weather::Initialize
() {
42
int
width
=
pViewport
->
uScreen_BR_X
-
pViewport
->
uScreen_TL_X
- 4;
43
int
height
=
pViewport
->
uScreen_BR_Y
-
pViewport
->
uScreen_TL_Y
- 4;
44
for
(
Point
&point :
Screen_Coord
) {
45
point.x =
pViewport
->
uViewportTL_X
+ rand() %
width
;
46
point.y =
pViewport
->
uViewportTL_Y
+ rand() %
height
;
47
}
48
}
49
50
void
Weather::Draw
() {
51
if
(
bRenderSnow
&&
engine
->AllowSnow()) {
52
DrawSnow
();
53
}
54
}
55
56
bool
Weather::OnPlayerTurn
(
int
dangle) {
57
if
(!
bRenderSnow
) {
58
return
false
;
59
}
60
61
unsigned
int
screen_width =
62
viewparams
->
uScreen_BttmR_X
-
viewparams
->
uScreen_topL_X
;
63
64
for
(
Point
&point :
Screen_Coord
) {
65
point.x += dangle;
66
if
(point.x < (
int
)
viewparams
->
uScreen_BttmR_X
- 4) {
67
if
(point.x >= (
int
)
viewparams
->
uScreen_topL_X
) {
68
continue
;
69
}
70
point.x += screen_width;
71
}
else
{
72
point.x -= screen_width + 4;
73
}
74
}
75
76
return
true
;
77
}
Viewport.h
Viewport::uViewportTL_Y
int uViewportTL_Y
Definition:
Viewport.h:23
Weather::bRenderSnow
bool bRenderSnow
Definition:
Weather.h:18
height
EGLSurface EGLint EGLint EGLint EGLint height
Definition:
SDL_egl.h:1596
engine
std::shared_ptr< Engine > engine
Definition:
Engine.cpp:130
Viewport::uScreen_TL_X
int uScreen_TL_X
Definition:
Viewport.h:18
Engine.h
ViewingParams::uScreen_topL_Y
unsigned int uScreen_topL_Y
Definition:
Viewport.h:61
ViewingParams::uScreen_BttmR_X
unsigned int uScreen_BttmR_X
Definition:
Viewport.h:62
Viewport::uScreen_TL_Y
int uScreen_TL_Y
Definition:
Viewport.h:19
pWeather
Weather * pWeather
Definition:
Weather.cpp:8
y
EGLSurface EGLint EGLint y
Definition:
SDL_egl.h:1596
Viewport::uScreen_BR_Y
int uScreen_BR_Y
Definition:
Viewport.h:21
ViewingParams::uScreen_topL_X
unsigned int uScreen_topL_X
Definition:
Viewport.h:60
IRender.h
x
EGLSurface EGLint x
Definition:
SDL_egl.h:1596
viewparams
struct ViewingParams * viewparams
Definition:
mm7_data.cpp:22
Weather::Initialize
void Initialize()
Definition:
Weather.cpp:41
Viewport::uScreen_BR_X
int uScreen_BR_X
Definition:
Viewport.h:20
Weather::Draw
void Draw()
Definition:
Weather.cpp:50
width
EGLSurface EGLint EGLint EGLint width
Definition:
SDL_egl.h:1596
Weather.h
pViewport
struct Viewport * pViewport
Definition:
mm7_data.cpp:21
Weather::OnPlayerTurn
bool OnPlayerTurn(int dangle)
Definition:
Weather.cpp:56
Weather::DrawSnow
void DrawSnow()
Definition:
Weather.cpp:10
Point
Definition:
Point.h:3
size
GLsizeiptr size
Definition:
SDL_opengl_glext.h:540
ViewingParams::uScreen_BttmR_Y
unsigned int uScreen_BttmR_Y
Definition:
Viewport.h:63
Weather::Screen_Coord
std::array< Point, 1000 > Screen_Coord
Definition:
Weather.h:16
Weather
Definition:
Weather.h:7
Viewport::uViewportTL_X
int uViewportTL_X
Definition:
Viewport.h:22
render
std::shared_ptr< IRender > render
Definition:
RenderOpenGL.cpp:52
Engine
Graphics
Weather.cpp
Документация по World of Might and Magic. Последние изменения: Вт 7 Апр 2020 22:03:30. Создано системой
1.8.17