]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/PartyLayout.h
moved hero position to Hero
[l2e.git] / src / battle / PartyLayout.h
index 1456f15ae89f7cc435ac3ed03df950b41988ad8a..684413964d096b77b352f5e31840d97acc47c65e 100644 (file)
@@ -10,6 +10,7 @@
 
 #include "../geometry/Point.h"
 
+#include <cassert>
 #include <vector>
 #include <SDL.h>
 
@@ -21,18 +22,26 @@ public:
        PartyLayout() { }
 
 public:
-       int NumPositions() const { return positions.size(); }
+       std::vector<geometry::Point<Uint8> >::size_type NumPositions() const { return positions.size(); }
        template<class U>
        void CalculatePositions(U width, U height, std::vector<geometry::Point<U> > &dest) const {
                dest.clear();
                dest.reserve(positions.size());
                for (std::vector<geometry::Point<Uint8> >::const_iterator i(positions.begin()), end(positions.end()); i != end; ++i) {
                        dest.push_back(geometry::Point<U>(
-                                       i->X() * 256 / width,
-                                       i->Y() * 256 / height
+                                       i->X() * width / 255,
+                                       i->Y() * height / 223
                                        ));
                }
        }
+       template<class U>
+       geometry::Point<U> CalculatePosition(std::vector<geometry::Point<Uint8> >::size_type index, U width, U height) const {
+               assert(index >= 0 && index < positions.size());
+               return geometry::Point<U>(
+                               positions[index].X() * width / 255,
+                               positions[index].Y() * height / 223
+                               );
+       }
 
 public:
        void AddPosition(const geometry::Point<Uint8> &p) {