Add deinit
for preperation for web
This commit is contained in:
parent
05d0f63535
commit
27b822d7b1
@ -28,6 +28,7 @@ public:
|
|||||||
~Tree();
|
~Tree();
|
||||||
void draw(Rectangle dest, float rotation);
|
void draw(Rectangle dest, float rotation);
|
||||||
void newTree();
|
void newTree();
|
||||||
|
void deinit();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int size = 0;
|
int size = 0;
|
||||||
|
11
src/App.cpp
11
src/App.cpp
@ -20,6 +20,7 @@ void App::init()
|
|||||||
destA = CalculateRect(center, rotation, screenWidth, screenWidth);
|
destA = CalculateRect(center, rotation, screenWidth, screenWidth);
|
||||||
destB = {destA.x, destA.y, (float)screenWidth, (float)screenWidth};
|
destB = {destA.x, destA.y, (float)screenWidth, (float)screenWidth};
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::update()
|
void App::update()
|
||||||
{
|
{
|
||||||
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT))
|
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT))
|
||||||
@ -42,10 +43,18 @@ void App::update()
|
|||||||
destA = CalculateRect(center, rotation, screenWidth, screenWidth);
|
destA = CalculateRect(center, rotation, screenWidth, screenWidth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::draw()
|
void App::draw()
|
||||||
{
|
{
|
||||||
ClearBackground(RED);
|
ClearBackground(RED);
|
||||||
trees[pos].draw(destB, 0.0f);
|
trees[pos].draw(destB, 0.0f);
|
||||||
trees[1 - pos].draw(destA, rotation);
|
trees[1 - pos].draw(destA, rotation);
|
||||||
}
|
}
|
||||||
void App::deinit() {}
|
|
||||||
|
void App::deinit()
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < trees.size(); i++)
|
||||||
|
{
|
||||||
|
trees[i].deinit();
|
||||||
|
}
|
||||||
|
}
|
@ -17,7 +17,6 @@ Tree::Tree(int size)
|
|||||||
|
|
||||||
Tree::~Tree()
|
Tree::~Tree()
|
||||||
{
|
{
|
||||||
UnloadRenderTexture(target);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tree::draw(Rectangle dest, float rotation)
|
void Tree::draw(Rectangle dest, float rotation)
|
||||||
@ -38,6 +37,11 @@ void Tree::newTree()
|
|||||||
EndTextureMode();
|
EndTextureMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Tree::deinit()
|
||||||
|
{
|
||||||
|
UnloadRenderTexture(target);
|
||||||
|
}
|
||||||
|
|
||||||
// Private
|
// Private
|
||||||
|
|
||||||
Vector2 Tree::drawLine()
|
Vector2 Tree::drawLine()
|
||||||
|
@ -15,7 +15,7 @@ int main(void)
|
|||||||
InitWindow(screenWidth, screenHeight, name);
|
InitWindow(screenWidth, screenHeight, name);
|
||||||
#endif
|
#endif
|
||||||
SetTargetFPS(60);
|
SetTargetFPS(60);
|
||||||
{
|
|
||||||
App app(screenWidth, screenHeight);
|
App app(screenWidth, screenHeight);
|
||||||
app.init();
|
app.init();
|
||||||
while (!WindowShouldClose())
|
while (!WindowShouldClose())
|
||||||
@ -25,7 +25,7 @@ int main(void)
|
|||||||
app.draw();
|
app.draw();
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
}
|
}
|
||||||
}
|
app.deinit();
|
||||||
|
|
||||||
CloseWindow();
|
CloseWindow();
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user