-
Notifications
You must be signed in to change notification settings - Fork 0
/
MenuScreen.cpp
107 lines (93 loc) · 3.78 KB
/
MenuScreen.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/**
* Copyright (C) Kevin J. Estevez (kenystev) and Luis C. Isaula (lisaula)
*
* GNU GENERAL PUBLIC LICENSE Version 2
* The licenses for most software are designed to take away your
* freedom to share and change it. By contrast, the GNU General Public
* License is intended to guarantee your freedom to share and change free
* software--to make sure the software is free for all its users. This
* General Public License applies to most of the Free Software
* Foundation's software and to any other program whose authors commit to
* using it.
*/
#include "MenuScreen.h"
#include "RaceGear.h"
MenuScreen::MenuScreen(Game*game)
{
this->game=game;
}
MenuScreen::~MenuScreen()
{
//dtor
}
void MenuScreen::show ()
{
((RaceGear*)game)->selected_car = 0;
((RaceGear*)game)->selected_track = "pista_novato.xml";
((RaceGear*)game)->name_player="";
((RaceGear*)game)->seg=0;
((RaceGear*)game)->id_pista=1;
//Fondo init
fondo= game->rosalila_graphics->getTexture(assets_directory+"Menu.png");
//Play button init
pu = game->rosalila_graphics->getTexture(assets_directory+"PLAY_UP.png");
pd = game->rosalila_graphics->getTexture(assets_directory+"PLAY_DWN.png");
centro_x=game->rosalila_graphics->screen_width/2-(pu->getWidth()/2);
centro_y=game->rosalila_graphics->screen_height/2-(pu->getHeight()/2);
Pb = new PlayButton(centro_x,centro_y-100,pu,pd,game->rosalila_graphics, this->game);
//Instrctions Button init
iu = game->rosalila_graphics->getTexture(assets_directory+"INSTR_UP.png");
id = game->rosalila_graphics->getTexture(assets_directory+"INSTR_DWN.png");
centro_x=game->rosalila_graphics->screen_width/2-(iu->getWidth()/2);
centro_y=game->rosalila_graphics->screen_height/2-(iu->getHeight()/2);
Ib = new InstrButton(centro_x,centro_y,iu,id,game->rosalila_graphics,this->game);
//Ranking Button init
ru = game->rosalila_graphics->getTexture(assets_directory+"RANK_UP.png");
rd = game->rosalila_graphics->getTexture(assets_directory+"RANK_DWN.png");
centro_x=game->rosalila_graphics->screen_width/2-(ru->getWidth()/2);
centro_y=game->rosalila_graphics->screen_height/2-(ru->getHeight()/2);
Rb = new RankButton(centro_x,centro_y+100,ru,rd,game->rosalila_graphics,this->game);
//Exit Button init
eu = game->rosalila_graphics->getTexture(assets_directory+"EXIT_UP.png");
ed = game->rosalila_graphics->getTexture(assets_directory+"EXIT_DWN.png");
centro_x=game->rosalila_graphics->screen_width/2-(eu->getWidth()/2);
centro_y=game->rosalila_graphics->screen_height/2-(eu->getHeight()/2);
Eb = new ExitButton(centro_x,centro_y+200,eu,ed,game->rosalila_graphics);
mouse_x=0;
mouse_y=0;
click=false;
}
void MenuScreen::render (RosalilaGraphics*painter)
{
update();
painter->draw2DImage(fondo,fondo->getWidth(),fondo->getHeight(),0,0,1,0,false,0,0,Color(255,255,255,255),0,0,false);
mouse_x = game->receiver->getMouse_X();
mouse_y = game->receiver->getMouse_Y();
click = game->receiver->isLeftClickDown();
Pb->draw(mouse_x,mouse_y,click);
Ib->draw(mouse_x,mouse_y,click);
Rb->draw(mouse_x,mouse_y,click);
Eb->draw(mouse_x,mouse_y,click);
}
// void resize (int width, int height);
void MenuScreen::pause ()
{
}
void MenuScreen::resume ()
{
}
void MenuScreen::hide ()
{
}
void MenuScreen::dispose ()
{
}
void MenuScreen::update(){
mouse_x = game->receiver->getMouse_X();
mouse_y = game->receiver->getMouse_Y();
click = game->receiver->isLeftClickDown();
Pb->update(mouse_x,mouse_y,click);
Ib->update(mouse_x,mouse_y,click);
Rb->update(mouse_x,mouse_y,click);
Eb->update(mouse_x,mouse_y,click);
}