From 95a6777ebd2d2e577629438987e86b5b90d47f5a Mon Sep 17 00:00:00 2001 From: Logen Kain Date: Sun, 7 Aug 2016 14:42:10 -0700 Subject: [PATCH] Starting loki programming guide --- loki_sample/Makefile | 34 ++++++++++++++++++++++++++++++++ loki_sample/gdb_example/Makefile | 2 ++ loki_sample/gdb_example/NOTES | 1 + loki_sample/gdb_example/buggy.c | 11 +++++++++++ loki_sample/notes | 20 +++++++++++++++++++ 5 files changed, 68 insertions(+) create mode 100644 loki_sample/Makefile create mode 100644 loki_sample/gdb_example/Makefile create mode 100644 loki_sample/gdb_example/NOTES create mode 100644 loki_sample/gdb_example/buggy.c create mode 100644 loki_sample/notes diff --git a/loki_sample/Makefile b/loki_sample/Makefile new file mode 100644 index 0000000..ffd9e85 --- /dev/null +++ b/loki_sample/Makefile @@ -0,0 +1,34 @@ +PREFIX=/usr + +#OBJS specifies which files to compile as part of the project +OBJS = tuxc.c lib/logenlib.c + +#CC specifies which compiler to use +CC = clang + +#COMPILER_FLAGS specifies the additional compilation options we're using +# -w suppress all warnings +COMPILER_FLAGS = -Wall + +#LINKER_FLAGS specifies the libraries we're linking against +LINKER_FLAGS = -llua + +#OBJ_NAME specifies the name of our executable +OBJ_NAME= tuxc + +#This is the target that compiles our executable +all : $(OBJS) + $(CC) $(OBJS) $(COMPILER_FLAGS) $(LINKER_FLAGS) -o $(OBJ_NAME) +install : + mkdir -p ${PREFIX}/share/tuxc + cp tuxc ${PREFIX}/share/tuxc/ + cp -R package_managers ${PREFIX}/share/tuxc/ + ln -si ${PREFIX}/share/tuxc/tuxc ${PREFIX}/bin/tux +uninstall : + rm ${PREFIX}/bin/tux + rm -r ${PREFIX}/share/tuxc/package_managers + rm ${PREFIX}/share/tuxc/tuxc + rm -r ${PREFIX}/share/tuxc +clean : + rm tuxc + diff --git a/loki_sample/gdb_example/Makefile b/loki_sample/gdb_example/Makefile new file mode 100644 index 0000000..1faef37 --- /dev/null +++ b/loki_sample/gdb_example/Makefile @@ -0,0 +1,2 @@ +ALL: + gcc -ggdb buggy.c -o buggy diff --git a/loki_sample/gdb_example/NOTES b/loki_sample/gdb_example/NOTES new file mode 100644 index 0000000..17a41a3 --- /dev/null +++ b/loki_sample/gdb_example/NOTES @@ -0,0 +1 @@ +this did not help me figure out gdb; however, clang happily showed me the issue easily. However, DDD worked amazingly. All I have to do is add a breakpoint and then run the program. It shows results as it goes. It's great! diff --git a/loki_sample/gdb_example/buggy.c b/loki_sample/gdb_example/buggy.c new file mode 100644 index 0000000..1f752b7 --- /dev/null +++ b/loki_sample/gdb_example/buggy.c @@ -0,0 +1,11 @@ +#include + +int main() +{ + int i; + for (i = 0; i < 10; i++); // The bug is this extra semicolon + printf("Counter is now %i\n",i); + return 0; +} +// Should (wrongfully) only print out "Counter is now 10" +// Note that GCC does not report an error. Clang reports the error. diff --git a/loki_sample/notes b/loki_sample/notes new file mode 100644 index 0000000..bb8af32 --- /dev/null +++ b/loki_sample/notes @@ -0,0 +1,20 @@ +Most engines seem to have this. + +Input subsystem >> Keyboard/Mouse/Game Pad + +Network Subsystem >> internet or lan + +update subsystem >> This should not be in the game loop >> Should be a seperate module to begin with >> Pay attention to code organization. + +display subsystem >> 32 Hardware / Framebuffer + +Audio Sybsystem >> sound card + +main loop >> Just a while loop that runs the entire time anywhere from 30 to 60 times per second. + Invokes correct routines to gather input from the player and network + updates the status of all objects in the game + draws the next frame of graphics + and produces audio. + seperating meu system from main loop is good, but can complicate the code + Networking information should usually be grabed first + Graphics should be usually grabed last