| 107 | |
| 108 | public: |
| 109 | bool OnUserCreate() override |
| 110 | { |
| 111 | // For this appliaction I have a single image that contains |
| 112 | // 28x2 unique characters, each character contains 8 animations of 3 |
| 113 | // frames each. Each frame is 26x36 pixels |
| 114 | gfxAll.Load("./assets/MegaSprite1.png"); |
| 115 | |
| 116 | // Thats A LOT of individual graphics, but they all follow a similar pattern |
| 117 | // because the asset was created usefully (take note certain popular asset creators) |
| 118 | // which means we can reuse the animation without needing to define it |
| 119 | // individually for all the "dudes" - the "cookie cutter" approach |
| 120 | |
| 121 | // Manually construct sequences - gfxAll could in fact be nullptr for this |
| 122 | // application, but ive kept it here for convenience |
| 123 | olc::utils::Animate2D::FrameSequence anim_fs_walk_s; |
| 124 | anim_fs_walk_s.AddFrame({ &gfxAll, {{0,0}, {26,36}} }); |
| 125 | anim_fs_walk_s.AddFrame({ &gfxAll, {{26,0}, {26,36}} }); |
| 126 | anim_fs_walk_s.AddFrame({ &gfxAll, {{52,0}, {26,36}} }); |
| 127 | |
| 128 | olc::utils::Animate2D::FrameSequence anim_fs_walk_w; |
| 129 | anim_fs_walk_w.AddFrame({ &gfxAll, {{ 0,36}, {26,36}} }); |
| 130 | anim_fs_walk_w.AddFrame({ &gfxAll, {{26,36}, {26,36}} }); |
| 131 | anim_fs_walk_w.AddFrame({ &gfxAll, {{52,36}, {26,36}} }); |
| 132 | |
| 133 | olc::utils::Animate2D::FrameSequence anim_fs_walk_e; |
| 134 | anim_fs_walk_e.AddFrame({ &gfxAll, {{ 0,72}, {26,36}} }); |
| 135 | anim_fs_walk_e.AddFrame({ &gfxAll, {{26,72}, {26,36}} }); |
| 136 | anim_fs_walk_e.AddFrame({ &gfxAll, {{52,72}, {26,36}} }); |
| 137 | |
| 138 | olc::utils::Animate2D::FrameSequence anim_fs_walk_n; |
| 139 | anim_fs_walk_n.AddFrame({ &gfxAll, {{ 0,108}, {26,36}} }); |
| 140 | anim_fs_walk_n.AddFrame({ &gfxAll, {{26,108}, {26,36}} }); |
| 141 | anim_fs_walk_n.AddFrame({ &gfxAll, {{52,108}, {26,36}} }); |
| 142 | |
| 143 | olc::utils::Animate2D::FrameSequence anim_fs_yes; |
| 144 | anim_fs_yes.AddFrame({ &gfxAll, {{ 0,144}, {26,36}} }); |
| 145 | anim_fs_yes.AddFrame({ &gfxAll, {{26,144}, {26,36}} }); |
| 146 | anim_fs_yes.AddFrame({ &gfxAll, {{52,144}, {26,36}} }); |
| 147 | |
| 148 | olc::utils::Animate2D::FrameSequence anim_fs_no; |
| 149 | anim_fs_no.AddFrame({ &gfxAll, {{ 0,180}, {26,36}} }); |
| 150 | anim_fs_no.AddFrame({ &gfxAll, {{26,180}, {26,36}} }); |
| 151 | anim_fs_no.AddFrame({ &gfxAll, {{52,180}, {26,36}} }); |
| 152 | |
| 153 | olc::utils::Animate2D::FrameSequence anim_fs_laugh; |
| 154 | anim_fs_laugh.AddFrame({ &gfxAll, {{ 0,216}, {26,36}} }); |
| 155 | anim_fs_laugh.AddFrame({ &gfxAll, {{26,216}, {26,36}} }); |
| 156 | anim_fs_laugh.AddFrame({ &gfxAll, {{52,216}, {26,36}} }); |
| 157 | |
| 158 | olc::utils::Animate2D::FrameSequence anim_fs_cheer; |
| 159 | anim_fs_cheer.AddFrame({ &gfxAll, {{ 0,252}, {26,36}} }); |
| 160 | anim_fs_cheer.AddFrame({ &gfxAll, {{26,252}, {26,36}} }); |
| 161 | anim_fs_cheer.AddFrame({ &gfxAll, {{52,252}, {26,36}} }); |
| 162 | |
| 163 | // A special "idle" animation just consists of a single frame |
| 164 | olc::utils::Animate2D::FrameSequence anim_fs_idle; |
| 165 | anim_fs_idle.AddFrame({ &gfxAll, {{26,0}, {26,36}} }); |
| 166 |
nothing calls this directly
no test coverage detected