1 module cloud;
2 
3 import resourcemanager;
4 import dsfml.graphics;
5 
6 static this() {
7   assert(resource_manager.register!Texture("assets/cloud.png", "cloud"));
8 }
9 
10 /// Drawable, slowly moving cloud
11 class Cloud : Drawable {
12   private static float speed = 100;
13   private float horizontal_offset;
14   private float height;
15 
16   /// Constructs a cloud at given height and horizontal offset
17   this(const float _horizontal_offset, const float _height) {
18     horizontal_offset = _horizontal_offset;
19     height = _height;
20   }
21 
22   /// Moves the cloud x px to the left
23   void move(const float f) {
24     horizontal_offset -= f;
25   }
26 
27   override void draw(RenderTarget target, RenderStates states) const {
28     auto s = new Sprite(resource_manager.get!Texture("cloud"));
29     s.position(Vector2f(horizontal_offset, height));
30     target.draw(s, states);
31   }
32 }