-
Notifications
You must be signed in to change notification settings - Fork 0
/
MenuState.cpp
executable file
·51 lines (44 loc) · 1.37 KB
/
MenuState.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <iostream>
#include "MenuState.h"
#include "ResourceManager.h"
#include "Button.h"
#include "foo.h"
#include "SpriteManager.h"
MenuState::MenuState(){
startGame = NULL;
quitGame = NULL;
background = NULL;
}
MenuState::~MenuState(){
std::cout << "menustate destructor called" << std::endl;
}
void MenuState::update(){
startGame->update();
quitGame->update();
//SpriteManager::INSTANCE()->update();
}
void MenuState::render(SDL_Surface* screen){
SDL_Rect offset;
offset.x = 0;
offset.y = 0;
SDL_BlitSurface( background, NULL, screen, &offset );
//SpriteManager::INSTANCE()->render(screen);
startGame->render(screen);
quitGame->render(screen);
}
void MenuState::uninstall(){
/*
delete startGame;
startGame = NULL;
delete quitGame;
quitGame = NULL;
delete background;
background = NULL;
*/
}
void MenuState::install(){
if(background == NULL) background = ResourceManager::INSTANCE()->loadImage("resources/images/menuBackground.png");
if(startGame == NULL) startGame = new Button<Game,void,Game::STATE>("Start",425,350,&*Game::INSTANCE(),&Game::setState,Game::RUNNING_STATE);
if(quitGame == NULL) quitGame= new Button<Game,void,Game::STATE>("Quit",425,390,&*Game::INSTANCE(),&Game::setState,Game::QUIT_STATE);
//SpriteManager::INSTANCE()->generateAsteroidWave();
}