SUPER Space invader : Turbo edition DX - VS GOD 1.0.0
A simple space invader ripoff
mySprite.cpp
Go to the documentation of this file.
1#include "utils.h"
2#include "mySprite.h"
3
4future<void> MySprite::asyncLoad(const string& fname){
5 DEBUG_MSG("Load file " << fname)
6 return std::async(std::launch::async, [fname, this]() -> void {
7 ptr = std::make_unique<nsGui::Sprite>(fname);
8 });
9}
10
12 const vector<RGBAcolor>& inPixels = msp.ptr->getPixelData();
13 unsigned rowSize = msp.ptr->getRowSize();
14
15 vector<RGBAcolor> outPixels;
16 // we reserve size so the vector doesn't dynamically grows
17 outPixels.reserve(inPixels.size());
18 //for each line of pixel
19 for(unsigned rowOffset=0; rowOffset < inPixels.size(); rowOffset+=rowSize){
20 // for each pixel of that line
21 for(unsigned j=0;j<rowSize;++j) {
22 // push back the pixel opposed to this one (still in the same line)
23 outPixels.push_back(inPixels[rowOffset + rowSize - j - 1]);
24 }
25 }
26 ptr = std::make_unique<nsGui::Sprite>(outPixels, rowSize);
27}
future< void > asyncLoad(const string &fname)
Definition: mySprite.cpp:4
void mirror(MySprite &msp)
Definition: mySprite.cpp:11
unique_ptr< nsGui::Sprite > ptr
Definition: mySprite.h:11
utilies for the game
#define DEBUG_MSG(X)
Definition: utils.h:34