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
4Task MySprite::asyncLoad(const string& fname){
5 DEBUG_MSG("Load file " << fname)
6 return std::async(std::launch::async, [fname, this]() -> void {
7 sp.emplace(fname);
8 });
9}
10
12 const vector<RGBAcolor>& inPixels = msp.sp->getPixelData();
13 unsigned rowSize = msp.sp->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 sp.emplace(outPixels, rowSize);
27}
optional< nsGui::Sprite > sp
optional actual Sprite We need to use an optional to init the object through a function,...
Definition: mySprite.h:20
void mirror(MySprite &msp)
Mirror a sprite pixel data into this one.
Definition: mySprite.cpp:11
Task asyncLoad(const string &fname)
load a sprite asynchronously
Definition: mySprite.cpp:4
utilies for the game
future< void > Task
Definition: utils.h:53
#define DEBUG_MSG(X)
Definition: utils.h:32