Skip to content

Commit

Permalink
Updated to latest engine code
Browse files Browse the repository at this point in the history
  • Loading branch information
notnotme committed Nov 17, 2016
1 parent a4dcb52 commit 30be5fe
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 32 deletions.
15 changes: 7 additions & 8 deletions floodit/source/Game.cpp
Expand Up @@ -335,12 +335,11 @@ int Game::update(const SceCtrlData& inputs, const SceTouchData& touchFront, cons

mGraphicsBase->startDrawing();
mGraphics2D->use();
mGraphics2D->setProjectionMatrix(*ortho);
mSpriteBuffer->start();

mSpriteBuffer->put(*floorSprite);
mGraphics2D->setTexture(mGameContext->getFloorTexture());
mGraphics2D->render(mSpriteBuffer);
mGraphics2D->render(*ortho, mSpriteBuffer);

mSpriteBuffer->put(mBackOverlaySprite);
for(unsigned int i=0; i<Game::GRID_SIZE*Game::GRID_SIZE; i++) {
Expand All @@ -349,30 +348,30 @@ int Game::update(const SceCtrlData& inputs, const SceTouchData& touchFront, cons
mSpriteBuffer->put(mPlayerGrid[i]);
}
mGraphics2D->setTexture(mGameContext->getSpritesTexture());
mGraphics2D->render(mSpriteBuffer);
mGraphics2D->render(*ortho, mSpriteBuffer);

char str[25];
snprintf(str, 25, "Left: %2i", mClicks);
mSpriteBuffer->put(mScoreMarginX,mScoreMarginY, -16, mScoreSpriteLetter, std::string(str));
mGraphics2D->setTexture(mGameContext->getFontTexture());
mGraphics2D->render(mSpriteBuffer);
mGraphics2D->render(*ortho, mSpriteBuffer);

if (mTopOverlaySprite.color.a != 0) {
mSpriteBuffer->put(mTopOverlaySprite);
mSpriteBuffer->put(mQuitSprite);
mSpriteBuffer->put(mRestartSprite);
mGraphics2D->setTexture(mGameContext->getSpritesTexture());
mGraphics2D->render(mSpriteBuffer);
mGraphics2D->render(*ortho, mSpriteBuffer);

if (mGameOverSpriteLetter.color.a != 0) {
if (mState == WIN) {
mSpriteBuffer->put(mWinMarginX,GraphicsBase::DISPLAY_HEIGHT*0.4, -Game::CHAR_OFFSET, mGameOverSpriteLetter, "You WIN :)");
mGraphics2D->setTexture(mGameContext->getFontTexture());
mGraphics2D->render(mSpriteBuffer);
mGraphics2D->render(*ortho, mSpriteBuffer);
} else if (mState == LOSE) {
mSpriteBuffer->put(mLoseMarginX,GraphicsBase::DISPLAY_HEIGHT*0.4, -Game::CHAR_OFFSET, mGameOverSpriteLetter, "You LOSE :(");
mGraphics2D->setTexture(mGameContext->getFontTexture());
mGraphics2D->render(mSpriteBuffer);
mGraphics2D->render(*ortho, mSpriteBuffer);
}
}
}
Expand All @@ -381,7 +380,7 @@ int Game::update(const SceCtrlData& inputs, const SceTouchData& touchFront, cons
snprintf(str, 25, "FPS: %i", mDirector->getFPS());
mSpriteBuffer->put(16,16, -4, *mGameContext->getSpriteLetter(), std::string(str));
mGraphics2D->setTexture(GraphicsBase::getDebugFontTexture());
mGraphics2D->render(mSpriteBuffer);
mGraphics2D->render(*ortho, mSpriteBuffer);
#endif
mGraphicsBase->stopDrawing();
mGraphicsBase->swapBuffers();
Expand Down
11 changes: 5 additions & 6 deletions floodit/source/Title.cpp
Expand Up @@ -133,34 +133,33 @@ int Title::update(const SceCtrlData& inputs, const SceTouchData& touchFront, con
// Render
mGraphicsBase->startDrawing();
mGraphics2D->use();
mGraphics2D->setProjectionMatrix(*ortho);

mSpriteBuffer->start();
mSpriteBuffer->put(*floorSprite);
mGraphics2D->setTexture(mGameContext->getFloorTexture());
mGraphics2D->render(mSpriteBuffer);
mGraphics2D->render(*ortho, mSpriteBuffer);

mSpriteBuffer->put(mTitleSprite);
mSpriteBuffer->put(mPlaySprite);
mGraphics2D->setTexture(mGameContext->getSpritesTexture());
mGraphics2D->render(mSpriteBuffer);
mGraphics2D->render(*ortho, mSpriteBuffer);

mSpriteBuffer->put(mScrollOffset, GraphicsBase::DISPLAY_HEIGHT-Title::CHAR_SIZE/2, -Title::CHAR_OFFSET, mScrollSprite, sGreetStr);
mGraphics2D->setTexture(mGameContext->getFontTexture());
mGraphics2D->render(mSpriteBuffer);
mGraphics2D->render(*ortho, mSpriteBuffer);

if (mOverlaySprite.color.a > 0) {
mSpriteBuffer->put(mOverlaySprite);
mGraphics2D->setTexture(mGameContext->getSpritesTexture());
mGraphics2D->render(mSpriteBuffer);
mGraphics2D->render(*ortho, mSpriteBuffer);
}

#ifdef DEBUG
char str[25];
snprintf(str, 25, "FPS: %i", mDirector->getFPS());
mSpriteBuffer->put(16,16, -4, *mGameContext->getSpriteLetter(), std::string(str));
mGraphics2D->setTexture(GraphicsBase::getDebugFontTexture());
mGraphics2D->render(mSpriteBuffer);
mGraphics2D->render(*ortho, mSpriteBuffer);
#endif
mGraphicsBase->stopDrawing();
mGraphicsBase->swapBuffers();
Expand Down
24 changes: 12 additions & 12 deletions samples/2d_shapes/main.cpp
Expand Up @@ -70,18 +70,18 @@ int main() {
graphics2D->clear(0xff, 0xff, 0xff, 0xff);

d2Buffer->start();
d2Buffer->put( 10, 10, 255, 0, 0, 255);
d2Buffer->put(100, 10, 0, 255, 0, 255);
d2Buffer->put(100, 100, 0, 0, 255, 255);
d2Buffer->put( 10, 100, 255, 255, 255, 255);

graphics2D->setProjectionMatrix(ortho);
graphics2D->render(SCE_GXM_PRIMITIVE_TRIANGLE_FAN, d2Buffer, false);

d2Buffer->put(200, 50, 255, 0, 0, 255);
d2Buffer->put(150, 150, 0, 255, 0, 255);
d2Buffer->put(250, 150, 0, 0, 255, 255);
graphics2D->render(SCE_GXM_PRIMITIVE_TRIANGLES, d2Buffer, false);
d2Buffer->put(100, 100, 255, 0, 0, 255);
d2Buffer->put(100, 150, 0, 0, 255, 255);
d2Buffer->put(150, 150, 255, 255, 255, 255);
d2Buffer->put(150, 100, 0, 255, 0, 255);
graphics2D->render(ortho, SCE_GXM_PRIMITIVE_TRIANGLE_FAN, d2Buffer, false);

d2Buffer->put(300, 300, 255, 0, 0, 255);
d2Buffer->put(300, 350, 255, 0, 0, 255);
d2Buffer->put(350, 350, 255, 0, 0, 255);
d2Buffer->put(350, 300, 255, 0, 0, 255);
graphics2D->render(ortho, SCE_GXM_PRIMITIVE_TRIANGLE_FAN, d2Buffer, false);


// stop and swap display
graphicsBase->stopDrawing();
Expand Down
3 changes: 1 addition & 2 deletions samples/cube/main.cpp
Expand Up @@ -132,8 +132,7 @@ int main() {
graphics2D->clear(0x00, 0x00, 0x00, 0xff);

graphics3D->use();
graphics3D->setProjectionMatrix(mvp);
graphics3D->render(SCE_GXM_PRIMITIVE_TRIANGLES, indiceBuffer, d3Buffer, false, 0, 36);
graphics3D->render(mvp, SCE_GXM_PRIMITIVE_TRIANGLES, indiceBuffer, d3Buffer, false, 0, 36);

graphicsBase->stopDrawing();
graphicsBase->swapBuffers();
Expand Down
3 changes: 1 addition & 2 deletions samples/hello_world/main.cpp
Expand Up @@ -82,9 +82,8 @@ int main() {
}

// set default texture then render
graphics2D->setProjectionMatrix(ortho);
graphics2D->setTexture(GraphicsBase::getDebugFontTexture());
graphics2D->render(spriteBuffer);
graphics2D->render(ortho, spriteBuffer);

/*
graphics2D->setTexture(0, myTexture);
Expand Down
3 changes: 1 addition & 2 deletions samples/triangle/main.cpp
Expand Up @@ -90,12 +90,11 @@ int main() {

graphics3D->use();
graphics3D->setTexture(GraphicsBase::getDebugFontTexture());
graphics3D->setProjectionMatrix(mvp);
d3Buffer->start();
d3Buffer->put( 1.0f, 1.0f,0.0f, 0.0f,0.0f, 255,0,255,255);
d3Buffer->put(-1.0f,-1.0f,0.0f, 1.0f,1.0f, 255,255,0,255);
d3Buffer->put( 1.0f,-1.0f,0.0f, 1.0f,0.0f, 0,255,255,255);
graphics3D->render(SCE_GXM_PRIMITIVE_TRIANGLES, d3Buffer, true);
graphics3D->render(mvp, SCE_GXM_PRIMITIVE_TRIANGLES, d3Buffer, true);

graphicsBase->stopDrawing();
graphicsBase->swapBuffers();
Expand Down

0 comments on commit 30be5fe

Please sign in to comment.