diff options
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | assets/dialog_en-us | 2 | ||||
-rw-r--r-- | assets/ui/button_corners.png | bin | 0 -> 786 bytes | |||
-rw-r--r-- | assets/ui/button_corners_flat.png | bin | 0 -> 282 bytes | |||
-rw-r--r-- | assets/ui/button_side_borders.png | bin | 0 -> 203 bytes | |||
-rw-r--r-- | assets/ui/button_side_borders_flat.png | bin | 0 -> 192 bytes | |||
-rw-r--r-- | assets/ui/button_top_bot_borders.png | bin | 0 -> 198 bytes | |||
-rw-r--r-- | assets/ui/button_top_bot_borders_flat.png | bin | 0 -> 196 bytes | |||
-rw-r--r-- | brice.dat | 6 | ||||
-rw-r--r-- | include/ui.hpp | 1 | ||||
-rw-r--r-- | shaders/world.frag | 1 | ||||
-rw-r--r-- | src/ui.cpp | 162 | ||||
-rw-r--r-- | xml/000.xml | 2 | ||||
-rw-r--r-- | xml/playerSpawnHill1.xml | 2 | ||||
-rw-r--r-- | xml/playerSpawnHill1_Building1.xml | 12 |
15 files changed, 173 insertions, 16 deletions
@@ -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). 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 Binary files differnew file mode 100644 index 0000000..38f0cf9 --- /dev/null +++ b/assets/ui/button_corners.png diff --git a/assets/ui/button_corners_flat.png b/assets/ui/button_corners_flat.png Binary files differnew file mode 100644 index 0000000..527500f --- /dev/null +++ b/assets/ui/button_corners_flat.png diff --git a/assets/ui/button_side_borders.png b/assets/ui/button_side_borders.png Binary files differnew file mode 100644 index 0000000..4f0ec6d --- /dev/null +++ b/assets/ui/button_side_borders.png diff --git a/assets/ui/button_side_borders_flat.png b/assets/ui/button_side_borders_flat.png Binary files differnew file mode 100644 index 0000000..ef9dbfe --- /dev/null +++ b/assets/ui/button_side_borders_flat.png diff --git a/assets/ui/button_top_bot_borders.png b/assets/ui/button_top_bot_borders.png Binary files differnew file mode 100644 index 0000000..f78b1e3 --- /dev/null +++ b/assets/ui/button_top_bot_borders.png diff --git a/assets/ui/button_top_bot_borders_flat.png b/assets/ui/button_top_bot_borders_flat.png Binary files differnew file mode 100644 index 0000000..431e6b8 --- /dev/null +++ b/assets/ui/button_top_bot_borders_flat.png @@ -1,7 +1,7 @@ 3 -Slow +canSprint 0 canJump 0 -canSprint -0 +Slow +1 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; } } @@ -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 bf0af6c..1806332 100644 --- a/xml/000.xml +++ b/xml/000.xml @@ -19,7 +19,7 @@ </text> <text id="1"> ... - <gotox>700</gotox> + <gotox>700</gotox> <set id="Slow" value="0"/> </text> </Dialog> diff --git a/xml/playerSpawnHill1.xml b/xml/playerSpawnHill1.xml index 534b5d9..f997b4d 100644 --- a/xml/playerSpawnHill1.xml +++ b/xml/playerSpawnHill1.xml @@ -19,7 +19,7 @@ </text> <text id="1"> ... - <gotox>1000</gotox> + <gotox>1000</gotox> <set id="Slow" value="0"/> <set id="canSprint" value="1"/> </text> diff --git a/xml/playerSpawnHill1_Building1.xml b/xml/playerSpawnHill1_Building1.xml index 50b34e0..d5c07b3 100644 --- a/xml/playerSpawnHill1_Building1.xml +++ b/xml/playerSpawnHill1_Building1.xml @@ -9,18 +9,18 @@ <Dialog name="Bob"> <text id="0" nextid="1" pause="true"> - Hey. Have a Dank MayMay :) - <give id="Dank MayMay" count="1"/></text> + Hey. Have a Dank MayMay :) + <give id="Dank MayMay" count="1"/></text> <text id="1" nextid="2"> - What? You want another Dank MayMay? - </text> + What? You want another Dank MayMay? + </text> <text id="2" nextid="3" pause="true"> K. - <give id="Dank MayMay" count="1"/></text> + <give id="Dank MayMay" count="1"/></text> <text id="3" nextid="4"> Well... I'm out of Dank MayMays. </text> <text id="4"> Have a sword though. - <give id="Wood Sword" count="1"/></text> + <give id="Wood Sword" count="1"/></text> </Dialog> |