Skip to content

Commit

Permalink
0.1.0 - in-game loading! And apologies to people who tried compiling,…
Browse files Browse the repository at this point in the history
… but couldn't find a Makefile...forgot it on the last cleanup
  • Loading branch information
penguin673 committed May 30, 2008
1 parent 1992d76 commit 6c85d80
Show file tree
Hide file tree
Showing 6 changed files with 404 additions and 26 deletions.
6 changes: 6 additions & 0 deletions L_ECHO_README
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@ To control:

Arrow Keys to control the perspective
P to start/pause/resume
L to toggle the loading screen

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)

ATTENTION!: NO REAL ECHOCHROME LEVELS ARE INCLUDED!!! REPEAT WITH ME: echochrome is a trademark of Sony Computer Entertainment Inc.
© 2008 Sony Computer Entertainment Inc. Thus, I can't provide real echochrome levels.

Contact me at: penguin673 at gmail dot com

That is all.

L-Echo (C) 2008 Jeff Chien
Expand Down
41 changes: 41 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
CXXFLAGS = -I./ -I../include -DTIXML_USE_STL -g3 -Wall
TINYXML_USE_STL := YES

CPPFILES := $(wildcard *.cpp) $(wildcard tinyxml/*.cpp)

LINFILES := $(wildcard lin/*.cpp)
OFILES := $(CPPFILES:.cpp=.o) $(LINFILES:.cpp=.o)

WINFILES := $(wildcard win/*.cpp)
OBJFILES := $(CPPFILES:.cpp=.OBJ) $(WINFILES:.cpp=.OBJ)

PKGPREFIX := ../l-echo-0.1.0_r30-

all: $(OFILES)
gcc tinyxml/*.o *.o lin/*.o -DTIXML_USE_STL -lGL -lGLU /usr/lib/libglut.so.3.8.0 -lpthread -g3 -Wall -o l-echo

%.OBJ: %.cpp
i586-mingw32msvc-g++ $(CXXFLAGS) -c -o $@ $<

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 lin/*.o win/*.OBJ *~ || echo

clean-all: clean
rm tinyxml/*.o tinyxml/*.OBJ || echo

run: all
./l-echo perspective_movement.xml

dbg: all
gdb ./l-echo

package: all w32
zip -r $(PKGPREFIX)lin32.zip l-echo *.xml L_ECHO_README
zip -r $(PKGPREFIX)w32.zip l-echo.exe *.xml L_ECHO_README

count:
wc -l *.cpp *.h lin/*.cpp win/*.cpp

2 changes: 2 additions & 0 deletions echo_character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,14 @@ vector3f* echo_char::step() //CHANGE FOR NORMALS
}
if(grid1 && grid2 && !paused) //if both grids are there
{
/*
if(speed == SPEED_LAUNCH)
{
grid1per -= speed;
grid2per += speed;
}
else
// */
{
grid1per -= speed / dist; //step thru it
grid2per += speed / dist;
Expand Down
143 changes: 143 additions & 0 deletions echo_ingame_loader.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
// echo_ingame_loader.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 <http://www.gnu.org/licenses/>.
*/

#include <cstdlib>
#include <cstring>
#include <iostream>
//POSIX
#include <dirent.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>

#include <echo_stage.h>
#include <echo_loader.h>
#include <echo_ingame_loader.h>

char* echo_merge(const char* arg1, const char* arg2)
{
char* ret = new char[strlen(arg1) + strlen(arg2) + 2];
strcat(strcat(strcpy(ret, arg1), "/"), arg2);
return(ret);
}

int is_dir(const char* dir, const char* fname)
{
if(!strcmp(fname, ".."))
return(1);
char* merged = echo_merge(dir, fname);
int ret = is_dir(merged);
delete merged;
return(ret);
}

int is_dir(const char* fname)
{
int fd = open(fname, O_RDONLY);
struct stat *file_stat = new(struct stat);
int exists = !fstat(fd, file_stat);
close(fd);
if(exists)
{
int ret = S_ISDIR(file_stat->st_mode);
delete file_stat;
return(ret);
}
delete file_stat;
return(0);
}

static char* cmp_dir;

static int cmp(const void* arg1v, const void* arg2v)
{
const char* arg1 = *((char**)arg1v);
const char* arg2 = *((char**)arg2v);
//std::cout << "cmp: " << arg1v << ", " << arg2v<< std::endl;
int arg1isdir = is_dir(cmp_dir, arg1), arg2isdir = is_dir(cmp_dir, arg2);
if(arg1isdir && !arg2isdir)
return(-1);
if(!arg1isdir && arg2isdir)
return(1);
return(strcmp(arg1, arg2));
}

echo_files* get_files(const char* dirname)
{
int fd = open(dirname, O_RDONLY);
struct stat dir_stat;
int exists = !fstat(fd, &dir_stat);
close(fd);
if(exists)
{
DIR* dir = opendir(dirname);
echo_files* ret = new(echo_files);
ret->num_files = 0;
ret->current_dir = const_cast<char*>(dirname);
dirent* each_ent;
while(each_ent = readdir(dir))
{
//std::cout << "each_ent->d_name: " << each_ent->d_name << std::endl;
if(strcmp(each_ent->d_name, ".") && strcmp(each_ent->d_name, ".."))
ret->num_files++;
}
//std::cout << "each_ent: " << each_ent << std::endl;
ret->num_files++;
ret->file_names = new char*[ret->num_files];
ret->file_names[0] = "..";

int each = 1;

rewinddir(dir);
while(each_ent = readdir(dir))
{
/*
fname = new char[strlen(dirname) + strlen(each_ent->d_name) + 1];
ret->file_names[each] = strcat(strcpy(fname, dirname)
, strcmp(".", each_ent->d_name) ? each_ent->d_name : "..");
// */
if(strcmp(each_ent->d_name, ".") && strcmp(each_ent->d_name, ".."))
{
ret->file_names[each] = new char[strlen(each_ent->d_name) + 1];
strcpy(ret->file_names[each], each_ent->d_name);
each++;
}
}
//std::cout << "num_files + each: " << ret->num_files << ", " << each << std::endl;
closedir(dir);

cmp_dir = ret->current_dir;
//std::cout << "cmp_dir: " << cmp_dir << std::endl;
qsort(ret->file_names, ret->num_files, sizeof(char*), cmp);
return(ret);
}
return(NULL);
}

void dump_files(echo_files* files)
{
int each = 0;
std::cout << "files->num_files: " << files->num_files << std::endl;
while(each < files->num_files)
{
std::cout << "files: " << files->file_names[each] << std::endl;
each++;
}
}

39 changes: 39 additions & 0 deletions echo_ingame_loader.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// echo_ingame_loader.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 <http://www.gnu.org/licenses/>.
*/

#include <echo_stage.h>
#include <echo_loader.h>

#ifndef __ECHO_INTERNAL_FILES__
#define __ECHO_INTERNAL_FILES__
typedef struct
{
char* current_dir;
char** file_names;
int num_files;
} echo_files;
#endif

char* echo_merge(const char* arg1, const char* arg2);
echo_files* get_files(const char* dirname);
void dump_files(echo_files* files);
int is_dir(const char* dir, const char* fname);
int is_dir(const char* fname);


Loading

0 comments on commit 6c85d80

Please sign in to comment.