Major changes

This commit is contained in:
Vladislav Khorev 2018-07-23 01:56:46 +05:00
parent d605cf62f6
commit ea6e4ff654
55 changed files with 363 additions and 332 deletions

View File

@ -43,7 +43,10 @@
"name": "level3" "name": "level3"
}, },
{ {
"name": "level3" "name": "level4"
},
{
"name": "level5"
} }
] ]
}, },
@ -61,6 +64,15 @@
}, },
{ {
"name": "level7" "name": "level7"
},
{
"name": "level3"
},
{
"name": "level4"
},
{
"name": "level5"
} }
] ]
}, },

View File

@ -6,11 +6,12 @@
"width": "match_parent", "width": "match_parent",
"height": "match_parent", "height": "match_parent",
"visible" : 0, "visible" : 0,
"touchTransparency": 0,
"horizontalAlignment": "HA_CENTER", "horizontalAlignment": "HA_CENTER",
"verticalAlignment": "VA_CENTER", "verticalAlignment": "VA_CENTER",
"children": [{ "children": [{
"type": "VerticalScrollLayout", "type": "VerticalScrollLayout",
"name": "leftSidePanel", "name": "panel",
"background": "#faf0ffFF", "background": "#faf0ffFF",
"borderType": "line", "borderType": "line",
"borderColor": "#808080FF", "borderColor": "#808080FF",
@ -18,17 +19,16 @@
"height": "match_parent", "height": "match_parent",
"touchTransparency": 0, "touchTransparency": 0,
"zLevel": 10, "zLevel": 10,
"marginTop" : 40, "marginTop" : 0,
"marginBottom" : 40, "marginBottom" : 0,
"paddingTop": 60, "paddingTop": 10,
"paddingBottom": 10, "paddingBottom": 10,
"paddingLeft": 10, "paddingLeft": 10,
"paddingRight": 10, "paddingRight": 10,
"itemSpacing": 20, "itemSpacing": 20,
"children" : [{ "children" : [{
"type": "HorizontalLinearLayout", "type": "HorizontalLinearLayout",
"name": "embroiderySettings", "name": "row1",
"itemSpacing": 30,
"paddingBottom": 15, "paddingBottom": 15,
"paddingTop": 15, "paddingTop": 15,
"paddingLeft": 15, "paddingLeft": 15,
@ -36,43 +36,43 @@
"background": "#faf0ffFF", "background": "#faf0ffFF",
"borderType": "line", "borderType": "line",
"borderColor": "#808080FF", "borderColor": "#808080FF",
"width": "wrap_content", "width": 454,
"height": "wrap_content", "height": "wrap_content",
"touchTransparency": 0, "touchTransparency": 0,
"itemSpacing": 20, "itemSpacing": 20,
"visible": 1, "visible": 1,
"children": [{ "children": [{
"type": "Button", "type": "Button",
"name": "button6", "name": "button0",
"width": 128, "width": 128,
"height": 80, "height": 80,
"background": "level1_prerender", "background": "#00000000",
"pressedDrawable": "#60606060", "pressedDrawable": "#60606060",
"hoverDrawable": "#60606060" "hoverDrawable": "#60606060"
}, },
{ {
"type": "Button", "type": "Button",
"name": "button7", "name": "button1",
"width": 128, "width": 128,
"height": 80, "height": 80,
"background": "level2_prerender", "background": "#00000000",
"pressedDrawable": "#60606060", "pressedDrawable": "#60606060",
"hoverDrawable": "#60606060" "hoverDrawable": "#60606060"
}, },
{ {
"type": "Button", "type": "Button",
"name": "button8", "name": "button2",
"width": 128, "width": 128,
"height": 80, "height": 80,
"background": "level3_prerender", "background": "#00000000",
"pressedDrawable": "#60606060", "pressedDrawable": "#60606060",
"hoverDrawable": "#60606060" "hoverDrawable": "#60606060"
}] }]
}, },
{ {
"type": "HorizontalLinearLayout", "type": "HorizontalLinearLayout",
"name": "embroiderySettings", "name": "row2",
"itemSpacing": 30, "itemSpacing": 20,
"paddingBottom": 15, "paddingBottom": 15,
"paddingTop": 15, "paddingTop": 15,
"paddingLeft": 15, "paddingLeft": 15,
@ -80,42 +80,42 @@
"background": "#faf0ffFF", "background": "#faf0ffFF",
"borderType": "line", "borderType": "line",
"borderColor": "#808080FF", "borderColor": "#808080FF",
"width": "wrap_content", "width": 454,
"height": "wrap_content", "height": "wrap_content",
"touchTransparency": 0, "touchTransparency": 0,
"visible": 1, "visible": 1,
"children": [{ "children": [{
"type": "Button", "type": "Button",
"name": "button6", "name": "button3",
"width": 128, "width": 128,
"height": 80, "height": 80,
"background": "level4_prerender", "background": "#00000000",
"pressedDrawable": "#60606060", "pressedDrawable": "#60606060",
"hoverDrawable": "#60606060" "hoverDrawable": "#60606060"
}, },
{ {
"type": "Button", "type": "Button",
"name": "button7", "name": "button4",
"width": 128, "width": 128,
"height": 80, "height": 80,
"background": "level5_prerender", "background": "#00000000",
"pressedDrawable": "#60606060", "pressedDrawable": "#60606060",
"hoverDrawable": "#60606060" "hoverDrawable": "#60606060"
}, },
{ {
"type": "Button", "type": "Button",
"name": "button8", "name": "button5",
"width": 128, "width": 128,
"height": 80, "height": 80,
"background": "level6_prerender", "background": "#00000000",
"pressedDrawable": "#60606060", "pressedDrawable": "#60606060",
"hoverDrawable": "#60606060" "hoverDrawable": "#60606060"
}] }]
}, },
{ {
"type": "HorizontalLinearLayout", "type": "HorizontalLinearLayout",
"name": "embroiderySettings", "name": "row3",
"itemSpacing": 30, "itemSpacing": 20,
"paddingBottom": 15, "paddingBottom": 15,
"paddingTop": 15, "paddingTop": 15,
"paddingLeft": 15, "paddingLeft": 15,
@ -123,7 +123,7 @@
"background": "#faf0ffFF", "background": "#faf0ffFF",
"borderType": "line", "borderType": "line",
"borderColor": "#808080FF", "borderColor": "#808080FF",
"width": "wrap_content", "width": 454,
"height": "wrap_content", "height": "wrap_content",
"touchTransparency": 1, "touchTransparency": 1,
"visible": 1, "visible": 1,
@ -132,7 +132,7 @@
"name": "button6", "name": "button6",
"width": 128, "width": 128,
"height": 80, "height": 80,
"background": "level7_prerender", "background": "#00000000",
"pressedDrawable": "#60606060", "pressedDrawable": "#60606060",
"hoverDrawable": "#60606060" "hoverDrawable": "#60606060"
}, },
@ -141,7 +141,7 @@
"name": "button7", "name": "button7",
"width": 128, "width": 128,
"height": 80, "height": 80,
"background": "level8_prerender", "background": "#00000000",
"pressedDrawable": "#60606060", "pressedDrawable": "#60606060",
"hoverDrawable": "#60606060" "hoverDrawable": "#60606060"
}, },
@ -150,15 +150,15 @@
"name": "button8", "name": "button8",
"width": 128, "width": 128,
"height": 80, "height": 80,
"background": "level9_prerender", "background": "#00000000",
"pressedDrawable": "#60606060", "pressedDrawable": "#60606060",
"hoverDrawable": "#60606060" "hoverDrawable": "#60606060"
}] }]
}, },
{ {
"type": "HorizontalLinearLayout", "type": "HorizontalLinearLayout",
"name": "embroiderySettings", "name": "row4",
"itemSpacing": 30, "itemSpacing": 20,
"paddingBottom": 15, "paddingBottom": 15,
"paddingTop": 15, "paddingTop": 15,
"paddingLeft": 15, "paddingLeft": 15,
@ -166,34 +166,34 @@
"background": "#faf0ffFF", "background": "#faf0ffFF",
"borderType": "line", "borderType": "line",
"borderColor": "#808080FF", "borderColor": "#808080FF",
"width": "wrap_content", "width": 454,
"height": "wrap_content", "height": "wrap_content",
"touchTransparency": 0, "touchTransparency": 0,
"visible": 1, "visible": 1,
"children": [{ "children": [{
"type": "Button", "type": "Button",
"name": "button6", "name": "button9",
"width": 128, "width": 128,
"height": 80, "height": 80,
"background": "level10_prerender", "background": "#00000000",
"pressedDrawable": "#60606060", "pressedDrawable": "#60606060",
"hoverDrawable": "#60606060" "hoverDrawable": "#60606060"
}, },
{ {
"type": "Button", "type": "Button",
"name": "button7", "name": "button10",
"width": 128, "width": 128,
"height": 80, "height": 80,
"background": "level11_prerender", "background": "#00000000",
"pressedDrawable": "#60606060", "pressedDrawable": "#60606060",
"hoverDrawable": "#60606060" "hoverDrawable": "#60606060"
}, },
{ {
"type": "Button", "type": "Button",
"name": "button8", "name": "button11",
"width": 128, "width": 128,
"height": 80, "height": 80,
"background": "level12_prerender", "background": "#00000000",
"pressedDrawable": "#60606060", "pressedDrawable": "#60606060",
"hoverDrawable": "#60606060" "hoverDrawable": "#60606060"
}] }]

View File

@ -1,3 +1,4 @@
022259762-alien-world.jpg
0, 255, 255, 255 0, 255, 255, 255
0, 0, 0, 255 0, 0, 0, 255
255, 0, 0, 255 255, 0, 0, 255
@ -18,14 +19,14 @@ Colormap
000000000000 000000000000
000000000000 000000000000
Brickmap Brickmap
111111111111
111111111111
111111111111
000000000000 000000000000
111111111111
111111111111
000000000000 000000000000
111111111111 000000000000
000000000000
000000000000
000000000000
000000000000
000000000000
111111111111 111111111111
000000000000 000000000000
000000000000 000000000000

View File

@ -1,3 +1,4 @@
shutterstock10.png
0, 255, 255, 255 0, 255, 255, 255
0, 0, 0, 255 0, 0, 0, 255
255, 0, 190, 255 255, 0, 190, 255

View File

@ -1,3 +1,4 @@
shutterstock11.png
255, 255, 255, 255 255, 255, 255, 255
0, 0, 0, 255 0, 0, 0, 255
0, 237, 255, 255 0, 237, 255, 255

View File

@ -1,3 +1,4 @@
shutterstock12.png
255, 128, 128, 255 255, 128, 128, 255
0, 0, 0, 255 0, 0, 0, 255
159, 240, 255, 255 159, 240, 255, 255

View File

@ -1,3 +1,4 @@
shutterstock2.png
255, 0, 0, 255 255, 0, 0, 255
0, 0, 0, 255 0, 0, 0, 255
0, 255, 255, 255 0, 255, 255, 255

View File

@ -1,3 +1,4 @@
shutterstock3.png
0, 255, 255, 255 0, 255, 255, 255
0, 0, 0, 255 0, 0, 0, 255
0, 151, 113, 255 0, 151, 113, 255

View File

@ -1,3 +1,4 @@
shutterstock4.png
255, 0, 0, 255 255, 0, 0, 255
0, 0, 0, 255 0, 0, 0, 255
101, 97, 255, 255 101, 97, 255, 255

View File

@ -1,3 +1,4 @@
shutterstock5.png
255, 0, 255, 255 255, 0, 255, 255
0, 0, 0, 255 0, 0, 0, 255
163, 255, 198, 255 163, 255, 198, 255

View File

@ -1,3 +1,4 @@
shutterstock6.png
255, 255, 255, 255 255, 255, 255, 255
0, 0, 0, 255 0, 0, 0, 255
255, 200, 5, 255 255, 200, 5, 255

View File

@ -1,3 +1,4 @@
shutterstock7.png
255, 255, 0, 255 255, 255, 0, 255
0, 0, 0, 255 0, 0, 0, 255
230, 230, 230, 255 230, 230, 230, 255

View File

@ -1,3 +1,4 @@
shutterstock8.png
0, 255, 255, 255 0, 255, 255, 255
0, 0, 0, 255 0, 0, 0, 255
217, 56, 62, 255 217, 56, 62, 255

View File

@ -1,3 +1,4 @@
shutterstock9.png
0, 255, 0, 255 0, 255, 0, 255
0, 0, 0, 255 0, 0, 0, 255
255, 221, 0, 255 255, 221, 0, 255

View File

Before

Width:  |  Height:  |  Size: 776 KiB

After

Width:  |  Height:  |  Size: 776 KiB

View File

Before

Width:  |  Height:  |  Size: 818 KiB

After

Width:  |  Height:  |  Size: 818 KiB

View File

Before

Width:  |  Height:  |  Size: 2.0 MiB

After

Width:  |  Height:  |  Size: 2.0 MiB

View File

Before

Width:  |  Height:  |  Size: 1.8 MiB

After

Width:  |  Height:  |  Size: 1.8 MiB

View File

Before

Width:  |  Height:  |  Size: 4.2 MiB

After

Width:  |  Height:  |  Size: 4.2 MiB

View File

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB

View File

Before

Width:  |  Height:  |  Size: 1.3 MiB

After

Width:  |  Height:  |  Size: 1.3 MiB

View File

Before

Width:  |  Height:  |  Size: 754 KiB

After

Width:  |  Height:  |  Size: 754 KiB

View File

Before

Width:  |  Height:  |  Size: 811 KiB

After

Width:  |  Height:  |  Size: 811 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 MiB

After

Width:  |  Height:  |  Size: 1.7 MiB

View File

Before

Width:  |  Height:  |  Size: 2.1 MiB

After

Width:  |  Height:  |  Size: 2.1 MiB

View File

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB

View File

Before

Width:  |  Height:  |  Size: 739 KiB

After

Width:  |  Height:  |  Size: 739 KiB

View File

Before

Width:  |  Height:  |  Size: 725 KiB

After

Width:  |  Height:  |  Size: 725 KiB

View File

Before

Width:  |  Height:  |  Size: 390 KiB

After

Width:  |  Height:  |  Size: 390 KiB

View File

Before

Width:  |  Height:  |  Size: 840 KiB

After

Width:  |  Height:  |  Size: 840 KiB

View File

Before

Width:  |  Height:  |  Size: 2.0 MiB

After

Width:  |  Height:  |  Size: 2.0 MiB

View File

Before

Width:  |  Height:  |  Size: 3.6 MiB

After

Width:  |  Height:  |  Size: 3.6 MiB

View File

Before

Width:  |  Height:  |  Size: 5.5 MiB

After

Width:  |  Height:  |  Size: 5.5 MiB

View File

Before

Width:  |  Height:  |  Size: 9.2 MiB

After

Width:  |  Height:  |  Size: 9.2 MiB

View File

Before

Width:  |  Height:  |  Size: 480 KiB

After

Width:  |  Height:  |  Size: 480 KiB

View File

Before

Width:  |  Height:  |  Size: 362 KiB

After

Width:  |  Height:  |  Size: 362 KiB

View File

Before

Width:  |  Height:  |  Size: 433 KiB

After

Width:  |  Height:  |  Size: 433 KiB

View File

Before

Width:  |  Height:  |  Size: 370 KiB

After

Width:  |  Height:  |  Size: 370 KiB

View File

Before

Width:  |  Height:  |  Size: 464 KiB

After

Width:  |  Height:  |  Size: 464 KiB

View File

Before

Width:  |  Height:  |  Size: 532 KiB

After

Width:  |  Height:  |  Size: 532 KiB

View File

Before

Width:  |  Height:  |  Size: 611 KiB

After

Width:  |  Height:  |  Size: 611 KiB

View File

Before

Width:  |  Height:  |  Size: 509 KiB

After

Width:  |  Height:  |  Size: 509 KiB

View File

Before

Width:  |  Height:  |  Size: 503 KiB

After

Width:  |  Height:  |  Size: 503 KiB

View File

Before

Width:  |  Height:  |  Size: 553 KiB

After

Width:  |  Height:  |  Size: 553 KiB

View File

Before

Width:  |  Height:  |  Size: 597 KiB

After

Width:  |  Height:  |  Size: 597 KiB

View File

Before

Width:  |  Height:  |  Size: 474 KiB

After

Width:  |  Height:  |  Size: 474 KiB

View File

@ -0,0 +1,19 @@
precision highp float;
uniform sampler2D Texture;
varying vec2 texCoord;
varying vec4 color;
void main()
{
vec4 texColor = texture2D(Texture,texCoord).rgba;
vec4 resultColor = color * texColor.rgba;
float c = (resultColor.r * 0.3 + resultColor.g * 0.59 + resultColor.b * 0.11);
gl_FragColor = vec4(c,c,c,resultColor.a);
}

View File

@ -0,0 +1,14 @@
attribute vec3 vPosition;
attribute vec2 vTexCoord;
attribute vec4 vColor;
varying vec2 texCoord;
varying vec4 color;
uniform mat4 ProjectionMatrix;
void main()
{
//480x320
gl_Position = ProjectionMatrix * vec4(vPosition.xyz, 1.0);
texCoord = vTexCoord;
color = vColor;
}

View File

@ -52,9 +52,8 @@ bool GalaxyMenu::InitGalaxyMenu(std::string config_json, float scale) {
std::string levelName = levels_pt.second.get<std::string>("name", "empty"); std::string levelName = levels_pt.second.get<std::string>("name", "empty");
TGameLevel lvl; std::shared_ptr<TGameLevel> lvl = std::make_shared<TGameLevel>();
lvl.FillWithFile(ST::PathToResources + levelName + ".txt"); lvl->FillWithFile(ST::PathToResources + levelName + ".txt");
lvl.setBackground("shutterstock" + std::to_string(levelIndex++));
star.selectionMenu.gameLevels.push_back(lvl); star.selectionMenu.gameLevels.push_back(lvl);
} }
@ -63,6 +62,7 @@ bool GalaxyMenu::InitGalaxyMenu(std::string config_json, float scale) {
galaxies.push_back(galax); galaxies.push_back(galax);
} }
return true; return true;
} }
catch (boost::property_tree::ptree_error) { catch (boost::property_tree::ptree_error) {
@ -70,6 +70,9 @@ bool GalaxyMenu::InitGalaxyMenu(std::string config_json, float scale) {
} }
} }
void GalaxyMenu::UpdateGalaxyMenu(float s_width, float s_height, size_t dt) { void GalaxyMenu::UpdateGalaxyMenu(float s_width, float s_height, size_t dt) {
/*..Reset..*/ /*..Reset..*/
galaxies_params.clear(); galaxies_params.clear();
@ -136,106 +139,6 @@ void GalaxyMenu::UpdateGalaxyMenu(float s_width, float s_height, size_t dt) {
stars_params.push_back(star_params); stars_params.push_back(star_params);
} }
/*..Level list geometry..*/
for (int i = 0; i < galaxies.size(); i++) {
for (int j = 0; j < galaxies[i].Stars.size(); j++) {
float button_x_dim = ((1.f - (galaxies[i].Stars[j].selectionMenu.border_x_offset * 2 + (galaxies[i].Stars[j].selectionMenu.columns - 1)*galaxies[i].Stars[j].selectionMenu.buttons_offset)) / galaxies[i].Stars[j].selectionMenu.columns); // relative size
int rows_count = (int)ceil((float)galaxies[i].Stars[j].selectionMenu.gameLevels.size() / (float)galaxies[i].Stars[j].selectionMenu.columns);
galaxies[i].Stars[j].selectionMenu.params = std::make_pair(
Eigen::Vector2f(
gameScreenCenter(0) + (galaxies[i].Stars[j].selectionMenu.offset(0) * gameScreenWidth / 2),
gameScreenCenter(1) + (galaxies[i].Stars[j].selectionMenu.offset(1) * gameScreenHeight / 2)
),
Eigen::Vector2f(
gameScreenWidth * galaxies[i].Stars[j].selectionMenu.dim(0),
//gameScreenHeight * galaxies[i].Stars[j].selectionMenu.dim(1)
//gameScreenHeight * galaxies[i].Stars[j].selectionMenu.dim(1) * (galaxies[i].Stars[j].selectionMenu.border_y_offset * 2 + (ceil(galaxies[i].Stars[j].selectionMenu.levels.size() / galaxies[i].Stars[j].selectionMenu.columns) - 1)*galaxies[i].Stars[j].selectionMenu.buttons_offset) + galaxies[i].Stars[j].selectionMenu.dim(0)*(ceil(galaxies[i].Stars[j].selectionMenu.levels.size() / galaxies[i].Stars[j].selectionMenu.columns)*(button_x_dim / galaxies[i].Stars[j].selectionMenu.buttons_ratio))
gameScreenWidth * galaxies[i].Stars[j].selectionMenu.dim(0) * (galaxies[i].Stars[j].selectionMenu.border_y_offset * 2 + rows_count*(button_x_dim/galaxies[i].Stars[j].selectionMenu.buttons_ratio) + (rows_count-1)*galaxies[i].Stars[j].selectionMenu.border_y_offset)
)
);
/*..buttons plane..*/
galaxies[i].Stars[j].selectionMenu.buttons_plane = std::make_pair(
Eigen::Vector2f(
galaxies[i].Stars[j].selectionMenu.params.first(0) + galaxies[i].Stars[j].selectionMenu.params.second(0) / 2 * galaxies[i].Stars[j].selectionMenu.plane_pos(0),
galaxies[i].Stars[j].selectionMenu.params.first(1) + galaxies[i].Stars[j].selectionMenu.params.second(1) / 2 * galaxies[i].Stars[j].selectionMenu.plane_pos(1)
),
Eigen::Vector2f(
galaxies[i].Stars[j].selectionMenu.params.second(0) * galaxies[i].Stars[j].selectionMenu.plane_size(0),
galaxies[i].Stars[j].selectionMenu.params.second(1) * galaxies[i].Stars[j].selectionMenu.plane_size(1)
)
);
// buttons
std::vector<std::pair<Eigen::Vector2f, Eigen::Vector2f>> buttons_params;
std::vector<std::vector<GameLevelInterior>> interior_params;
int levelsCount = galaxies[i].Stars[j].selectionMenu.gameLevels.size();
buttons_params.resize(levelsCount);
interior_params.resize(levelsCount);
for (int v = 0; v < interior_params.size(); v++) {
interior_params[v].resize(CONST_BRICKMATRIX_HEIGHT*CONST_BRICKMATRIX_WIDTH);
}
for (int y = 0; y < levelsCount; y++) {
GameLevelInterior levelInter;
float x_rpos = (galaxies[i].Stars[j].selectionMenu.border_x_offset + (y - floor((float)y / (float)galaxies[i].Stars[j].selectionMenu.columns)*(float)galaxies[i].Stars[j].selectionMenu.columns)*(button_x_dim + galaxies[i].Stars[j].selectionMenu.buttons_offset) + button_x_dim/2);
//float y_rpos = (/**/ galaxies[i].Stars[j].selectionMenu.border_y_offset + (floor((float)y / (float)galaxies[i].Stars[j].selectionMenu.columns))*(/*..*/ galaxies[i].Stars[j].selectionMenu.buttons_offset + button_x_dim / galaxies[i].Stars[j].selectionMenu.buttons_ratio /*..*/) + button_x_dim/galaxies[i].Stars[j].selectionMenu.buttons_ratio/2 /**/);
float y_rpos = (galaxies[i].Stars[j].selectionMenu.border_y_offset + ((int)floor(((float)y)/((float)galaxies[i].Stars[j].selectionMenu.columns)))*(button_x_dim/galaxies[i].Stars[j].selectionMenu.buttons_ratio) + (((int)floor(((float)y) / ((float)galaxies[i].Stars[j].selectionMenu.columns)))) * galaxies[i].Stars[j].selectionMenu.border_y_offset + ((button_x_dim/galaxies[i].Stars[j].selectionMenu.buttons_ratio)/2.f));
buttons_params[y] = std::make_pair(
Eigen::Vector2f(
(galaxies[i].Stars[j].selectionMenu.buttons_plane.first(0) - galaxies[i].Stars[j].selectionMenu.buttons_plane.second(0)/2) + galaxies[i].Stars[j].selectionMenu.buttons_plane.second(0)*x_rpos,
(galaxies[i].Stars[j].selectionMenu.buttons_plane.first(1) + galaxies[i].Stars[j].selectionMenu.buttons_plane.second(1)/2) - galaxies[i].Stars[j].selectionMenu.buttons_plane.second(0)*y_rpos
),
Eigen::Vector2f(
button_x_dim*galaxies[i].Stars[j].selectionMenu.buttons_plane.second(0),
(button_x_dim / galaxies[i].Stars[j].selectionMenu.buttons_ratio)*galaxies[i].Stars[j].selectionMenu.buttons_plane.second(0)
)
);
/*..Interior params..*/
/*.matrix init.*/
int brickMatr[CONST_BRICKMATRIX_WIDTH][CONST_BRICKMATRIX_HEIGHT];
for (int w = 0; w < CONST_BRICKMATRIX_WIDTH; w++)
{
for (int h = 0; h < CONST_BRICKMATRIX_HEIGHT; h++)
{
if (galaxies[i].Stars[j].selectionMenu.gameLevels[y].BlockMatrix[w][h].IsAppear()) {
brickMatr[w][h] = 1;
}
else {
brickMatr[w][h] = 0;
}
}
}
/*.params init.*/
float brick_w = 0.06f;
float brick_ratio = 1.6f;
float brick_h = brick_w / brick_ratio;
float xb_offset = 0.01f; // x border offset * 0.5
float yb_offset = 0.01f; // offset from top
int loop_itr = 0;
for (int w = 0; w < CONST_BRICKMATRIX_WIDTH; w++) {
for (int h = 0; h < CONST_BRICKMATRIX_HEIGHT; h++) {
levelInter.position = Eigen::Vector2f(
(buttons_params[y].first(0) - buttons_params[y].second(0)*0.5f) + (xb_offset + brick_w * w + brick_w * 0.5f) * buttons_params[y].second(0),
(buttons_params[y].first(1) + buttons_params[y].second(1)*0.5f) - (yb_offset + brick_h * h + brick_h * 0.5f)*buttons_params[y].second(1)
);
levelInter.dimensions = Eigen::Vector2f(
buttons_params[y].second(0)*brick_w/* * brickMatr[w][h]*/, //drawable block coefficient - #NOW NEED TO BE FIXED AT (matrix init) sections#
buttons_params[y].second(1)*brick_h/* * brickMatr[w][h]*/
);
//inited
interior_params[y][loop_itr++] = levelInter;
}
}
}
galaxies[i].Stars[j].selectionMenu.levelInterior = interior_params;
galaxies[i].Stars[j].selectionMenu.buttons = buttons_params;
}
}
} }
Eigen::Vector2f GalaxyMenu::textureSizeNormalize(Eigen::Vector2f texVec, int t_type) { Eigen::Vector2f GalaxyMenu::textureSizeNormalize(Eigen::Vector2f texVec, int t_type) {
@ -359,6 +262,7 @@ void GalaxyMenu::InteractWithGalaxy(size_t dt) {
} }
} }
/*
else if (menuState == 1) { // zoomed galaxy else if (menuState == 1) { // zoomed galaxy
} }
@ -372,7 +276,7 @@ void GalaxyMenu::InteractWithGalaxy(size_t dt) {
// OnTapDown->OnMove-> // OnTapDown->OnMove->
//totalTapShift = Eigen::Vector2f(totalTapShift(0) + currentTapShift(0), totalTapShift(1) + currentTapShift(1)); //totalTapShift = Eigen::Vector2f(totalTapShift(0) + currentTapShift(0), totalTapShift(1) + currentTapShift(1));
} }
} }*/
// \_/\_/\_/\_/ timer active \_/\_/\_/\_/ // \_/\_/\_/\_/ timer active \_/\_/\_/\_/
} }
@ -385,22 +289,19 @@ void GalaxyMenu::InteractWithGalaxy(size_t dt) {
/*..level select menu open..*/ /*..level select menu open..*/
starIndex = findPlanetByPos(lastTapPos); starIndex = findPlanetByPos(lastTapPos);
if (starIndex != -1) { if (starIndex != -1) {
planetHoverIndex = starIndex; planetHoverIndex = starIndex;
menuState = 2; Application->SetupGalaxyUi(starIndex);
}
else {
planetHoverIndex = -1;
}
if (starIndex != -1)
{
ResourceManager->newGuiManager.findWidgetByName("modal_background")->setVisibility(true); ResourceManager->newGuiManager.findWidgetByName("modal_background")->setVisibility(true);
} }
timer_active = false;
} }/*
else if (menuState == 1) { // zoomed galaxy else if (menuState == 1) { // zoomed galaxy
if (totalTapShift(0) == 0.f && totalTapShift(1) == 0.f) { if (totalTapShift(0) == 0.f && totalTapShift(1) == 0.f) {
// OnTapDown->OnTapUp // OnTapDown->OnTapUp
@ -413,6 +314,8 @@ void GalaxyMenu::InteractWithGalaxy(size_t dt) {
} }
else if (menuState == 2) { // level select view else if (menuState == 2) { // level select view
if (totalTapShift(0) == 0.f && totalTapShift(1) == 0.f) { if (totalTapShift(0) == 0.f && totalTapShift(1) == 0.f) {
// OnTapDown->OnTapUp // OnTapDown->OnTapUp
@ -437,7 +340,7 @@ void GalaxyMenu::InteractWithGalaxy(size_t dt) {
} }
} }*/
} }
// \_/\_/\_/\_/ timer inactive \_/\_/\_/\_/ // \_/\_/\_/\_/ timer inactive \_/\_/\_/\_/
} }
@ -599,107 +502,6 @@ int GalaxyMenu::findPlanetByPos(Eigen::Vector2f pos) {
return -1; return -1;
} }
void GalaxyMenu::drawSelectionMenu(int index) {
int i = index;
if (i != -1) {
glBindTexture(GL_TEXTURE_2D, SE::ResourceManager->TexList["matte_screen"]);
SE::Renderer->DrawRect(
Eigen::Vector2f(
0.f,
0.f
),
Eigen::Vector2f(
(float)SE::Renderer->GetScreenWidth(),
(float)SE::Renderer->GetScreenHeight()
)
); // DrawRect
glBindTexture(GL_TEXTURE_2D, SE::ResourceManager->TexList["red_square"]);
SE::Renderer->DrawRect(
Eigen::Vector2f(
galaxies[0].Stars[i].selectionMenu.buttons_plane.first(0) - galaxies[0].Stars[i].selectionMenu.buttons_plane.second(0) / 2,
galaxies[0].Stars[i].selectionMenu.buttons_plane.first(1) - galaxies[0].Stars[i].selectionMenu.buttons_plane.second(1) / 2
),
Eigen::Vector2f(
galaxies[0].Stars[i].selectionMenu.buttons_plane.first(0) + galaxies[0].Stars[i].selectionMenu.buttons_plane.second(0) / 2,
galaxies[0].Stars[i].selectionMenu.buttons_plane.first(1) + galaxies[0].Stars[i].selectionMenu.buttons_plane.second(1) / 2
)
); // DrawRect
/*..border..*/
drawBorder(
Eigen::Vector2f(
galaxies[0].Stars[i].selectionMenu.buttons_plane.first(0) - galaxies[0].Stars[i].selectionMenu.buttons_plane.second(0) / 2,
galaxies[0].Stars[i].selectionMenu.buttons_plane.first(1) - galaxies[0].Stars[i].selectionMenu.buttons_plane.second(1) / 2
),
Eigen::Vector2f(
galaxies[0].Stars[i].selectionMenu.buttons_plane.first(0) + galaxies[0].Stars[i].selectionMenu.buttons_plane.second(0) / 2,
galaxies[0].Stars[i].selectionMenu.buttons_plane.first(1) + galaxies[0].Stars[i].selectionMenu.buttons_plane.second(1) / 2
),
0.005f,
"outer" /*..inner/outer/center..mode */
);
// buttons
int j = 0;
for (auto &button : galaxies[0].Stars[i].selectionMenu.buttons)
{
//std::string levelName = "shutterstock" + galaxies[0].Stars[i].selectionMenu.levels[j].substr(itr + 1);
//glBindTexture(GL_TEXTURE_2D, SE::ResourceManager->TexList[levelName]);
std::string &levelName = galaxies[0].Stars[i].selectionMenu.gameLevels[j].levelName;
std::string levelPrerender = galaxies[0].Stars[i].selectionMenu.gameLevels[j].levelName + "_prerender";
glBindTexture(GL_TEXTURE_2D, SE::ResourceManager->TexList[levelPrerender]);
SE::Renderer->DrawRect(
Eigen::Vector2f(
button.first(0) - button.second(0) / 2,
button.first(1) - button.second(1) / 2
),
Eigen::Vector2f(
button.first(0) + button.second(0) / 2,
button.first(1) + button.second(1) / 2
)
); // DrawRect
/*..draw level interior..*/
//drawLevelInterior(i,j);
/*std::list<std::pair<PairColorTexture, TTriangleList>>::iterator colorBlockIterator;
for (colorBlockIterator = galaxies[0].Stars[i].selectionMenu.levelInterior[j].BlockInstansingList.ColorBlockList.begin(); colorBlockIterator != galaxies[0].Stars[i].selectionMenu.levelInterior[j].BlockInstansingList.ColorBlockList.end(); ++colorBlockIterator)
{
RenderUniform4fv("BrickColor", colorBlockIterator->first.first.data());
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList[colorBlockIterator->first.second]);
Renderer->DrawTriangleList(colorBlockIterator->second);
}*/
++j;
}
}
}
TGameLevel* GalaxyMenu::findLevelByButtonPos(Eigen::Vector2f pos) {
for (int i = 0; i < galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons.size(); i++) {
float x_l = galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons[i].first(0) - galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons[i].second(0)*0.5f;
float x_r = galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons[i].first(0) + galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons[i].second(0)*0.5f;
float y_t = galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons[i].first(1) + galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons[i].second(1)*0.5f;
float y_b = galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons[i].first(1) - galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons[i].second(1)*0.5f;
if (pos(0) >= x_l && pos(0) <= x_r) {
if (pos(1) >= y_b && pos(1) <= y_t) {
return &galaxies[galaxyIndex].Stars[starIndex].selectionMenu.gameLevels[i];
}
}
}
return nullptr;
}
bool GalaxyMenu::checkMenuBound(Eigen::Vector2f pos) { bool GalaxyMenu::checkMenuBound(Eigen::Vector2f pos) {
float x_l = galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons_plane.first(0) - galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons_plane.second(0)*0.5f; float x_l = galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons_plane.first(0) - galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons_plane.second(0)*0.5f;
float x_r = galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons_plane.first(0) + galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons_plane.second(0)*0.5f; float x_r = galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons_plane.first(0) + galaxies[galaxyIndex].Stars[starIndex].selectionMenu.buttons_plane.second(0)*0.5f;

View File

@ -27,6 +27,8 @@ public:
bool InitGalaxyMenu(std::string config_json, float scale = 1.f); bool InitGalaxyMenu(std::string config_json, float scale = 1.f);
void DrawGalaxyMenu(); void DrawGalaxyMenu();
void UpdateGalaxyMenu(float s_width, float s_height, size_t dt); void UpdateGalaxyMenu(float s_width, float s_height, size_t dt);
// ======== Main Methods ======== // ======== Main Methods ========
void InteractWithGalaxy(size_t dt); // Prototype for mouse/tap events void InteractWithGalaxy(size_t dt); // Prototype for mouse/tap events
@ -79,11 +81,10 @@ private:
void takeInFocus(int g_index, int s_index = -1); void takeInFocus(int g_index, int s_index = -1);
int findGalaxyByPos(Eigen::Vector2f pos); int findGalaxyByPos(Eigen::Vector2f pos);
int findPlanetByPos(Eigen::Vector2f pos); int findPlanetByPos(Eigen::Vector2f pos);
TGameLevel* findLevelByButtonPos(Eigen::Vector2f pos);
bool checkMenuBound(Eigen::Vector2f pos); bool checkMenuBound(Eigen::Vector2f pos);
/*..draw methodes..*/ /*..draw methodes..*/
void drawSelectionMenu(int index);
void drawBorder(Eigen::Vector2f lb_, Eigen::Vector2f rt_, float scale, std::string mode); void drawBorder(Eigen::Vector2f lb_, Eigen::Vector2f rt_, float scale, std::string mode);
void drawLevelInterior(int star = -1, int button = -1); void drawLevelInterior(int star = -1, int button = -1);

View File

@ -12,7 +12,7 @@ public:
/*..LEVELS..*/ /*..LEVELS..*/
/*..levels interior info..*/ /*..levels interior info..*/
std::vector<TGameLevel> gameLevels; std::vector<std::shared_ptr<TGameLevel>> gameLevels;
std::vector<std::vector<GameLevelInterior>> levelInterior; std::vector<std::vector<GameLevelInterior>> levelInterior;
// #params // #params

View File

@ -442,7 +442,7 @@ void TBall::Update(size_t dt)
TGameLevel::TGameLevel() TGameLevel::TGameLevel()
{ {
BkgTexture = "bkg"; BkgTexture = "";
RenderBufferReady = false; RenderBufferReady = false;
PrevLevelStateIsStandby = false; PrevLevelStateIsStandby = false;
@ -623,6 +623,18 @@ void TGameLevel::ReloadLevel()
} }
std::vector<std::string>::iterator rowIterator = rows.begin(); std::vector<std::string>::iterator rowIterator = rows.begin();
if (BkgTexture != "")
{
ResourceManager->TexList.DeleteTexture(BkgTexture);
}
BkgTexture = *rowIterator;
ResourceManager->TexList.AddTexture("level_background/" + BkgTexture);
++rowIterator;
BallColor = ParseColor(*rowIterator); BallColor = ParseColor(*rowIterator);
++rowIterator; ++rowIterator;
@ -668,11 +680,11 @@ void TGameLevel::ReloadLevel()
} }
/*
void TGameLevel::setBackground(const std::string& textureName) void TGameLevel::setBackground(const std::string& textureName)
{ {
BkgTexture = textureName; BkgTexture = textureName;
LevelScreenTexture = textureName; }*/
}
void TGameLevel::FillWithFile(const std::string& filename) void TGameLevel::FillWithFile(const std::string& filename)
{ {
@ -759,27 +771,33 @@ void TGameLevel::drawOutline(int screenWidth, int screenHeight) {
); );
} }
void TGameLevel::DrawSnapshot(const std::string& assignedSnapshotFrameBuffer) void TGameLevel::DrawSnapshot(const std::string& assignedSnapshotFrameBuffer, bool blackAndWhite)
{ {
InitLevel(768, 480); InitLevel(768, 480);
int prevState = LevelState; int prevState = LevelState;
LevelState = CONST_LEVELSTATE_SNAPSHOTTING; LevelState = CONST_LEVELSTATE_SNAPSHOTTING;
InnerDraw(768, 480, 768, 480); InnerDraw(768, 480, 768, 480, blackAndWhite);
LevelState = prevState; LevelState = prevState;
prerenderedImage = std::string texName = levelName + "_prerender";
ResourceManager->FrameManager.GetFrameTextureCopy(assignedSnapshotFrameBuffer, levelName + "_prerender");
if (blackAndWhite)
{
texName += "_blackandwhite";
}
prerenderedImage = ResourceManager->FrameManager.GetFrameTextureCopy(assignedSnapshotFrameBuffer, texName);
} }
void TGameLevel::Draw() void TGameLevel::Draw()
{ {
InnerDraw(Renderer->GetScreenWidth(), Renderer->GetScreenHeight(), Renderer->GetMatrixWidth(), Renderer->GetMatrixHeight()); InnerDraw(Renderer->GetScreenWidth(), Renderer->GetScreenHeight(), Renderer->GetMatrixWidth(), Renderer->GetMatrixHeight(), false);
} }
void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, int matrixHeight) void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, int matrixHeight, bool blackAndWhite)
{ {
// Scaling math // Scaling math
@ -815,9 +833,9 @@ void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, i
Renderer->TranslateMatrix(Vector3f(matrixWidth * 0.5f, matrixHeight * 0.5f, 0)); Renderer->TranslateMatrix(Vector3f(matrixWidth * 0.5f, matrixHeight * 0.5f, 0));
Renderer->ScaleMatrix(scale); Renderer->ScaleMatrix(scale);
Renderer->TranslateMatrix(-Vector3f(matrixWidth * 0.5f, matrixHeight * 0.5f, 0)); Renderer->TranslateMatrix(-Vector3f(matrixWidth * 0.5f, matrixHeight * 0.5f, 0));
glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList[LevelScreenTexture]); glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList[levelName + "_prerendered"]);
Renderer->DrawRect(Vector2f(xlOffset, ylOffset), Vector2f(xlOffset+tSW, ylOffset+tSH), Vector2f (0.f,0.f), Vector2f(1.f,1.f)); // Game Screen Scale Renderer->DrawRect(Vector2f(xlOffset, ylOffset), Vector2f(xlOffset+tSW, ylOffset+tSH), Vector2f (0.f,0.f), Vector2f(1.f,1.f)); // Game Screen Scale
Renderer->PopMatrix(); Renderer->PopMatrix();
CheckGlError(); CheckGlError();
return; return;
} }
@ -830,7 +848,7 @@ void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, i
bool renderBufferReady = RenderBufferReady; bool renderBufferReady = RenderBufferReady;
/*
if (pause && renderBufferReady) if (pause && renderBufferReady)
{ {
@ -847,6 +865,8 @@ void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, i
} }
Renderer->PopMatrix(); Renderer->PopMatrix();
CheckGlError(); CheckGlError();
drawOutline(screenWidth, screenHeight);
return; return;
} }
@ -858,7 +878,7 @@ void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, i
glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); glClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
CheckGlError(); CheckGlError();
}*/ }
// Level background // Level background
// ::::::::::: // :::::::::::
@ -907,7 +927,16 @@ void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, i
std::list<std::pair<PairColorTexture, TTriangleList>>::iterator colorBlockIterator; std::list<std::pair<PairColorTexture, TTriangleList>>::iterator colorBlockIterator;
for (colorBlockIterator = BlockInstansingList.ColorBlockList.begin(); colorBlockIterator != BlockInstansingList.ColorBlockList.end(); ++colorBlockIterator) for (colorBlockIterator = BlockInstansingList.ColorBlockList.begin(); colorBlockIterator != BlockInstansingList.ColorBlockList.end(); ++colorBlockIterator)
{ {
RenderUniform4fv("BrickColor", colorBlockIterator->first.first.data()); Vector4f color = colorBlockIterator->first.first;
if (blackAndWhite)
{
float c = (color(0) * 0.3 + color(1) * 0.59 + color(2) * 0.11);
color(0) = c;
color(1) = c;
color(2) = c;
}
RenderUniform4fv("BrickColor", color.data());
glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList[colorBlockIterator->first.second]); glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList[colorBlockIterator->first.second]);
Renderer->DrawTriangleList(colorBlockIterator->second); Renderer->DrawTriangleList(colorBlockIterator->second);
@ -923,7 +952,9 @@ void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, i
Application->EffectsDraw(); Application->EffectsDraw();
DrawBallInstancingList();
DrawBallInstancingList(blackAndWhite);
Renderer->PopShader(); Renderer->PopShader();
@ -962,7 +993,7 @@ void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, i
} }
/*/
if (!pause && LevelState != CONST_LEVELSTATE_SNAPSHOTTING) if (!pause && LevelState != CONST_LEVELSTATE_SNAPSHOTTING)
{ {
RenderUniform1f("Transparency", 1.f); RenderUniform1f("Transparency", 1.f);
@ -972,19 +1003,21 @@ void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, i
const float const_backBtnHeight = CONST_BACK_BTN_HEIGHT * Application->GetGameLevelScreenHeight()/320.f; const float const_backBtnHeight = CONST_BACK_BTN_HEIGHT * Application->GetGameLevelScreenHeight()/320.f;
Renderer->DrawRect(Vector2f(-const_backBtnWidth*0.5f, -const_backBtnHeight*0.5f)+BackBtnPos, Vector2f(const_backBtnWidth*0.5f, const_backBtnHeight*0.5f)+BackBtnPos); Renderer->DrawRect(Vector2f(-const_backBtnWidth*0.5f, -const_backBtnHeight*0.5f)+BackBtnPos, Vector2f(const_backBtnWidth*0.5f, const_backBtnHeight*0.5f)+BackBtnPos);
} }
drawOutline(screenWidth, screenHeight);
if (pause && !renderBufferReady) if (pause && !renderBufferReady)
{ {
//ololo //ololo
//See also above (same method) //See also above (same method)
Renderer->SwitchToScreen(); Renderer->SwitchToScreen();
Renderer->SetFullScreenViewport(); Renderer->SetFullScreenViewport();
Renderer->PushMatrix(); Renderer->PushMatrix();
//Renderer->LoadIdentity();
Renderer->TranslateMatrix(Vector3f(matrixWidth * 0.5f, matrixHeight * 0.5f, 0)); Renderer->TranslateMatrix(Vector3f(matrixWidth * 0.5f, matrixHeight * 0.5f, 0));
//Renderer->TranslateMatrix(Vector3f(Application->GetGameLevelScreenWidth(), Application->GetGameLevelScreenHeight(), 0));
Renderer->ScaleMatrix(OutScale); Renderer->ScaleMatrix(OutScale);
Renderer->TranslateMatrix(-Vector3f(matrixWidth * 0.5f, matrixHeight * 0.5f, 0)); Renderer->TranslateMatrix(-Vector3f(matrixWidth * 0.5f, matrixHeight * 0.5f, 0));
DrawBuffer(); DrawBuffer();
@ -995,12 +1028,11 @@ void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, i
Renderer->PopMatrix(); Renderer->PopMatrix();
RenderBufferReady = true; RenderBufferReady = true;
CheckGlError(); CheckGlError();
}*/ }
drawOutline(screenWidth, screenHeight);
CheckGlError(); CheckGlError();
} }
@ -1016,11 +1048,22 @@ void TGameLevel::DrawPauseButtons() //continue from
} }
void TGameLevel::DrawBallInstancingList() void TGameLevel::DrawBallInstancingList(bool blackAndWhite)
{ {
RenderUniform1f("Transparency", 1.f); RenderUniform1f("Transparency", 1.f);
RenderUniform4fv("BrickColor", BallColor.data());
Vector4f color = BallColor;
if (blackAndWhite)
{
float c = (color(0) * 0.3 + color(1) * 0.59 + color(2) * 0.11);
color(0) = c;
color(1) = c;
color(2) = c;
}
RenderUniform4fv("BrickColor", color.data());
if (BonusGothroughTimer > 0.f) if (BonusGothroughTimer > 0.f)
{ {
@ -1237,11 +1280,11 @@ void TGameLevel::Update(size_t dt)
//Bonus floor pos //Bonus floor pos
if (BonusFloorTimer/CONST_BONUS_GOTHROUGH_TIME < 0.2f) if (BonusFloorTimer/CONST_BONUS_GOTHROUGH_TIME < 0.2f)
{ {
//Bonus must go down until 0.f //Bonus must go down until - 20.f
if (BonusFloorPosY > 0.f) if (BonusFloorPosY > -20.f)
{ {
BonusFloorPosY -= CONST_BONUS_FLOOR_APPEAR_SPEED * dt / 1000.f; BonusFloorPosY -= CONST_BONUS_FLOOR_APPEAR_SPEED * dt / 1000.f;
BonusFloorPosY = max_t(BonusFloorPosY, 0.f); BonusFloorPosY = max_t(BonusFloorPosY, -20.f);
} }
} }

View File

@ -32,7 +32,7 @@ const float CONST_BONUS_CATCH_DISTANCE_X = 65.f;
const float CONST_BONUS_CATCH_DISTANCE_Y = 20.f; const float CONST_BONUS_CATCH_DISTANCE_Y = 20.f;
const float CONST_BONUS_FLOOR_TIME = 8000.f; const float CONST_BONUS_FLOOR_TIME = 8000.f;
const float CONST_BONUS_FLOOR_APPEAR_SPEED = 50.f; const float CONST_BONUS_FLOOR_APPEAR_SPEED = 80.f;
const int CONST_BONUS_TYPE_MULTIPLIER = 0; const int CONST_BONUS_TYPE_MULTIPLIER = 0;
const int CONST_BONUS_TYPE_GOTHROUGH = 1; const int CONST_BONUS_TYPE_GOTHROUGH = 1;
@ -127,7 +127,7 @@ protected:
float lvlWidth; float lvlWidth;
float lvlHeight; float lvlHeight;
std::string BkgTexture; std::string BkgTexture;
std::string LevelScreenTexture; //std::string LevelScreenTexture;
std::string LevelFileName; std::string LevelFileName;
GLuint prerenderedImage; GLuint prerenderedImage;
@ -152,7 +152,7 @@ protected:
void DrawBuffer(); void DrawBuffer();
void DrawPauseButtons(); void DrawPauseButtons();
void DrawBallInstancingList(); void DrawBallInstancingList(bool blackAndWhite);
void drawOutline(int screenWidth, int screenHeight); void drawOutline(int screenWidth, int screenHeight);
@ -194,7 +194,7 @@ public:
~TGameLevel(); ~TGameLevel();
void FillWithFile(const std::string& filename); void FillWithFile(const std::string& filename);
void setBackground(const std::string& assignedShutterstock); //void setBackground(const std::string& assignedShutterstock);
//void SetLevelScale(); //void SetLevelScale();
//Vector2f GetLevelScale(); //Vector2f GetLevelScale();
@ -204,8 +204,8 @@ public:
bool IsLoaded(); bool IsLoaded();
virtual void Draw(); virtual void Draw();
void InnerDraw(int screenWidth, int screenHeight, int matrixWidth, int matrixHeight); void InnerDraw(int screenWidth, int screenHeight, int matrixWidth, int matrixHeight, bool blackAndWhite);
void DrawSnapshot(const std::string& assignedSnapshotFrameBuffer); void DrawSnapshot(const std::string& assignedSnapshotFrameBuffer, bool blackAndWhite);
void SetPause(); void SetPause();
bool IsPaused(); bool IsPaused();

View File

@ -61,8 +61,8 @@ void TMyApplication::InnerInit()
#ifdef TARGET_WIN32 #ifdef TARGET_WIN32
#ifdef NDEBUG #ifdef NDEBUG
//ST::PathToResources = "resources/"; ST::PathToResources = "resources/";
ST::PathToResources = "../../../assets/"; //ST::PathToResources = "../../../assets/";
#else #else
ST::PathToResources = "../../../assets/"; ST::PathToResources = "../../../assets/";
#endif #endif
@ -93,6 +93,7 @@ void TMyApplication::InnerInit()
//ResourceManager->ShaderManager.AddShader("DefaultShader", "shaders/texture-shader.vertex", "shaders/texture-shader.fragment"); //ResourceManager->ShaderManager.AddShader("DefaultShader", "shaders/texture-shader.vertex", "shaders/texture-shader.fragment");
ResourceManager->ShaderManager.AddShader("DefaultShader", "shaders/gui_transparent.vertex", "shaders/gui_transparent.fragment"); ResourceManager->ShaderManager.AddShader("DefaultShader", "shaders/gui_transparent.vertex", "shaders/gui_transparent.fragment");
ResourceManager->ShaderManager.AddShader("BlackAndWhiteShader", "shaders/gui_transparent_blackandwhite.vertex", "shaders/gui_transparent_blackandwhite.fragment");
ResourceManager->ShaderManager.AddShader("ColorShader", "shaders/color-shader.vertex", "shaders/color-shader.fragment"); ResourceManager->ShaderManager.AddShader("ColorShader", "shaders/color-shader.vertex", "shaders/color-shader.fragment");
ResourceManager->ShaderManager.AddShader("FrameShader", "shaders/frameshader_vertex.txt", "shaders/frameshader_fragment.txt"); ResourceManager->ShaderManager.AddShader("FrameShader", "shaders/frameshader_vertex.txt", "shaders/frameshader_fragment.txt");
ResourceManager->ShaderManager.AddShader("BrickShader", "shaders/brickshader_vertex.txt", "shaders/brickshader_fragment.txt"); ResourceManager->ShaderManager.AddShader("BrickShader", "shaders/brickshader_vertex.txt", "shaders/brickshader_fragment.txt");
@ -107,7 +108,7 @@ void TMyApplication::InnerInit()
ResourceManager->TexList.AddTexture("white.bmp"); ResourceManager->TexList.AddTexture("white.bmp");
ResourceManager->FrameManager.AddFrameRenderBuffer("LevelBuffer", 512, 512); ResourceManager->FrameManager.AddFrameRenderBuffer("LevelBuffer", 256, 256);
//OnDrawSignal.connect(boost::bind(&TGameLoading::Draw, boost::ref(GameLoading))); //OnDrawSignal.connect(boost::bind(&TGameLoading::Draw, boost::ref(GameLoading)));
Inited = true; Inited = true;
@ -125,7 +126,7 @@ void TMyApplication::InnerInit()
ResourceManager->FontManager.PushFont("lucon12"); ResourceManager->FontManager.PushFont("lucon12");
//ResourceManager->newGuiManager.LoadFromConfig("gui_main_menu.json"); //ResourceManager->newGuiManager.LoadFromConfig("gui_main_menu.json");
ResourceManager->newGuiManager.LoadFromConfig("gui_loading.json"); ResourceManager->newGuiManager.LoadFromConfig("gui_loading.json");
//SetButtonsAction();
// ------- UI ------- // ------- UI -------
// TESTS of menu // TESTS of menu
@ -266,7 +267,7 @@ void TMyApplication::LoadResources()
boost::property_tree::ptree Textures_pt = SE::ReadJsonFile(ST::PathToResources + "bg_textures_config.json"); boost::property_tree::ptree Textures_pt = SE::ReadJsonFile(ST::PathToResources + "bg_textures_config.json");
//boost::property_tree::json_parser::read_json(ST::PathToResources + "bg_textures_config.json", Textures_pt); //boost::property_tree::json_parser::read_json(ST::PathToResources + "bg_textures_config.json", Textures_pt);
std::string bg_ext = ".jpeg"; std::string bg_ext = ".jpg";
// ::::::::::::::::::::::::::::::::::::: // :::::::::::::::::::::::::::::::::::::
@ -450,8 +451,8 @@ void TMyApplication::InnerUpdate(size_t dt)
TextureNamesToLoad.erase(TextureNamesToLoad.begin()); TextureNamesToLoad.erase(TextureNamesToLoad.begin());
} }
else else
{ {
Renderer->SwitchToFrameBuffer("LevelBuffer"); Renderer->SwitchToFrameBuffer("LevelBuffer");
@ -461,23 +462,27 @@ void TMyApplication::InnerUpdate(size_t dt)
for (auto &star : Menu.GalaxMenu.galaxies[0].Stars) for (auto &star : Menu.GalaxMenu.galaxies[0].Stars)
{ {
for (auto &level : star.selectionMenu.gameLevels) for (auto level : star.selectionMenu.gameLevels)
{ {
level.DrawSnapshot("LevelBuffer"); level->DrawSnapshot("LevelBuffer", false);
break;
Renderer->PushShader("BlackAndWhiteShader");
level->DrawSnapshot("LevelBuffer", true);
Renderer->PopShader();
} }
break;
} }
Renderer->SwitchToScreen(); Renderer->SwitchToScreen();
Renderer->SetOrthoProjection(); Renderer->SetOrthoProjection();
GameState = CONST_GAMESTATE_MENU; GameState = CONST_GAMESTATE_MENU;
ApplySignalsToMenu(); ApplySignalsToMenu();
ResourceManager->newGuiManager.Clear();
ResourceManager->newGuiManager.LoadFromConfig("gui_main_menu.json"); LoadGalaxyUi();
//OnDrawSignal.disconnect(boost::bind(&TGameLoading::Draw, boost::ref(GameLoading)));
OnDrawSignal.connect(0, boost::bind(&TGameMenu::Draw, boost::ref(Menu))); OnDrawSignal.connect(0, boost::bind(&TGameMenu::Draw, boost::ref(Menu)));
StateTimer = 0.f; StateTimer = 0.f;
Loaded = true; Loaded = true;
@ -540,7 +545,122 @@ void TMyApplication::InnerUpdate(size_t dt)
} }
void TMyApplication::GoFromMenuToGame(TGameLevel* level)
void TMyApplication::LoadGalaxyUi()
{
ResourceManager->newGuiManager.Clear();
ResourceManager->newGuiManager.LoadFromConfig("gui_main_menu.json");
std::shared_ptr<WidgetAncestor> modal_background = ResourceManager->newGuiManager.findWidgetByName("modal_background");
modal_background->onMouseUpSignal.connect(
[modal_background](Vector2f v, int i) {
modal_background->visible = false;
});
}
void TMyApplication::SetupGalaxyUi(size_t levelStar)
{
std::shared_ptr<WidgetAncestor> modal_background = ResourceManager->newGuiManager.findWidgetByName("modal_background");
std::shared_ptr<WidgetAncestor> row2 = ResourceManager->newGuiManager.findWidgetByName("row2");
std::shared_ptr<WidgetAncestor> row3 = ResourceManager->newGuiManager.findWidgetByName("row3");
std::shared_ptr<WidgetAncestor> row4 = ResourceManager->newGuiManager.findWidgetByName("row4");
size_t levelCount = this->Menu.GalaxMenu.galaxies[0].Stars[levelStar].selectionMenu.gameLevels.size();
if (levelCount <= 3)
{
row2->setVisibility(false);
}
else
{
row2->setVisibility(true);
}
if (levelCount <= 6)
{
row3->setVisibility(false);
}
else
{
row3->setVisibility(true);
}
if (levelCount <= 9)
{
row4->setVisibility(false);
}
else
{
row4->setVisibility(true);
}
std::string levelStarString = boost::lexical_cast<std::string>(levelStar);
for (size_t levelIndex = 0; levelIndex < 12; levelIndex++)
{
std::string levelIndexString = boost::lexical_cast<std::string>(levelIndex);
std::shared_ptr<WidgetAncestor> currentLevelButton = ResourceManager->newGuiManager.findWidgetByName("button" + levelIndexString);
currentLevelButton->onMouseUpSignal.disconnect_all_slots();
if (levelIndex < levelCount)
{
std::string levelName = this->Menu.GalaxMenu.galaxies[0].Stars[levelStar].selectionMenu.gameLevels[levelIndex]->levelName;
if (IsLevelOpened(levelStar, levelIndex))
{
currentLevelButton->setVisibility(true);
currentLevelButton->setBackground(levelName + "_prerender");
currentLevelButton->onMouseUpSignal.connect(
[this, modal_background, levelStar, levelIndex](Vector2f v, int i) {
modal_background->visible = false;
std::shared_ptr<TGameLevel> lvl = this->Menu.GalaxMenu.galaxies[0].Stars[levelStar].selectionMenu.gameLevels[levelIndex];
lvl->ReloadLevel();
this->GoFromMenuToGame(lvl);
});
}
else
{
currentLevelButton->setBackground(levelName + "_prerender_blackandwhite");
}
//currentLevelButton->OnMouseUp(Vector2f(), 0);
}
else
{
currentLevelButton->setVisibility(false);
}
}
}
void TMyApplication::GoFromMenuToGame(std::shared_ptr<TGameLevel> level)
{ {
//#ifndef TARGET_IOS //#ifndef TARGET_IOS
// ResourceManager->SoundManager.PlayMusicLooped("level1ogg.ogg"); // ResourceManager->SoundManager.PlayMusicLooped("level1ogg.ogg");
@ -637,14 +757,7 @@ float TMyApplication::GetGameLevelScreenHeight()
} }
void TMyApplication::InnerOnMouseDown(TMouseState& mouseState) { void TMyApplication::InnerOnMouseDown(TMouseState& mouseState) {
/*
if (mouseState.LeftButtonPressed) {
if ((float)mouseState.X >= (Renderer->GetScreenWidth())*0.25f && (float)mouseState.X <= (Renderer->GetScreenWidth())*0.75f && (float)mouseState.Y >= (Renderer->GetScreenHeight())*0.25f && (float)mouseState.Y <= (Renderer->GetScreenHeight())*0.75f) {
// some tmp code
Application->GoFromMenuToGame(1);
}
}
*/
OnTapDownSignal(Vector2f(mouseState.X, ((Renderer->GetScreenHeight()) - mouseState.Y))); // Temp mouse down action for WIN32 OnTapDownSignal(Vector2f(mouseState.X, ((Renderer->GetScreenHeight()) - mouseState.Y))); // Temp mouse down action for WIN32
} }
@ -652,6 +765,22 @@ void TMyApplication::InnerOnMouseMove(TMouseState& mouseState) {
} }
bool TMyApplication::IsLevelOpened(int levelStar, int levelIndex)
{
if (levelStar == 0)
{
return true;
}
if (levelStar == 1 && levelIndex < 3)
{
return true;
}
return false;
}
void TMyApplication::EffectsInit() { void TMyApplication::EffectsInit() {
boost::property_tree::ptree JSONsource; boost::property_tree::ptree JSONsource;
@ -738,13 +867,3 @@ void TMyApplication::fireworkEffect() {
lvlFirework.stopSpawn(); lvlFirework.stopSpawn();
lvlFirework.startSpawn(); lvlFirework.startSpawn();
} }
void TMyApplication::SetButtonsAction () {
auto backBtn = ResourceManager->newGuiManager.findWidgetByName("backButton");
if (backBtn) {
backBtn->onMouseDownSignal.connect([this, backBtn](Vector2f pos, int touchNumber) {
this->GameLevel->SetPause();
this->GameLevel->PrevLevelStateIsStandby = true;
});
}
}

View File

@ -98,7 +98,7 @@ protected:
ParticleEffect lvlFirework; // Level finished effect ParticleEffect lvlFirework; // Level finished effect
TGameMenu Menu; TGameMenu Menu;
TGameLevel* GameLevel; std::shared_ptr<TGameLevel> GameLevel;
TGameCredits GameCredits; TGameCredits GameCredits;
TGameLoading GameLoading; TGameLoading GameLoading;
@ -119,13 +119,20 @@ protected:
void ApplySignalsToCredits(); void ApplySignalsToCredits();
void DisapplySignalsToCredits(); void DisapplySignalsToCredits();
void EffectsInit(); void EffectsInit();
// Mouse new methods // Mouse new methods
virtual void InnerOnMouseDown(TMouseState& mouseState); virtual void InnerOnMouseDown(TMouseState& mouseState);
virtual void InnerOnMouseMove(TMouseState& mouseState); virtual void InnerOnMouseMove(TMouseState& mouseState);
bool IsLevelOpened(int levelStar, int levelIndex);
public: public:
bool Loaded; bool Loaded;
@ -139,7 +146,7 @@ public:
virtual void InnerUpdate(size_t dt); virtual void InnerUpdate(size_t dt);
void GoFromMenuToGame(TGameLevel* level); void GoFromMenuToGame(std::shared_ptr<TGameLevel> gameLevel);
void GoFromGameToMenu(); void GoFromGameToMenu();
void GoFromMenuToCredits(); void GoFromMenuToCredits();
void GoFromCreditsToMenu(); void GoFromCreditsToMenu();
@ -180,7 +187,9 @@ public:
float GetGameLevelScreenHeight(); float GetGameLevelScreenHeight();
void SetGameLevelScreenScale(); void SetGameLevelScreenScale();
void SetButtonsAction();
void LoadGalaxyUi();
void SetupGalaxyUi(size_t levelStar);
}; };