assets + some semantic things
This commit is contained in:
parent
994a073ee5
commit
c257c24488
BIN
assets/hand_closed.si2
Normal file
BIN
assets/hand_closed.si2
Normal file
Binary file not shown.
BIN
assets/hand_open.si2
Normal file
BIN
assets/hand_open.si2
Normal file
Binary file not shown.
BIN
assets/test.sl2
BIN
assets/test.sl2
Binary file not shown.
@ -18,7 +18,15 @@ class PixelManager{
|
|||||||
public:
|
public:
|
||||||
MinGL& window;
|
MinGL& window;
|
||||||
|
|
||||||
nsGui::Sprite background = nsGui::Sprite("./assets/bg.sl2"); // you cant create an empty sprite for some reasons
|
/*
|
||||||
|
* Sprites are not const because for some reason the texture is associated with coordinates,
|
||||||
|
* and we have no way to dissociate them...
|
||||||
|
* So the objects are constantly updated with new coordinates as they need to be drawn
|
||||||
|
*/
|
||||||
|
nsGui::Sprite background = nsGui::Sprite("./assets/bg.si2");
|
||||||
|
nsGui::Sprite handOpen = nsGui::Sprite("./assets/hand_open.si2");
|
||||||
|
nsGui::Sprite handClosed = nsGui::Sprite("./assets/hand_closed.si2");
|
||||||
|
|
||||||
|
|
||||||
explicit PixelManager(MinGL&);
|
explicit PixelManager(MinGL&);
|
||||||
|
|
||||||
@ -26,8 +34,9 @@ public:
|
|||||||
void drawInvaderB(const Position& baseVector, unsigned size, const RGBAcolor& color) const;
|
void drawInvaderB(const Position& baseVector, unsigned size, const RGBAcolor& color) const;
|
||||||
void drawInvaderC(const Position& baseVector, unsigned size, const RGBAcolor& color) const;
|
void drawInvaderC(const Position& baseVector, unsigned size, const RGBAcolor& color) const;
|
||||||
void drawPlayer(unsigned x, unsigned width, const nsGraphics::RGBAcolor& color) const;
|
void drawPlayer(unsigned x, unsigned width, const nsGraphics::RGBAcolor& color) const;
|
||||||
void drawTorpedo(const Position& baseVector, unsigned width, const nsGraphics::RGBAcolor& color) const;
|
|
||||||
void drawMissile(const Position& baseVector, unsigned width, const nsGraphics::RGBAcolor& color) const;
|
void drawMissile(const Position& baseVector, unsigned width, const nsGraphics::RGBAcolor& color) const;
|
||||||
|
void drawTorpedo(const Position& baseVector, unsigned width, const nsGraphics::RGBAcolor& color) const;
|
||||||
|
void drawSprite(nsGui::Sprite& sprite, const Position& pos) const;
|
||||||
void drawBackground() const;
|
void drawBackground() const;
|
||||||
|
|
||||||
PlayMode showInitialMenu() const;
|
PlayMode showInitialMenu() const;
|
||||||
|
@ -47,4 +47,67 @@ void Game::displayInvader(const Position& pos, unsigned size, InvaderType type)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void applyBezier(Position& pos, const Position& point, const double percent) {
|
||||||
|
pos += (point-pos)*percent;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Game::displayGod() const {
|
||||||
|
switch (god.state) {
|
||||||
|
case GodState::NONE:
|
||||||
|
return;
|
||||||
|
case GodState::LOAD: {
|
||||||
|
pm.displayGodBench(god.counter - GOD_BENCH_SIZE);
|
||||||
|
|
||||||
|
Position leftHand = Position(pm.getScreenWidth()-GOD_HAND_DISTANCE-GOD_HAND_SIZE, god.counter - GOD_BENCH_SIZE);
|
||||||
|
Position rightHand = Position(GOD_HAND_DISTANCE, god.counter - GOD_BENCH_SIZE);
|
||||||
|
pm.displayGodLeftHand(leftHand);
|
||||||
|
pm.displayGodRightHand(rightHand);
|
||||||
|
}
|
||||||
|
case GodState::WAIT:{
|
||||||
|
pm.displayGodBench(0);
|
||||||
|
|
||||||
|
Position leftHand(GOD_HAND_DISTANCE, 0);
|
||||||
|
Position rightHand(pm.getScreenWidth()-GOD_HAND_DISTANCE-GOD_HAND_SIZE, 0);
|
||||||
|
pm.displayGodLeftHand(leftHand);
|
||||||
|
pm.displayGodRightHand(rightHand);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GodState::RETRIEVE1:{
|
||||||
|
// Bezier curve
|
||||||
|
// counter goes [0-100]
|
||||||
|
|
||||||
|
Position startPos(GOD_HAND_DISTANCE, 0);
|
||||||
|
Position endPos = basePos+Position(INV_POS(god.throwedInvPos.getX()), INV_POS(god.throwedInvPos.getY()));
|
||||||
|
|
||||||
|
applyBezier(startPos, god.thrownTransition, god.counter/100);
|
||||||
|
applyBezier(startPos, endPos, god.counter/100);
|
||||||
|
|
||||||
|
// startPos is now the position we need to draw our hand to
|
||||||
|
pm.displayGodRightHand(startPos);
|
||||||
|
pm.displayGodLeftHand(Position(GOD_HAND_DISTANCE, 0));
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GodState::RETRIEVE2:{
|
||||||
|
// similar with RETRIEVE1
|
||||||
|
Position startPos(GOD_HAND_DISTANCE, 0);
|
||||||
|
Position endPos = basePos+Position(INV_POS(god.throwedInvPos.getX()), INV_POS(god.throwedInvPos.getY()));
|
||||||
|
|
||||||
|
applyBezier(startPos, god.thrownTransition, 1-(god.counter/100));
|
||||||
|
applyBezier(startPos, endPos, 1-(god.counter/100));
|
||||||
|
|
||||||
|
pm.displayGodRightHand(startPos);
|
||||||
|
pm.displayGodLeftHand(Position(GOD_HAND_DISTANCE, 0));
|
||||||
|
|
||||||
|
// but now, you come with me you invader !
|
||||||
|
// pm.drawInvader1();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GodState::THROW:{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -31,65 +31,3 @@ void Game::manageGod(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void applyBezier(Position& pos, const Position& point, const double percent) {
|
|
||||||
pos += (point-pos)*percent;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Game::displayGod() const {
|
|
||||||
switch (god.state) {
|
|
||||||
case GodState::NONE:
|
|
||||||
return;
|
|
||||||
case GodState::LOAD: {
|
|
||||||
pm.displayGodBench(god.counter - GOD_BENCH_SIZE);
|
|
||||||
|
|
||||||
Position leftHand = Position(pm.getScreenWidth()-GOD_HAND_DISTANCE-GOD_HAND_SIZE, god.counter - GOD_BENCH_SIZE);
|
|
||||||
Position rightHand = Position(GOD_HAND_DISTANCE, god.counter - GOD_BENCH_SIZE);
|
|
||||||
pm.displayGodLeftHand(leftHand);
|
|
||||||
pm.displayGodRightHand(rightHand);
|
|
||||||
}
|
|
||||||
case GodState::WAIT:{
|
|
||||||
pm.displayGodBench(0);
|
|
||||||
|
|
||||||
Position leftHand(GOD_HAND_DISTANCE, 0);
|
|
||||||
Position rightHand(pm.getScreenWidth()-GOD_HAND_DISTANCE-GOD_HAND_SIZE, 0);
|
|
||||||
pm.displayGodLeftHand(leftHand);
|
|
||||||
pm.displayGodRightHand(rightHand);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case GodState::RETRIEVE1:{
|
|
||||||
// Bezier curve
|
|
||||||
// counter goes [0-100]
|
|
||||||
|
|
||||||
Position startPos(GOD_HAND_DISTANCE, 0);
|
|
||||||
Position endPos = basePos+Position(INV_POS(god.throwedInvPos.getX()), INV_POS(god.throwedInvPos.getY()));
|
|
||||||
|
|
||||||
applyBezier(startPos, god.thrownTransition, god.counter/100);
|
|
||||||
applyBezier(startPos, endPos, god.counter/100);
|
|
||||||
|
|
||||||
// startPos is now the position we need to draw our hand to
|
|
||||||
pm.displayGodRightHand(startPos);
|
|
||||||
pm.displayGodLeftHand(Position(GOD_HAND_DISTANCE, 0));
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case GodState::RETRIEVE2:{
|
|
||||||
// similar with RETRIEVE1
|
|
||||||
Position startPos(GOD_HAND_DISTANCE, 0);
|
|
||||||
Position endPos = basePos+Position(INV_POS(god.throwedInvPos.getX()), INV_POS(god.throwedInvPos.getY()));
|
|
||||||
|
|
||||||
applyBezier(startPos, god.thrownTransition, 1-(god.counter/100));
|
|
||||||
applyBezier(startPos, endPos, 1-(god.counter/100));
|
|
||||||
|
|
||||||
pm.displayGodRightHand(startPos);
|
|
||||||
pm.displayGodLeftHand(Position(GOD_HAND_DISTANCE, 0));
|
|
||||||
|
|
||||||
// but now, you come with me you invader !
|
|
||||||
// pm.drawInvader1();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case GodState::THROW:{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -58,6 +58,16 @@ void PixelManager::drawTorpedo(const Position& baseVector, unsigned width, const
|
|||||||
window << nsShape::Rectangle(baseVector, baseVector + Position(width, width * PROJ_LENGTH_FACTOR), color);
|
window << nsShape::Rectangle(baseVector, baseVector + Position(width, width * PROJ_LENGTH_FACTOR), color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PixelManager::drawSprite(nsGui::Sprite& sprite, const Position& pos) const {
|
||||||
|
/*
|
||||||
|
* no idea why the const qualifier is authorized since we modify object data with setPosition(),
|
||||||
|
* but since this modification isn't even "real" (see pixelManager.h), it's actually nice, I guess
|
||||||
|
*/
|
||||||
|
sprite.setPosition(pos);
|
||||||
|
|
||||||
|
sprite.draw(window);
|
||||||
|
}
|
||||||
|
|
||||||
void PixelManager::drawBackground() const {
|
void PixelManager::drawBackground() const {
|
||||||
background.draw(window);
|
background.draw(window);
|
||||||
}
|
}
|
||||||
|
BIN
unconverted_assets/bg.jpeg
Normal file
BIN
unconverted_assets/bg.jpeg
Normal file
Binary file not shown.
After Width: | Height: | Size: 47 KiB |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
Loading…
Reference in New Issue
Block a user