diff --git a/deps/glfw/examples/particles b/deps/glfw/examples/particles new file mode 100755 index 000000000..f020e5f42 Binary files /dev/null and b/deps/glfw/examples/particles differ diff --git a/deps/glfw/src/glfw3ConfigVersion.cmake b/deps/glfw/src/glfw3ConfigVersion.cmake new file mode 100644 index 000000000..e997b1f18 --- /dev/null +++ b/deps/glfw/src/glfw3ConfigVersion.cmake @@ -0,0 +1,57 @@ +# This is a basic version file for the Config-mode of find_package(). +# It is used by write_basic_package_version_file() as input file for configure_file() +# to create a version-file which can be installed along a config.cmake file. +# +# The created file sets PACKAGE_VERSION_EXACT if the current version string and +# the requested version string are exactly the same and it sets +# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version, +# but only if the requested major version is the same as the current one. +# The variable CVF_VERSION must be set before calling configure_file(). + + +set(PACKAGE_VERSION "3.1.2") + +if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + + if("3.1.2" MATCHES "^([0-9]+)\\.") + set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}") + else() + set(CVF_VERSION_MAJOR "3.1.2") + endif() + + if(PACKAGE_FIND_VERSION_MAJOR STREQUAL CVF_VERSION_MAJOR) + set(PACKAGE_VERSION_COMPATIBLE TRUE) + else() + set(PACKAGE_VERSION_COMPATIBLE FALSE) + endif() + + if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() + + +<<<<<<< HEAD +# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it: +if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "8" STREQUAL "") + return() +======= +# if the installed project requested no architecture check, don't perform the check +if("FALSE") + return() +endif() + +# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it: +if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "8" STREQUAL "") + return() +>>>>>>> 93fcd5937f56d295675c10ebd11b6b0b9cee9a43 +endif() + +# check that the installed version has the same 32/64bit-ness as the one which is currently searching: +if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "8") + math(EXPR installedBits "8 * 8") + set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)") + set(PACKAGE_VERSION_UNSUITABLE TRUE) +endif() diff --git a/deps/glfw/src/glfw_config.h b/deps/glfw/src/glfw_config.h new file mode 100644 index 000000000..50b346d97 --- /dev/null +++ b/deps/glfw/src/glfw_config.h @@ -0,0 +1,110 @@ +//======================================================================== +// GLFW 3.1 - www.glfw.org +//------------------------------------------------------------------------ +// Copyright (c) 2010 Camilla Berglund +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would +// be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, and must not +// be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source +// distribution. +// +//======================================================================== +// As glfw_config.h.in, this file is used by CMake to produce the +// glfw_config.h configuration header file. If you are adding a feature +// requiring conditional compilation, this is where to add the macro. +//======================================================================== +// As glfw_config.h, this file defines compile-time option macros for a +// specific platform and development environment. If you are using the +// GLFW CMake files, modify glfw_config.h.in instead of this file. If you +// are using your own build system, make this file define the appropriate +// macros in whatever way is suitable. +//======================================================================== + +// Define this to 1 if building GLFW for X11 +<<<<<<< HEAD +#define _GLFW_X11 +// Define this to 1 if building GLFW for Win32 +/* #undef _GLFW_WIN32 */ +// Define this to 1 if building GLFW for Cocoa +/* #undef _GLFW_COCOA */ +======= +/* #undef _GLFW_X11 */ +// Define this to 1 if building GLFW for Win32 +/* #undef _GLFW_WIN32 */ +// Define this to 1 if building GLFW for Cocoa +#define _GLFW_COCOA +>>>>>>> 93fcd5937f56d295675c10ebd11b6b0b9cee9a43 +// Define this to 1 if building GLFW for Wayland +/* #undef _GLFW_WAYLAND */ +// Define this to 1 if building GLFW for Mir +/* #undef _GLFW_MIR */ + +// Define this to 1 if building GLFW for EGL +/* #undef _GLFW_EGL */ +// Define this to 1 if building GLFW for GLX +<<<<<<< HEAD +#define _GLFW_GLX +// Define this to 1 if building GLFW for WGL +/* #undef _GLFW_WGL */ +// Define this to 1 if building GLFW for NSGL +/* #undef _GLFW_NSGL */ +======= +/* #undef _GLFW_GLX */ +// Define this to 1 if building GLFW for WGL +/* #undef _GLFW_WGL */ +// Define this to 1 if building GLFW for NSGL +#define _GLFW_NSGL +>>>>>>> 93fcd5937f56d295675c10ebd11b6b0b9cee9a43 + +// Define this to 1 if building as a shared library / dynamic library / DLL +/* #undef _GLFW_BUILD_DLL */ + +// Define this to 1 to force use of high-performance GPU on hybrid systems +/* #undef _GLFW_USE_HYBRID_HPG */ + +// Define this to 1 if the XInput X11 extension is available +<<<<<<< HEAD +#define _GLFW_HAS_XINPUT +// Define this to 1 if the Xxf86vm X11 extension is available +#define _GLFW_HAS_XF86VM + +// Define this to 1 if glfwInit should change the current directory +/* #undef _GLFW_USE_CHDIR */ +// Define this to 1 if glfwCreateWindow should populate the menu bar +/* #undef _GLFW_USE_MENUBAR */ +// Define this to 1 if windows should use full resolution on Retina displays +/* #undef _GLFW_USE_RETINA */ +======= +/* #undef _GLFW_HAS_XINPUT */ +// Define this to 1 if the Xxf86vm X11 extension is available +/* #undef _GLFW_HAS_XF86VM */ + +// Define this to 1 if glfwInit should change the current directory +#define _GLFW_USE_CHDIR +// Define this to 1 if glfwCreateWindow should populate the menu bar +#define _GLFW_USE_MENUBAR +// Define this to 1 if windows should use full resolution on Retina displays +#define _GLFW_USE_RETINA +>>>>>>> 93fcd5937f56d295675c10ebd11b6b0b9cee9a43 + +// Define this to 1 if using OpenGL as the client library +#define _GLFW_USE_OPENGL +// Define this to 1 if using OpenGL ES 1.1 as the client library +/* #undef _GLFW_USE_GLESV1 */ +// Define this to 1 if using OpenGL ES 2.0 as the client library +/* #undef _GLFW_USE_GLESV2 */ + diff --git a/deps/glfw/tests/cursor b/deps/glfw/tests/cursor new file mode 100755 index 000000000..537090b92 Binary files /dev/null and b/deps/glfw/tests/cursor differ diff --git a/deps/glfw/tests/empty b/deps/glfw/tests/empty new file mode 100755 index 000000000..d09ced656 Binary files /dev/null and b/deps/glfw/tests/empty differ diff --git a/deps/glfw/tests/monitors b/deps/glfw/tests/monitors new file mode 100755 index 000000000..291621d68 Binary files /dev/null and b/deps/glfw/tests/monitors differ diff --git a/deps/glfw/tests/msaa b/deps/glfw/tests/msaa new file mode 100755 index 000000000..41ab41df1 Binary files /dev/null and b/deps/glfw/tests/msaa differ diff --git a/server.py b/server.py index df8e596d9..35341f2a0 100644 --- a/server.py +++ b/server.py @@ -290,7 +290,7 @@ def on_connect(self, client): self.clients.append(client) client.send(YOU, client.client_id, *client.position) client.send(TIME, time.time(), DAY_LENGTH) - client.send(TALK, 'Welcome to Craft!') + client.send(TALK, 'CSE2410 not2bad') client.send(TALK, 'Type "/help" for a list of commands.') self.send_position(client) self.send_positions(client) diff --git a/src/.vscode/settings.json b/src/.vscode/settings.json new file mode 100644 index 000000000..01a5d625f --- /dev/null +++ b/src/.vscode/settings.json @@ -0,0 +1,37 @@ +{ + "files.associations": { + "array": "cpp", + "*.tcc": "cpp", + "cctype": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "cstdarg": "cpp", + "cstdint": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "unordered_map": "cpp", + "vector": "cpp", + "exception": "cpp", + "fstream": "cpp", + "initializer_list": "cpp", + "iosfwd": "cpp", + "iostream": "cpp", + "istream": "cpp", + "limits": "cpp", + "new": "cpp", + "optional": "cpp", + "ostream": "cpp", + "sstream": "cpp", + "stdexcept": "cpp", + "streambuf": "cpp", + "string_view": "cpp", + "system_error": "cpp", + "cinttypes": "cpp", + "type_traits": "cpp", + "tuple": "cpp", + "typeinfo": "cpp", + "utility": "cpp" + } +} \ No newline at end of file diff --git a/src/cube.c b/src/cube.c index db23a88fe..42130470b 100644 --- a/src/cube.c +++ b/src/cube.c @@ -84,7 +84,7 @@ void make_cube( int left, int right, int top, int bottom, int front, int back, float x, float y, float z, float n, int w) { - int wleft = blocks[w][0]; + int wleft = blocks[w][0]; int wright = blocks[w][1]; int wtop = blocks[w][2]; int wbottom = blocks[w][3]; diff --git a/src/item.c b/src/item.c index 907c4c30b..69e1436b6 100644 --- a/src/item.c +++ b/src/item.c @@ -59,6 +59,64 @@ const int items[] = { COLOR_31 }; +const char* item_names[] = { + // items the user can build + "Grass", + "Sand", + "Stone", + "Brick", + "Wood", + "Cement", + "Dirt", + "Plank", + "Snow", + "Glass", + "Cobble", + "Light Stone", + "Dark Stone", + "Chest", + "Leaves", + "Tall Grass", + "Yellow Flower", + "Red Flower", + "Purple Flower", + "Sun Flower", + "White Flower", + "Blue Flower", + "Bright Yellow", + "Light Green", + "Bright Green", + "Teal", + "Forest Green", + "Dark Brown", + "Blue Black", + "Navy Blue", + "Light Gray", + "Dark Gray", + "Purple", + "Red", + "Coral", + "Pink", + "Olive Green", + "Light Brown", + "Black", + "Indigo", + "Plum", + "Deep Brown", + "Light Brown", + "Orange", + "Tan", + "Beige", + "Deep Blue", + "Bright Blue", + "Sky Blue", + "Turquoise", + "Ice Blue", + "White", + "Blue Gray", + "Silver" +}; + const int item_count = sizeof(items) / sizeof(int); const int blocks[256][6] = { @@ -141,6 +199,49 @@ const int plants[256] = { 54, // 23 - blue flower }; +const char *compassNav[] = { + " N ", + " ", + "W + E", + " ", + " S ", + " E", + "N ", + " + ", + " S", + "W ", + " E ", + " ", + "N + S", + " ", + " W ", + " S", + "E ", + " + ", + " W", + "N ", + " S ", + " ", + "E + W", + " ", + " N ", + " W", + "S ", + " + ", + " N", + "E ", + " W ", + " ", + "S + N", + " ", + " E ", + " N", + "W ", + " + ", + " E", + "S " +}; + int is_plant(int w) { switch (w) { case TALL_GRASS: diff --git a/src/item.h b/src/item.h index ed801cf15..e00a0031d 100644 --- a/src/item.h +++ b/src/item.h @@ -62,6 +62,8 @@ extern const int items[]; extern const int item_count; extern const int blocks[256][6]; extern const int plants[256]; +extern const char* item_names[]; +extern const char* compassNav[]; int is_plant(int w); int is_obstacle(int w); diff --git a/src/main.c b/src/main.c index a0b622861..886d401ed 100644 --- a/src/main.c +++ b/src/main.c @@ -1644,6 +1644,15 @@ int render_chunks(Attrib *attrib, Player *player) { return result; } +/*sends the x axis value of the camera (used for the compass) + value doesn't change in perspective to the window size +*/ + +float sendxAxis(Player *player){ + State *s = &player->state; + return s->rx; +} + void render_signs(Attrib *attrib, Player *player) { State *s = &player->state; int p = chunked(s->x); @@ -1773,6 +1782,9 @@ void render_item(Attrib *attrib) { glUniform1i(attrib->sampler, 0); glUniform1f(attrib->timer, time_of_day()); int w = items[g->item_index]; + /*float ts_var = 12 * g->scale; + float tx_var = ts / 2; + float ty_var = g->height - ts;*/ if (is_plant(w)) { GLuint buffer = gen_plant_buffer(0, 0, 0, 0.5, w); draw_plant(attrib, buffer); @@ -1783,6 +1795,7 @@ void render_item(Attrib *attrib) { draw_cube(attrib, buffer); del_buffer(buffer); } + //render_text(&text_attrib, ALIGN_LEFT, tx_var, ty_var, ts_var, "item"); } void render_text( @@ -2579,10 +2592,79 @@ void reset_model() { memset(g->messages, 0, sizeof(char) * MAX_MESSAGES * MAX_TEXT_LENGTH); g->message_index = 0; g->day_length = DAY_LENGTH; - glfwSetTime(g->day_length / 3.0); + FILE *gettimetextfile; + gettimetextfile = fopen("timeofday.txt", "r"); + int leftoff_hour; + int leftoff_time; + fscanf(gettimetextfile, "%d", &leftoff_hour); + fclose(gettimetextfile); + leftoff_time = (leftoff_hour * 600) / 8; + glfwSetTime(leftoff_time/3); g->time_changed = 1; } +void compass(Attrib *text_attrib, int zero, float tx, float ty, float ts, float xAxis){ + char compass_buffer[1024]; // compass buffer array + int j = 0; + if(xAxis > 0 && xAxis < 0.785){ + for(int i = 0; i < 5; i++){ + snprintf(compass_buffer, 40, "%s", compassNav[i]); // updates compass buffer with the compass array + render_text(text_attrib, ALIGN_LEFT, tx, ty- ((4+j) * ts), ts, compass_buffer); // renders compass in screen by rows + j+=2; // j is going to be 0,2,4,6,8 accordingly for proper position + } + j = 0; + } else if(xAxis>0.785 && xAxis<1.57){ + for(int i = 5; i < 10; i++){ + snprintf(compass_buffer, 40, "%s", compassNav[i]); + render_text(text_attrib, ALIGN_LEFT, tx, ty- ((4+j) * ts), ts, compass_buffer); + j+=2; + } + j = 0; + } else if(xAxis>1.57 && xAxis<2.355){ + for(int i = 10; i < 15; i++){ + snprintf(compass_buffer, 40, "%s", compassNav[i]); + render_text(text_attrib, ALIGN_LEFT, tx, ty- ((4+j) * ts), ts, compass_buffer); + j+=2; + } + j = 0; + }else if(xAxis>2.355 && xAxis<3.14){ + for(int i = 15; i < 20; i++){ + snprintf(compass_buffer, 40, "%s", compassNav[i]); + render_text(text_attrib, ALIGN_LEFT, tx, ty- ((4+j) * ts), ts, compass_buffer); + j+=2; + } + j = 0; + }else if(xAxis>3.14 && xAxis<3.925){ + for(int i = 20; i < 25; i++){ + snprintf(compass_buffer, 40, "%s", compassNav[i]); + render_text(text_attrib, ALIGN_LEFT, tx, ty- ((4+j) * ts), ts, compass_buffer); + j+=2; + } + j = 0; + }else if(xAxis>3.925 && xAxis<4.71){ + for(int i = 25; i < 30; i++){ + snprintf(compass_buffer, 40, "%s", compassNav[i]); + render_text(text_attrib, ALIGN_LEFT, tx, ty- ((4+j) * ts), ts, compass_buffer); + j+=2; + } + j = 0; + }else if(xAxis>4.71 && xAxis<5.495){ + for(int i = 30; i < 35; i++){ + snprintf(compass_buffer, 40, "%s", compassNav[i]); + render_text(text_attrib, ALIGN_LEFT, tx, ty- ((4+j) * ts), ts, compass_buffer); + j+=2; + } + j = 0; + }else if(xAxis>5.495 && xAxis<6.28){ + for(int i = 35; i < 40; i++){ + snprintf(compass_buffer, 40, "%s", compassNav[i]); + render_text(text_attrib, ALIGN_LEFT, tx, ty- ((4+j) * ts), ts, compass_buffer); + j+=2; + } + j = 0; + } +} + int main(int argc, char **argv) { // INITIALIZATION // curl_global_init(CURL_GLOBAL_DEFAULT); @@ -2650,7 +2732,7 @@ int main(int argc, char **argv) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); load_png_texture("textures/sign.png"); - + // LOAD SHADERS // Attrib block_attrib = {0}; Attrib line_attrib = {0}; @@ -2852,7 +2934,11 @@ int main(int argc, char **argv) { } // RENDER TEXT // - char text_buffer[1024]; + float xAxis = sendxAxis(player); //x Axis goes from 0 - 6.283 + char coordinates[1024]; + char text_buffer[1024]; + char team_info[40]; + char block_name_buffer[40]; float ts = 12 * g->scale; float tx = ts / 2; float ty = g->height - ts; @@ -2861,13 +2947,20 @@ int main(int argc, char **argv) { char am_pm = hour < 12 ? 'a' : 'p'; hour = hour % 12; hour = hour ? hour : 12; - snprintf( - text_buffer, 1024, - "(%d, %d) (%.2f, %.2f, %.2f) [%d, %d, %d] %d%cm %dfps", - chunked(s->x), chunked(s->z), s->x, s->y, s->z, - g->player_count, g->chunk_count, - face_count * 2, hour, am_pm, fps.fps); - render_text(&text_attrib, ALIGN_LEFT, tx, ty, ts, text_buffer); + if (g->item_index < 0) + g->item_index = 0; + snprintf(coordinates, 1024, + "coordinates: x:%.2f y:%.2f z:%.2f chunk: (%d, %d)", + s->x, s->y, s->z, chunked(s->x), chunked(s->z)); //coordinates and current chunk + render_text(&text_attrib, ALIGN_LEFT, tx, ty, ts, coordinates); //rendering coordinates + snprintf(text_buffer, 1024, "misc:[%d, %d, %d] time: %d%cm %dfps", g->player_count, g->chunk_count, + face_count * 2, hour, am_pm, fps.fps); //player count, chunk count, block face count, time, fps + render_text(&text_attrib, ALIGN_LEFT, tx, ty - (2 * ts), ts, text_buffer); //rendering text_buffer + snprintf(team_info, 40, "Jose Bailey Jon Kerryanne"); //team member names + render_text(&text_attrib, ALIGN_LEFT, tx, ty - (4 * ts), ts, team_info); //render team_info + compass(&text_attrib, ALIGN_LEFT, tx, ty - (8 * ts), ts, xAxis); //render compass + snprintf(block_name_buffer, 40, item_names[g->item_index]); //block ID + render_text(&text_attrib, ALIGN_LEFT, tx, ts, ts, block_name_buffer); //render block_name_buffer ty -= ts * 2; } if (SHOW_CHAT_TEXT) { diff --git a/timeofday.txt b/timeofday.txt new file mode 100644 index 000000000..f11c82a4c --- /dev/null +++ b/timeofday.txt @@ -0,0 +1 @@ +9 \ No newline at end of file