diff --git a/L_ECHO_README b/L_ECHO_README new file mode 100644 index 0000000..668878a --- /dev/null +++ b/L_ECHO_README @@ -0,0 +1,18 @@ +Ok, listen up. This is a development build! No guarantees. + +To control: + +Arrow Keys to control the perspective +P to start/pause/resume + +This program is under GPLv3. + +Oh, and you may need OpenGL (in every DirectX if you're using Windows) and GLUT (Windows binaries here: http://www.xmission.com/~nate/glut.html) + +That is all. + +L-Echo (C) 2008 Jeff Chien + +echochrome is a trademark of Sony Computer Entertainment Inc. © 2008 Sony Computer Entertainment Inc. + +"PlayStation?", "PLAYSTATION" and "PS" Family logo are registered trademarks of Sony Computer Entertainment Inc. diff --git a/Makefile b/Makefile index 1c2132b..a200a9b 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ w32: $(OBJFILES) i586-mingw32msvc-g++ *.OBJ win/*.OBJ tinyxml/*.OBJ glut32.lib -lGL -lGLU -g3 -Wall -o l-echo.exe clean: - rm *.o *.OBJ l-echo.exe l-echo *~ || echo + rm *.o *.OBJ l-echo.exe l-echo lin/*.o win/*.OBJ *~ || echo clean-all: clean rm tinyxml/*.o tinyxml/*.OBJ || echo diff --git a/echo_character.cpp b/echo_character.cpp new file mode 100644 index 0000000..bb1fea8 --- /dev/null +++ b/echo_character.cpp @@ -0,0 +1,199 @@ +// echo_character.cpp + +/* + This file is part of L-Echo. + + L-Echo is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + L-Echo is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with L-Echo. If not, see . +*/ + +#include +#include + +#include +#include +#include +#include +#include +#include + +#define STARTY 30 +#define SPEED_STEP 0.08f +#define SPEED_FALL 0.50f + +echo_char::echo_char() +{ + num_goals = 0; + init(NULL); +} +echo_char::echo_char(grid* g1) +{ + num_goals = 0; + init(g1); +} + +int echo_char::is_paused() +{ + return(paused); +} + +int echo_char::num_goals_reached() +{ + return(num_goals); +} + +void echo_char::change_speed() +{ + if(grid1 && grid2) + { + if(typeid(*grid1) == typeid(hole) && (typeid(*grid2) == typeid(isect_grid) + || grid2 == echo_ns::hole_grid)) + { + std::cout << "falling into hole..." << std::endl; + speed = SPEED_FALL; + } + if(typeid(*grid1) == typeid(isect_grid) + && typeid(*grid2) != typeid(isect_grid)) + { + std::cout << "normal speed" << std::endl; + speed = SPEED_STEP; + } + } +} +void echo_char::init(grid * g1) +{ + start = g1; + grid1 = g1; + if(g1) + grid2 = grid1->get_next(echo_ns::angle, grid1); + else + grid2 = NULL; + + paused = 0; + + + grid1per = 1; + grid2per = 0; + startper = 1; + speed = SPEED_STEP; + dist = 1; + change_speed(); +} + +void echo_char::toggle_pause() +{ + paused = !paused; +} + +void echo_char::kill() +{ + startper = -0.05; +} + +void echo_char::reset() +{ + init(start); +} + +void echo_char::next_grid() +{ + if(grid1->is_goal(echo_ns::angle)) + { + grid1->toggle_goal(echo_ns::angle); + num_goals++; + } + if(grid1 == echo_ns::hole_grid) + kill(); + else if(grid2) + { + grid *temp = grid2; + grid2 = grid2->get_next(echo_ns::angle, grid1); + if (grid2 == echo_ns::hole_grid) + kill(); + grid1 = temp; + change_speed(); + } + else + grid2 = NULL; + grid1per = 1; + grid2per = 0; +} + +vector3f* echo_char::step() //CHANGE FOR NORMALS +{ + if(startper > 0) + { + vector3f pos1 = start->get_info(echo_ns::angle)->pos; + startper -= 0.05; + if (startper < 0) + startper = 0; + return(new vector3f(pos1.x, pos1.y + STARTY * startper, pos1.z)); + } + else if(startper < 0) + { + vector3f pos1 = grid1->get_info(echo_ns::angle)->pos; + startper -= 0.05; + if(startper < -1) + init(start); + return(new vector3f(pos1.x, pos1.y + STARTY * startper, pos1.z)); + } + else if(grid1) + { + if (grid2 == echo_ns::hole_grid) + kill(); + else + { + if(grid1->is_goal(echo_ns::angle)) + { + grid1->toggle_goal(echo_ns::angle); + num_goals++; + } + if(grid1 && grid2 && !paused) //if both grids are there + { + grid1per -= speed / dist; //step thru it + grid2per += speed / dist; + if (grid1per <= 0) //if we've reached the end of this cycle + { + next_grid(); //on to the next cycle + } + } + if(grid1 && !grid2) //if there isn't a second grid... + { + grid2 = grid1->get_next(echo_ns::angle, grid1); //try to get one + change_speed(); + if(!grid2) //if there still isn't a second grid... + return(new vector3f(grid1->get_info(echo_ns::angle)->pos)); //return grid1's position + } + grid_info_t *i1 = grid1->get_info(echo_ns::angle); + if(i1) + { + vector3f pos1 = i1->pos; + grid_info_t *i2 = grid2->get_info(echo_ns::angle); + if(i2) + { + vector3f pos2 = i2->pos; + dist = pos1.dist(pos2); + /* + ret->dump(); + std::cout <pos)); //there isn't a second grid? but wait, wouldn't this be return already? + } + } + } + return(NULL); //i dunno why this would happen, but sure... +} diff --git a/echo_character.h b/echo_character.h new file mode 100644 index 0000000..3d5907f --- /dev/null +++ b/echo_character.h @@ -0,0 +1,51 @@ +// echo_character.h + +/* + This file is part of L-Echo. + + L-Echo is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + L-Echo is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with L-Echo. If not, see . +*/ + +#include +#include +#include + +#ifndef __ECHO_CHARACTER__ +#define __ECHO_CHARACTER__ +class echo_char +{ + protected: + grid* start; + grid* grid1; + grid* grid2; + int paused; + int num_goals; + float grid1per, grid2per, startper, speed, dist; + + public: + echo_char(); + echo_char(grid* start); + void init(grid* g1); + void reset(); + + vector3f* step(); + void kill(); + void toggle_pause(); + void next_grid(); + void change_speed(); + int is_paused(); + int num_goals_reached(); +}; +#endif + diff --git a/hole_demo.xml b/hole_demo.xml new file mode 100644 index 0000000..5af28a0 --- /dev/null +++ b/hole_demo.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/isect_grid.cpp b/isect_grid.cpp new file mode 100644 index 0000000..a4c6f08 --- /dev/null +++ b/isect_grid.cpp @@ -0,0 +1,71 @@ +// isect_grid.cpp + +/* + This file is part of L-Echo. + + L-Echo is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + L-Echo is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with L-Echo. If not, see . +*/ + +#include + +#include +#include +#include +#include +#include +#include + +isect_grid::isect_grid() +{ +} +isect_grid::isect_grid(grid_info_t* my_info, grid* my_prev, grid* my_next, vector3f camera, GRID_PTR_SET* my_level) +{ + init(my_info, my_prev, my_next, camera, my_level); +} +void isect_grid::init(grid_info_t* my_info, grid* my_prev, grid* my_next, vector3f camera, GRID_PTR_SET* my_level) +{ + level_y = my_info->pos.y; + static_grid::init(my_info, my_prev, my_next, camera); + level = my_level; +} + +grid* isect_grid::get_next(vector3f angle, grid* current) +{ + refresh(angle); + GRID_PTR_SET::iterator it = level->begin(), end = level->end(); + vector3f prev_pos = get_real_prev()->get_info(angle)->pos; + vector3f vec = ginfo->pos - prev_pos; + float delta_y = level_y - prev_pos.y; + if((delta_y > 0 && vec.y < 0) || (delta_y < 0 && vec.y > 0)) + return(grid::get_next(angle, current)); + vec = vec * (delta_y / vec.y); + vector3f end_pt = prev_pos + vec; + /* + std::cout << "end_pt: " << std::endl; + end_pt.dump(); + std::cout << std::endl; + // */ + while(it != end) + { + grid* g = *it; + if(g->is_pt_on(angle,end_pt)) + { + return(g); + } + it++; + } + return(grid::get_next(angle, current)); +} + + diff --git a/isect_grid.h b/isect_grid.h new file mode 100644 index 0000000..6c7fbd2 --- /dev/null +++ b/isect_grid.h @@ -0,0 +1,41 @@ +// isect_grid.h + +/* + This file is part of L-Echo. + + L-Echo is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + L-Echo is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with L-Echo. If not, see . +*/ + +#include +#include +#include +#include + +#ifndef __ECHO_CLASS_ISECT_GRID__ +#define __ECHO_CLASS_ISECT_GRID__ +class isect_grid : public static_grid +{ + protected: + GRID_PTR_SET* level; + float level_y; + public: + isect_grid(); + isect_grid(grid_info_t* my_info, grid* my_prev, grid* my_next, vector3f camera, GRID_PTR_SET* my_level); + void init(grid_info_t* my_info, grid* my_prev, grid* my_next, vector3f camera, GRID_PTR_SET* my_level); + + virtual grid* get_next(vector3f angle, grid* current); +}; +#endif + + diff --git a/echo_sys_linux.cpp b/lin/echo_sys_linux.cpp similarity index 100% rename from echo_sys_linux.cpp rename to lin/echo_sys_linux.cpp diff --git a/simple.xml b/simple.xml new file mode 100644 index 0000000..c560872 --- /dev/null +++ b/simple.xml @@ -0,0 +1,4 @@ + + + + diff --git a/static_grid.cpp b/static_grid.cpp new file mode 100644 index 0000000..d9d496d --- /dev/null +++ b/static_grid.cpp @@ -0,0 +1,76 @@ +// static_grid.cpp + +/* + This file is part of L-Echo. + + L-Echo is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + L-Echo is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with L-Echo. If not, see . +*/ + +#include + +#include +#include +#include +#include + +static_grid::static_grid() +{ +} +static_grid::static_grid(grid_info_t* my_info, grid* my_prev, grid* my_next, vector3f camera) +{ + init(my_info, my_prev, my_next, camera); +} +void static_grid::init(grid_info_t* my_info, grid* my_prev, grid* my_next, vector3f camera) +{ + grid::init(new(grid_info_t), my_prev, my_next); + real_vec = my_info->pos.neg_rotate_yx(camera); + force_refresh(camera); +} +void static_grid::refresh(vector3f camera) +{ + if(camera != prev_angle) + { + force_refresh(camera); + } +} + +void static_grid::force_refresh(vector3f camera) +{ + ginfo->pos = *(real_vec->rotate_xy(camera)); + lines = generate_lines(*ginfo); + prev_angle.set(camera); + + /* + std::cout << "refresh: "; + ginfo->pos.dump(); + std::cout << std::endl; + // */ +} + +grid_info_t* static_grid::get_info(vector3f angle) +{ + refresh(angle); + return(ginfo); +} + +void static_grid::draw(vector3f angle) +{ + refresh(angle); + /* + draw_line(ginfo->pos + *(new vector3f(0, 0.3f, 0)) + , ginfo->pos - *(new vector3f(0, 0.3f, 0))); + // */ + grid::draw(angle); +} + diff --git a/static_grid.h b/static_grid.h new file mode 100644 index 0000000..6287708 --- /dev/null +++ b/static_grid.h @@ -0,0 +1,42 @@ +// static_grid.h + +/* + This file is part of L-Echo. + + L-Echo is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + L-Echo is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with L-Echo. If not, see . +*/ + +#include +#include + +#ifndef __ECHO_CLASS_STATIC_GRID__ +#define __ECHO_CLASS_STATIC_GRID__ +class static_grid : public grid +{ + protected: + vector3f* real_vec; + vector3f prev_angle; + public: + static_grid(); + static_grid(grid_info_t* my_info, grid* my_prev, grid* my_next, vector3f camera); + void init(grid_info_t* my_info, grid* my_prev, grid* my_next, vector3f camera); + + void refresh(vector3f camera); + void force_refresh(vector3f camera); + virtual grid_info_t* get_info(vector3f angle); + virtual void draw(vector3f angle); +}; +#endif + + diff --git a/echo_sys_w32.cpp b/win/echo_sys_w32.cpp similarity index 100% rename from echo_sys_w32.cpp rename to win/echo_sys_w32.cpp