- Main Page
- Classes
- Files

- File List
- File Members

# C:/Users/Public/AGS Final Folder/BFLETCHER D4010283/Source/Game/Source/BreakoutPauseScene.cpp

Go to the documentation of this file.

    00001 #include "BreakoutPauseScene.h"
    00002
    00003 #include "GameConfig.h"
    00004
    00005 #include "Vector2.h"
    00006
    00007 #include "ApplicationEvents.h"
    00008 #include "InputEvents.h"
    00009 #include "BreakoutEvents.h"
    00010 #include "EventManager.h"
    00011
    00012 BreakoutPauseScene::BreakoutPauseScene()
    00013 : m_bIsActive(false)
    00014 {
    00015
    00016 }
    00017
    00018 BreakoutPauseScene::~BreakoutPauseScene()
    00019 {
    00020
    00021 }
    00022
    00023 void BreakoutPauseScene::Initialise()
    00024 {
    00025         Visualisation* pVis = Visualisation::getSingleton();
    00026
    00027         m_vTextLines.push_back(pVis->CreateSpriteText("PAUSED", MENU_NORMAL_COLOUR));
    00028         m_vTextLines.push_back(pVis->CreateSpriteText("PRESS START TO CONTINUE", MENU_NORMAL_COLOUR));
    00029         m_vTextLines.push_back(pVis->CreateSpriteText("PRESS L, R AND START TO QUIT", MENU_NORMAL_COLOUR));
    00030
    00031         EventManager::getSingleton()->AddEventListener(ButtonInputEvent::cEventName, this);
    00032 }
    00033
    00034 void BreakoutPauseScene::Draw()
    00035 {
    00036         if(!m_bIsActive)
    00037                 return;
    00038
    00039         Visualisation* pVis = Visualisation::getSingleton();
    00040         pVis->ClearScreen();
    00041
    00042         SDL_Surface* pScreen = pVis->GetScreen();
    00043         Vector2i centre(pScreen->w / 2, pScreen->h / 2);
    00044
    00045         int numEntries = m_vTextLines.size();
    00046         int totalHeight = numEntries * CHARACTER_HEIGHT * 2; //Multiplied by 2 to add some spacing between entries.
    00047         int yPos = centre.y - (totalHeight / 2);
    00048
    00049         for(int i = 0 ; i < numEntries; i++)
    00050         {
    00051                 int xPos = centre.x - (pVis->GetSpriteWidth(m_vTextLines[i]) / 2);
    00052                 pVis->DrawSprite(m_vTextLines[i], xPos, yPos);
    00053
    00054                 yPos += CHARACTER_HEIGHT * 2;
    00055         }
    00056 }
    00057
    00058 void BreakoutPauseScene::Update()
    00059 {
    00060
    00061 }
    00062
    00063 void BreakoutPauseScene::Shutdown()
    00064 {
    00065         m_vTextLines.clear();
    00066 }
    00067
    00068 void BreakoutPauseScene::Activate()
    00069 {
    00070         m_bIsActive = true;
    00071 }
    00072
    00073 void BreakoutPauseScene::Deactivate()
    00074 {
    00075         m_bIsActive = false;
    00076 }
    00077
    00078 bool BreakoutPauseScene::HandleEvent(IEvent *pEvent)
    00079 {
    00080         if(!m_bIsActive)
    00081                 return false;
    00082
    00083         if(pEvent->GetEventType() == ButtonInputEvent::cEventName)
    00084         {
    00085                 ButtonInputEvent* pButtonEvent = (ButtonInputEvent*)pEvent;
    00086                 int key = pButtonEvent->GetKey();
    00087
    00088                 if(key == eKeyButtonStart && pButtonEvent->IsKeyDown())
    00089                 {
    00090                         BreakoutUnpauseGameEvent* pEvent = new BreakoutUnpauseGameEvent();
    00091                         EventManager::getSingleton()->QueueEvent(pEvent);
    00092                 }
    00093         }
    00094
    00095         return false;
    00096 }