]> Dogcows Code - chaz/yoink/commitdiff
new interface class: drawable
authorCharles McGarvey <chazmcgarvey@brokenzipper.com>
Wed, 8 Jul 2009 22:49:24 +0000 (16:49 -0600)
committerCharles McGarvey <chazmcgarvey@brokenzipper.com>
Wed, 8 Jul 2009 22:49:24 +0000 (16:49 -0600)
share/character/Heroine.json [new file with mode: 0644]
src/Character.hh [new file with mode: 0644]
src/drawable.hh [new file with mode: 0644]
src/tilemap.hh

diff --git a/share/character/Heroine.json b/share/character/Heroine.json
new file mode 100644 (file)
index 0000000..0ea723b
--- /dev/null
@@ -0,0 +1,4 @@
+{
+       "tilemap": "Heroine.png",
+       "animation": "Heroine.json"
+}
diff --git a/src/Character.hh b/src/Character.hh
new file mode 100644 (file)
index 0000000..2f175ad
--- /dev/null
@@ -0,0 +1,57 @@
+
+/*******************************************************************************
+
+ Copyright (c) 2009, Charles McGarvey
+ All rights reserved.
+ Redistribution   and   use  in  source  and  binary  forms,  with  or  without
+ modification, are permitted provided that the following conditions are met:
+   * Redistributions  of  source  code  must retain the above copyright notice,
+     this list of conditions and the following disclaimer.
+   * Redistributions  in binary form must reproduce the above copyright notice,
+     this  list of conditions and the following disclaimer in the documentation
+     and/or other materials provided with the distribution.
+ THIS  SOFTWARE  IS  PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND  ANY  EXPRESS  OR  IMPLIED  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED.  IN  NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ FOR  ANY  DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES  (INCLUDING,  BUT  NOT  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES;  LOSS  OF  USE,  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED  AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+*******************************************************************************/
+
+#ifndef _CHARACTER_HH_
+#define _CHARACTER_HH_
+
+/**
+ * @file Character.hh
+ * Parent class of animate objects with "personalities."
+ */
+
+
+class Character : public dc::resource, public dc::drawable
+{
+public:
+       struct exception : public std::runtime_error
+       {
+               explicit exception(const std::string& what_arg) :
+                       std::runtime_error(what_arg) {}
+       };
+
+       Character(const std::string& name);
+
+       void draw(dc::scalar alpha);
+
+       dc::tilemap* texture;
+       dc::animation* anim;
+};
+
+
+#endif // _CHARACTER_HH_
+
diff --git a/src/drawable.hh b/src/drawable.hh
new file mode 100644 (file)
index 0000000..835fb61
--- /dev/null
@@ -0,0 +1,51 @@
+
+/*******************************************************************************
+
+ Copyright (c) 2009, Charles McGarvey
+ All rights reserved.
+ Redistribution   and   use  in  source  and  binary  forms,  with  or  without
+ modification, are permitted provided that the following conditions are met:
+   * Redistributions  of  source  code  must retain the above copyright notice,
+     this list of conditions and the following disclaimer.
+   * Redistributions  in binary form must reproduce the above copyright notice,
+     this  list of conditions and the following disclaimer in the documentation
+     and/or other materials provided with the distribution.
+ THIS  SOFTWARE  IS  PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND  ANY  EXPRESS  OR  IMPLIED  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED.  IN  NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ FOR  ANY  DIRECT,  INDIRECT,  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES  (INCLUDING,  BUT  NOT  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES;  LOSS  OF  USE,  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED  AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+*******************************************************************************/
+
+#ifndef _DRAWABLE_HH_
+#define _DRAWABLE_HH_
+
+/**
+ * @file drawable.hh
+ * Interface for a drawable object.
+ */
+
+
+namespace dc {
+
+
+class drawable
+{
+public:
+       virtual void draw(scalar alpha) = 0;
+};
+
+
+} // namespace dc
+
+#endif // _DRAWABLE_HH_
+
index 212195355c76c53d9505b04f46fc216a25d9799f..50e5c3dd72d7620358713cafe8748c457ac29581 100644 (file)
@@ -85,6 +85,7 @@ public:
 
        void setTileDimensions(unsigned tilesU, unsigned tilesV)
        {
+               assert(tilesU != 0 && tilesV != 0);
                tilesU_ = tilesU;
                tilesV_ = tilesV;
        }
This page took 0.022371 seconds and 4 git commands to generate.