World of Might and Magic  0.2.0
Open reimplementation of Might and Magic 6 7 8 game engine
Weather.cpp
См. документацию.
2 
3 #include "Engine/Engine.h"
4 
7 
9 
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)) {
32  (rand() % (viewparams->uScreen_BttmR_X -
34  }
35 
36  render->FillRectFast(Screen_Coord[i].x, Screen_Coord[i].y, size, size,
37  0xFFFF);
38  }
39 }
40 
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 =
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