From b9f727e8f21560e0c9726e4b4782dfbd28aee746 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Wed, 15 Jun 2016 07:35:39 -0400 Subject: check check 1 2 --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index dda1214..40ed2e8 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ # gamedev + gamedev is a high school project between drumsetmonkey and tcsullivan written in C++ and using SDL2/OpenGL. The goal of this project is to have a completed commercial-grade video game available to Linux and Windows users. We plan on profiting off of the game once we finish it, so once the game reaches its final stages it may become closed source (however, what was uploaded will stay for others to use as a resource). -- cgit v1.2.3 From 0b38e943e1cd2ccd752f35358affd3fec08e23ca Mon Sep 17 00:00:00 2001 From: drumsetmonkey Date: Wed, 15 Jun 2016 07:45:30 -0400 Subject: Better text boxes --- assets/dialog_en-us | 2 +- assets/ui/button_corners.png | Bin 0 -> 786 bytes assets/ui/button_corners_flat.png | Bin 0 -> 282 bytes assets/ui/button_side_borders.png | Bin 0 -> 203 bytes assets/ui/button_side_borders_flat.png | Bin 0 -> 192 bytes assets/ui/button_top_bot_borders.png | Bin 0 -> 198 bytes assets/ui/button_top_bot_borders_flat.png | Bin 0 -> 196 bytes brice.dat | 8 +- include/ui.hpp | 1 + shaders/world.frag | 1 - src/ui.cpp | 162 +++++++++++++++++++++++++++++- xml/000.xml | 2 +- xml/playerSpawnHill1_Building1.xml | 2 +- 13 files changed, 167 insertions(+), 11 deletions(-) create mode 100644 assets/ui/button_corners.png create mode 100644 assets/ui/button_corners_flat.png create mode 100644 assets/ui/button_side_borders.png create mode 100644 assets/ui/button_side_borders_flat.png create mode 100644 assets/ui/button_top_bot_borders.png create mode 100644 assets/ui/button_top_bot_borders_flat.png diff --git a/assets/dialog_en-us b/assets/dialog_en-us index dfe7b03..2224aa6 100644 --- a/assets/dialog_en-us +++ b/assets/dialog_en-us @@ -4,7 +4,7 @@ I heard if you complete a quest, you'll get a special reward. How much wood could a woodchuck chuck if a woodchuck could chuck wood? I don't think anyone has ever been able to climb up that hill. If you ever see a hole in the ground, watch out; it could mean the end for you. -Did you know this game has over 5000 lines of code? I didn't. I didn't even know I was in a game until now... +Did you know this game has over 10000 lines of code? I didn't. I didn't even know I was in a game until now... HELP MY CAPS LOCK IS STUCK You know, if anyone ever asked me who I wanted to be when I grow up, I would say Abby Ross. I want to have the wallpaper in our house changed. It doesn't really fit the environment. diff --git a/assets/ui/button_corners.png b/assets/ui/button_corners.png new file mode 100644 index 0000000..38f0cf9 Binary files /dev/null and b/assets/ui/button_corners.png differ diff --git a/assets/ui/button_corners_flat.png b/assets/ui/button_corners_flat.png new file mode 100644 index 0000000..527500f Binary files /dev/null and b/assets/ui/button_corners_flat.png differ diff --git a/assets/ui/button_side_borders.png b/assets/ui/button_side_borders.png new file mode 100644 index 0000000..4f0ec6d Binary files /dev/null and b/assets/ui/button_side_borders.png differ diff --git a/assets/ui/button_side_borders_flat.png b/assets/ui/button_side_borders_flat.png new file mode 100644 index 0000000..ef9dbfe Binary files /dev/null and b/assets/ui/button_side_borders_flat.png differ diff --git a/assets/ui/button_top_bot_borders.png b/assets/ui/button_top_bot_borders.png new file mode 100644 index 0000000..f78b1e3 Binary files /dev/null and b/assets/ui/button_top_bot_borders.png differ diff --git a/assets/ui/button_top_bot_borders_flat.png b/assets/ui/button_top_bot_borders_flat.png new file mode 100644 index 0000000..431e6b8 Binary files /dev/null and b/assets/ui/button_top_bot_borders_flat.png differ diff --git a/brice.dat b/brice.dat index 3b090ad..2653f9c 100644 --- a/brice.dat +++ b/brice.dat @@ -1,7 +1,7 @@ 3 -canSprint -0 -canJump -0 Slow 1 +canJump +0 +canSprint +0 diff --git a/include/ui.hpp b/include/ui.hpp index 7d9b9f5..507a211 100644 --- a/include/ui.hpp +++ b/include/ui.hpp @@ -108,6 +108,7 @@ namespace ui { */ void drawBox(vec2 c1, vec2 c2); + void drawNiceBox(vec2 c1, vec2 c2, float z); void dialogBox(std::string name, std::string opt, bool passive, std::string text, ...); void merchantBox(const char *name,Trade trade,const char *opt,bool passive,const char *text,...); void merchantBox(); diff --git a/shaders/world.frag b/shaders/world.frag index 617cbb1..87d86ca 100644 --- a/shaders/world.frag +++ b/shaders/world.frag @@ -26,7 +26,6 @@ void main() if (dist < light[i].w) { float attenuation = clamp(1.0f - dist*dist/(light[i].w*light[i].w), 0.0f, 1.0f); attenuation *= attenuation; - shadeColor += (vec4(attenuation, attenuation, attenuation, 0.0f) * vec4(lightColor[i])) * lightImpact; } } diff --git a/src/ui.cpp b/src/ui.cpp index c5d134e..8f234df 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -731,6 +731,163 @@ namespace ui { glUseProgram(0); } + void drawNiceBox(vec2 c1, vec2 c2, float z) { + // the textures for the box corners + static GLuint box_corner = Texture::loadTexture("assets/ui/button_corners.png"); + static GLuint box_side_top = Texture::loadTexture("assets/ui/button_top_bot_borders.png"); + static GLuint box_side = Texture::loadTexture("assets/ui/button_side_borders.png"); + + // the dimensions of the corner textures + static dim2 box_corner_dim_t = Texture::imageDim("assets/ui/button_corners.png"); + static vec2 box_corner_dim = vec2(box_corner_dim_t.x / 2.0, box_corner_dim_t.y / 2.0); + + // the amount of bytes to skip in the OpenGL arrays (see below) + auto stride = 5 * sizeof(GLfloat); + + // we always want to make sure c1 is lower left and c2 is upper right + if (c1.x > c2.x) std::swap(c1.x, c2.y); + if (c1.y > c2.y) std::swap(c1.y, c2.y); + + // if the box is too small, we will not be able to draw it + if (c2.x - c1.x < (box_corner_dim_t.x)) return; + if (c2.y - c1.y < (box_corner_dim_t.y)) return; + + + GLfloat box_ul[] = {c1.x, c2.y - box_corner_dim.y, z, 0.0f, 0.5f, + c1.x + box_corner_dim.x, c2.y - box_corner_dim.y, z, 0.5f, 0.5f, + c1.x + box_corner_dim.x, c2.y, z, 0.5f, 1.0f, + + c1.x + box_corner_dim.x, c2.y, z, 0.5f, 1.0f, + c1.x, c2.y, z, 0.0f, 1.0f, + c1.x, c2.y - box_corner_dim.y, z, 0.0f, 0.5f}; + + GLfloat box_ll[] = {c1.x, c1.y, z, 0.0f, 0.0f, + c1.x + box_corner_dim.x, c1.y, z, 0.5f, 0.0f, + c1.x + box_corner_dim.x, c1.y + box_corner_dim.y, z, 0.5f, 0.5f, + + c1.x + box_corner_dim.x, c1.y + box_corner_dim.y, z, 0.5f, 0.5f, + c1.x, c1.y + box_corner_dim.y, z, 0.0f, 0.5f, + c1.x, c1.y, z, 0.0f, 0.0f}; + + GLfloat box_ur[] = {c2.x - box_corner_dim.x, c2.y - box_corner_dim.y, z, 0.5f, 0.5f, + c2.x, c2.y - box_corner_dim.y, z, 1.0f, 0.5f, + c2.x, c2.y, z, 1.0f, 1.0f, + + c2.x, c2.y, z, 1.0f, 1.0f, + c2.x - box_corner_dim.x, c2.y, z, 0.5f, 1.0f, + c2.x - box_corner_dim.x, c2.y - box_corner_dim.y, z, 0.5f, 0.5f}; + + GLfloat box_lr[] = {c2.x - box_corner_dim.x, c1.y, z, 0.5f, 0.0f, + c2.x, c1.y, z, 1.0f, 0.0f, + c2.x, c1.y + box_corner_dim.y, z, 1.0f, 0.5f, + + c2.x, c1.y + box_corner_dim.y, z, 1.0f, 0.5f, + c2.x - box_corner_dim.x, c1.y + box_corner_dim.y, z, 0.0f, 0.5f, + c2.x - box_corner_dim.x, c1.y, z, 0.5f, 0.0f}; + + GLfloat box_l[] = {c1.x, c1.y + box_corner_dim.y, z, 0.0f, 0.0f, + c1.x + box_corner_dim.x, c1.y + box_corner_dim.y, z, 0.5f, 0.0f, + c1.x + box_corner_dim.x, c2.y - box_corner_dim.y, z, 0.5f, 1.0f, + + c1.x + box_corner_dim.x, c2.y - box_corner_dim.y, z, 0.5f, 1.0f, + c1.x, c2.y - box_corner_dim.y, z, 0.0f, 1.0f, + c1.x, c1.y + box_corner_dim.y, z, 0.0f, 0.0f}; + + GLfloat box_r[] = {c2.x - box_corner_dim.x, c1.y + box_corner_dim.y, z, 0.5f, 0.0f, + c2.x, c1.y + box_corner_dim.y, z, 1.0f, 0.0f, + c2.x, c2.y - box_corner_dim.y, z, 1.0f, 1.0f, + + c2.x, c2.y - box_corner_dim.y, z, 1.0f, 1.0f, + c2.x - box_corner_dim.x, c2.y - box_corner_dim.y, z, 0.5f, 1.0f, + c2.x - box_corner_dim.x, c1.y + box_corner_dim.y, z, 0.5f, 0.0f}; + + GLfloat box_b[] = {c1.x + box_corner_dim.x, c1.y, z, 0.0f, 0.0f, + c2.x - box_corner_dim.x, c1.y, z, 1.0f, 0.0f, + c2.x - box_corner_dim.x, c1.y + box_corner_dim.y, z, 1.0f, 0.5f, + + c2.x - box_corner_dim.x, c1.y + box_corner_dim.y, z, 1.0f, 0.5f, + c1.x + box_corner_dim.x, c1.y + box_corner_dim.y, z, 0.0f, 0.5f, + c1.x + box_corner_dim.x, c1.y, z, 0.0f, 0.0f}; + + GLfloat box_t[] = {c1.x + box_corner_dim.x, c2.y - box_corner_dim.y, z, 0.0f, 0.5f, + c2.x - box_corner_dim.x, c2.y - box_corner_dim.y, z, 1.0f, 0.5f, + c2.x - box_corner_dim.x, c2.y, z, 1.0f, 1.0f, + + c2.x - box_corner_dim.x, c2.y, z, 1.0f, 1.0f, + c1.x + box_corner_dim.x, c2.y, z, 0.0f, 1.0f, + c1.x + box_corner_dim.x, c2.y - box_corner_dim.y, z, 0.0f, 0.5f}; + + GLfloat box_f[] = {c1.x + box_corner_dim.x, c1.y + box_corner_dim.y, z, 0.5f, 0.5f, + c2.x - box_corner_dim.x, c1.y + box_corner_dim.y, z, 0.5f, 0.5f, + c2.x - box_corner_dim.x, c2.y - box_corner_dim.y, z, 0.5f, 0.5f, + + c2.x - box_corner_dim.x, c2.y - box_corner_dim.y, z, 0.5f, 0.5f, + c1.x + box_corner_dim.x, c2.y - box_corner_dim.y, z, 0.5f, 0.5f, + c1.x + box_corner_dim.x, c1.y + box_corner_dim.y, z, 0.5f, 0.5f}; + + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, box_corner); + glUniform1f(textShader_uniform_texture, 0); + glUseProgram(textShader); + + glEnableVertexAttribArray(textShader_attribute_coord); + glEnableVertexAttribArray(textShader_attribute_tex); + + // draw upper left corner + glVertexAttribPointer(textShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, stride, &box_ul[0]); + glVertexAttribPointer(textShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, stride, &box_ul[3]); + glDrawArrays(GL_TRIANGLES, 0, 6); + + // lower left corner + glVertexAttribPointer(textShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, stride, &box_ll[0]); + glVertexAttribPointer(textShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, stride, &box_ll[3]); + glDrawArrays(GL_TRIANGLES, 0, 6); + + // upper right corner + glVertexAttribPointer(textShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, stride, &box_ur[0]); + glVertexAttribPointer(textShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, stride, &box_ur[3]); + glDrawArrays(GL_TRIANGLES, 0, 6); + + // lower right corner + glVertexAttribPointer(textShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, stride, &box_lr[0]); + glVertexAttribPointer(textShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, stride, &box_lr[3]); + glDrawArrays(GL_TRIANGLES, 0, 6); + + // draw the middle of the box + glVertexAttribPointer(textShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, stride, &box_f[0]); + glVertexAttribPointer(textShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, stride, &box_f[3]); + glDrawArrays(GL_TRIANGLES, 0, 6); + + glBindTexture(GL_TEXTURE_2D, box_side); + + // draw the left edge of the box + glVertexAttribPointer(textShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, stride, &box_l[0]); + glVertexAttribPointer(textShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, stride, &box_l[3]); + glDrawArrays(GL_TRIANGLES, 0, 6); + + // draw right edge of the box + glVertexAttribPointer(textShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, stride, &box_r[0]); + glVertexAttribPointer(textShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, stride, &box_r[3]); + glDrawArrays(GL_TRIANGLES, 0, 6); + + glBindTexture(GL_TEXTURE_2D, box_side_top); + + // draw bottom of the box + glVertexAttribPointer(textShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, stride, &box_b[0]); + glVertexAttribPointer(textShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, stride, &box_b[3]); + glDrawArrays(GL_TRIANGLES, 0, 6); + + // draw top of the box + glVertexAttribPointer(textShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, stride, &box_t[0]); + glVertexAttribPointer(textShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, stride, &box_t[3]); + glDrawArrays(GL_TRIANGLES, 0, 6); + + glDisableVertexAttribArray(textShader_attribute_coord); + glDisableVertexAttribArray(textShader_attribute_tex); + + glUseProgram(0); + } + void draw(void){ unsigned char i; float x,y,tmp; @@ -800,8 +957,7 @@ namespace ui { x = offset.x - SCREEN_WIDTH / 6; y = (offset.y + SCREEN_HEIGHT / 2) - HLINES(8); - drawBox(vec2 {x, y}, vec2 {x + SCREEN_WIDTH / 3, y - SCREEN_HEIGHT * 0.6f}); - + drawNiceBox(vec2(x, y), vec2(x + (SCREEN_WIDTH / 3.0f), y - (SCREEN_HEIGHT * 0.6f)), -7.0f); // draw typeOut'd text putString(x + game::HLINE, y - fontSize - game::HLINE, (rtext = typeOut(dialogBoxText))); @@ -934,7 +1090,7 @@ namespace ui { x = offset.x - SCREEN_WIDTH / 2 + HLINES(8); y = offset.y + SCREEN_HEIGHT / 2 - HLINES(8); - drawBox(vec2 {x, y}, vec2 {x + SCREEN_WIDTH - HLINES(16), y - SCREEN_HEIGHT / 4}); + drawNiceBox(vec2 {x, y}, vec2 {x + SCREEN_WIDTH - HLINES(16), y - SCREEN_HEIGHT / 4}, -7.0); rtext = typeOut(dialogBoxText); putString(x + game::HLINE, y - fontSize - game::HLINE, rtext); diff --git a/xml/000.xml b/xml/000.xml index 9996cec..1779b0c 100644 --- a/xml/000.xml +++ b/xml/000.xml @@ -8,7 +8,7 @@ -880 - + Guy diff --git a/xml/playerSpawnHill1_Building1.xml b/xml/playerSpawnHill1_Building1.xml index 0b51b55..b86fd9f 100644 --- a/xml/playerSpawnHill1_Building1.xml +++ b/xml/playerSpawnHill1_Building1.xml @@ -10,7 +10,7 @@ Hey. Have a Dank MayMay :) - + What? You want another Dank MayMay? -- cgit v1.2.3