SpriteBatch.hpp
1 /******************************************************************************
2 
3  nomlib - C++11 cross-platform game engine
4 
5 Copyright (c) 2013, Jeffrey Carpenter <jeffrey.carp@gmail.com>
6 All rights reserved.
7 
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are met:
10 
11 1. Redistributions of source code must retain the above copyright notice, this
12  list of conditions and the following disclaimer.
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
21 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 ******************************************************************************/
29 #ifndef NOMLIB_SDL2_SPRITE_BATCH_HEADERS
30 #define NOMLIB_SDL2_SPRITE_BATCH_HEADERS
31 
32 #include <iostream>
33 #include <string>
34 
35 #include "nomlib/config.hpp"
36 #include "nomlib/math/Coords.hpp"
37 #include "nomlib/graphics/Texture.hpp"
38 #include "nomlib/graphics/sprite/Sprite.hpp"
39 #include "nomlib/graphics/sprite/SpriteSheet.hpp"
40 
41 namespace nom {
42 
45  public Sprite
46 {
47  public:
50  SpriteBatch ( void );
51 
53  virtual ~SpriteBatch ( void );
54 
57  SpriteBatch ( const SpriteSheet& sheet );
58 
60  SpriteBatch ( const std::string& filename );
61 
63  SpriteBatch& operator = ( const SpriteBatch& other );
64 
66  int32 getSheetID ( void ) const;
67 
69  int32 frames ( void ) const;
70 
71  const std::string& sheet_filename ( void ) const;
72 
74  void setSheetID ( int32 id );
75 
78  /*virtual*/ void update ( void );
79 
80  protected:
83 
86 
88  int32 sheet_id;
89 };
90 
91 
92 } // namespace nom
93 
94 #endif // include guard defined
Extended bitmap object rendering – utilizes sprite sheets.
Definition: SpriteBatch.hpp:44
Coords offsets
Source (input) coordinates – used for sprite sheet positioning.
Definition: SpriteBatch.hpp:82
int32 frames(void) const
Obtain the number of frames available.
Definition: SpriteBatch.cpp:92
SpriteBatch & operator=(const SpriteBatch &other)
Copy assignment operator.
Definition: SpriteBatch.cpp:68
void setSheetID(int32 id)
Set a new frame ID to render.
virtual ~SpriteBatch(void)
Destructor.
Definition: SpriteBatch.cpp:81
int32 sheet_id
The sheet&#39;s frame ID presently in use.
Definition: SpriteBatch.hpp:88
Specialized class container for the creation of sprite sheets via RFC 4627 JSON-compliant file input...
Definition: SpriteSheet.hpp:62
int32 getSheetID(void) const
Get the object&#39;s current sheet_id.
Definition: SpriteBatch.cpp:86
SpriteSheet sprite_sheet
Our attached sprite sheet object.
Definition: SpriteBatch.hpp:85
Coordinate values (x, y, z, width, height ) wrapper.
Definition: Coords.hpp:44
void update(void)
Base class for bitmap objects.
Definition: Sprite.hpp:46