@@ -47,6 +47,7 @@ Wind::Wind(const ReaderMapping& reader) :
47
47
particles_enabled(true )
48
48
{
49
49
float w,h;
50
+ parse_type (reader);
50
51
reader.get (" x" , m_col.m_bbox .get_left (), 0 .0f );
51
52
reader.get (" y" , m_col.m_bbox .get_top (), 0 .0f );
52
53
reader.get (" width" , w, 32 .0f );
@@ -96,6 +97,15 @@ Wind::get_settings()
96
97
return result;
97
98
}
98
99
100
+ GameObjectTypes
101
+ Wind::get_types () const
102
+ {
103
+ return {
104
+ { " wind" , _ (" Wind" ) },
105
+ { " current" , _ (" Current" ) }
106
+ };
107
+ }
108
+
99
109
void
100
110
Wind::update (float dt_sec_)
101
111
{
@@ -107,19 +117,26 @@ Wind::update(float dt_sec_)
107
117
Vector ppos = Vector (graphicsRandom.randf (m_col.m_bbox .get_left () + 8 , m_col.m_bbox .get_right () - 8 ), graphicsRandom.randf (m_col.m_bbox .get_top () + 8 , m_col.m_bbox .get_bottom () - 8 ));
108
118
Vector pspeed = Vector (graphicsRandom.randf (speed.x - 20 , speed.x + 20 ), graphicsRandom.randf (speed.y - 20 , speed.y + 20 ));
109
119
110
- // TODO: Rotate sprite rather than just use 2 different actions
111
120
// Approx. 1 particle per tile
112
121
if (graphicsRandom.randf (0 .f , 100 .f ) < (m_col.m_bbox .get_width () / 32 .f ) * (m_col.m_bbox .get_height () / 32 .f ))
113
122
{
114
123
// Emit a particle
115
- if (fancy_wind)
124
+ if (fancy_wind)
116
125
{
117
- Sector::get ().add <SpriteParticle>(" images/particles/wind.sprite" , (std::abs (speed.x ) > std::abs (speed.y )) ? " default" : " flip" , ppos, ANCHOR_MIDDLE, pspeed, Vector (0 , 0 ), m_layer);
118
- }
119
- else
126
+ const float angle = std::atan2 (speed.y , speed.x ) * float (180.0 / M_PI);
127
+ switch (m_type) {
128
+ case WIND: // Normal wind
129
+ Sector::get ().add <SpriteParticle>(" images/particles/wind.sprite" , " default" , ppos, ANCHOR_MIDDLE, pspeed, Vector (0 , 0 ), m_layer, false , Color::WHITE, angle);
130
+ break ;
131
+ case CURRENT: // Current variant
132
+ Sector::get ().add <SpriteParticle>(" images/particles/water_piece1.sprite" , " default" , ppos, ANCHOR_MIDDLE, pspeed, Vector (0 , 0 ), m_layer, false , Color::WHITE, angle);
133
+ break ;
134
+ }
135
+ }
136
+ else
120
137
{
121
- Sector::get ().add <Particles>(ppos, 44 , 46 , pspeed, Vector (0 , 0 ), 1 , Color (.4f , .4f , .4f ), 3 , .1f , m_layer);
122
- }
138
+ Sector::get ().add <Particles>(ppos, 44 , 46 , pspeed, Vector (0 , 0 ), 1 , Color (.4f , .4f , .4f ), 3 , .1f , m_layer);
139
+ }
123
140
}
124
141
}
125
142
0 commit comments