Week 9 | Red Plane1942
|
I’ve been working on a menu system by creating classes such as the following:
This is how my GUI_Image class looks like: #include "stdafx.h"
#include "GUI_Image.h"
#include "DrawManager.h"
GUI_Image::GUI_Image(GUI_Element* parent, int x, int y, Sprite* sprite)
{
//Image
m_sprite = sprite;
//Element
if (parent != nullptr)
{
m_x = parent->GetX() + x;
m_y = parent->GetY() + y;
}
else
{
m_x = x;
m_y = y;
}
}
GUI_Image::~GUI_Image()
{
}
//Element
int GUI_Image::GetX()
{
return m_x;
}
int GUI_Image::GetY()
{
return m_y;
}
//Image
void GUI_Image::Draw(DrawManager* drawManager)
{
drawManager->Draw(m_sprite, m_x, m_y);
}
Sprite* GUI_Image::GetSprite()
{
return m_sprite;
}
I’ve also finished the high score system. It saves the top five users score inside a .txt file. When the game reaches game over the game switches to a HighScoreState. Inside this state i check if the last users score is higher than than any of the other scores on the list. If it is I add the last score to the list and remove the lowest score. The user is also able to enter his/her name. |