Parcourir la source

Make project compilable with make

DricomDragon il y a 4 ans
Parent
commit
cac967b61a
7 fichiers modifiés avec 88 ajouts et 16 suppressions
  1. 40 3
      .gitignore
  2. 18 9
      README.md
  3. 26 0
      makefile
  4. 1 1
      src/Control/Input.h
  5. 1 1
      src/Game.h
  6. 1 1
      src/HitManager.h
  7. 1 1
      src/Shot.h

+ 40 - 3
.gitignore

@@ -1,3 +1,40 @@
-.idea/
-cmake-build-debug/*
-*.py
+# Created by https://www.toptal.com/developers/gitignore/api/c++
+# Edit at https://www.toptal.com/developers/gitignore?templates=c++
+
+### C++ ###
+# Prerequisites
+*.d
+
+# Compiled Object files
+*.slo
+*.lo
+*.o
+*.obj
+
+# Precompiled Headers
+*.gch
+*.pch
+
+# Compiled Dynamic libraries
+*.so
+*.dylib
+*.dll
+
+# Fortran module files
+*.mod
+*.smod
+
+# Compiled Static libraries
+*.lai
+*.la
+*.a
+*.lib
+
+# Executables
+*.exe
+*.out
+*.app
+
+# End of https://www.toptal.com/developers/gitignore/api/c++
+
+bin/

+ 18 - 9
README.md

@@ -29,16 +29,25 @@ My own website where you can find more about this game, like executables (french
 
 ## Installation
 
-### To build
+### Ubuntu
 
-#### Ubuntu
-Execute the following commands to install SDL and SDL GFX :
-`sudo apt install libsdl1.2-dev`
-`sudo apt install libsdl-gfx1.2-dev`
+#### Build
+
+You need `make` and `SDL1` and `SDL_gfx` to build this project.
+
+Example on Ubuntu :
+```sh
+$ sudo apt install make g++ libsdl-dev libsdl-gfx1.2-dev
+$ make
+```
 
-### To play
+To execute :
+```sh
+$ make exec
+```
+
+#### To play
 
-#### Ubuntu
 Execute the following commands to install SDL and SDL GFX :
-`sudo apt install libsdl1.2debian`
-`sudo apt install libsdl-gfx1.2-5`
+
+`sudo apt install libsdl1.2debian libsdl-gfx1.2-5`

+ 26 - 0
makefile

@@ -0,0 +1,26 @@
+CXX=g++
+CXXFLAGS=
+LDFLAGS=-lSDL -lSDL_gfx
+INC=
+LIB=
+
+EXEC=AsciiSpaceDestroyer
+SRC=$(shell find . -name '*.cpp') 
+OBJ=$(SRC:.cpp=.o)
+
+$(EXEC): $(OBJ)
+	@mkdir -p bin
+	$(CXX) -o bin/$@ $^ $(LDFLAGS) $(LIB)
+
+#TODO add .h in case of global variables
+%.o : %.cpp 
+	$(CXX) -o $@ -c $< $(CXXFLAGS) $(INC)
+	
+clean:
+	rm -rf $(OBJ)
+
+distclean: clean
+	rm -rf $(EXEC)
+
+exec: $(EXEC)
+	./bin/$(EXEC)

+ 1 - 1
src/Control/Input.h

@@ -6,7 +6,7 @@
 
 // Include
 #include <iostream>
-#include <SDL.h>
+#include <SDL/SDL.h>
 #include <vector>
 
 

+ 1 - 1
src/Game.h

@@ -7,7 +7,7 @@
 #include <ctime>
 
 // SDL
-#include <SDL.h>
+#include <SDL/SDL.h>
 #undef main
 
 #include <SDL/SDL_gfxPrimitives.h>

+ 1 - 1
src/HitManager.h

@@ -8,7 +8,7 @@
 #include <vector>
 
 // SDL
-#include <SDL.h>
+#include <SDL/SDL.h>
 #undef main
 
 #include <SDL/SDL_gfxPrimitives.h>

+ 1 - 1
src/Shot.h

@@ -5,7 +5,7 @@
 #include <cmath>
 
 // SDL
-#include <SDL.h>
+#include <SDL/SDL.h>
 #undef main
 
 #include <SDL/SDL_gfxPrimitives.h>