From: Charles McGarvey Date: Wed, 8 Jul 2009 22:49:24 +0000 (-0600) Subject: new interface class: drawable X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=79becf045222f385da5a1b9eb79081f6f5266c86;p=chaz%2Fyoink new interface class: drawable --- diff --git a/share/character/Heroine.json b/share/character/Heroine.json new file mode 100644 index 0000000..0ea723b --- /dev/null +++ b/share/character/Heroine.json @@ -0,0 +1,4 @@ +{ + "tilemap": "Heroine.png", + "animation": "Heroine.json" +} diff --git a/src/Character.hh b/src/Character.hh new file mode 100644 index 0000000..2f175ad --- /dev/null +++ b/src/Character.hh @@ -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 index 0000000..835fb61 --- /dev/null +++ b/src/drawable.hh @@ -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_ + diff --git a/src/tilemap.hh b/src/tilemap.hh index 2121953..50e5c3d 100644 --- a/src/tilemap.hh +++ b/src/tilemap.hh @@ -85,6 +85,7 @@ public: void setTileDimensions(unsigned tilesU, unsigned tilesV) { + assert(tilesU != 0 && tilesV != 0); tilesU_ = tilesU; tilesV_ = tilesV; }