Week 9 | Red Plane1942

I’ve been working on a menu system by creating classes such as the following:

  • GUI_Element: Is the base class for all GUI classes.
  • GUI_Label: Contains a Draw() function and a SpriteText* variable. It can also be parented to another GUI_Element.
  • GUI_Image: Contains a Draw() function and a Sprite* variable. It can also be parented to another GUI_Element.
  • GUI_Button: Contains a Draw() and a CheckCollision() function, a Collider* variable, a GUI_Label* variable and two GUI_Image* variables. One image is for the button sprite. The other image is as an overlay image for when the button is hovered. The button will draw the first image and then draw the label and lastly draw the second image ontop of everything if the button is hovered by the mouse.

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.

About Semih Parlayan

2014  Programming