ParadoxZero / sfml-snake

snake game in C++ using sfml library.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

test the repository in a linux environment

ParadoxZero opened this issue Β· comments

So far the only thing i know is that this builds successfully in linux. Need someone to test it and see if it works in it.

can you try and build this in linux ?? @prankulsingh

i will give it a try πŸ˜„

Thanks @gautamkrishnar that would be really helpful

Had some issues with the build file..
screenshot from 2016-12-15 20-13-41

  1. While building it is having the following errors:
g++-4.8 -std=c++11 -c src/main.cpp -o build/main.o
make: g++-4.8: Command not found
Makefile:17: recipe for target 'build/main.o' failed
make: *** [build/main.o] Error 127
  1. After correcting the make file with g++ command, it is showing another error:
g++ -std=c++11 -c src/main.cpp -o build/main.o
Assembler messages:
Fatal error: can't create build/main.o: No such file or directory
Makefile:17: recipe for target 'build/main.o' failed
make: *** [build/main.o] Error 1
  1. Cant execute the app:
bash: ./game.o: cannot execute binary file: Exec format error
  • So we need to create the build folder and add .gitkeep to it.
mkdir build
echo > build/,gitkeep
  • Update the commands so that the build fails when the required version of g++ is not found.
    @ParadoxZero

Ya, I had forgotten about the g++ thing, its due to travis CI.
Anyways, did you copy the dlls ? any idea what's causing it?

i had installed the sfml via the apt-get command.
I have no idea why this error!
I will try compiling the files manually...

Well the target of the build is in same directory as the makefile, you should see a file called game

Then you will need the following dlls in the same folder as executable (in windows that's how it is, linux supports dynamic link right?)

  • sfml-graphics-d-2.dll
  • sfml-window-d-2.dll
  • sfml-system-d-2.dll

wait, I think you don't need the dlls. You sure you executed the correct thing? can't see it in your screenshot

$make
g++ -std=c++11 -c src/main.cpp -o build/main.o
g++ -std=c++11 -c src/game.cpp -o build/game.o
g++ -std=c++11 -c src/food.cpp -o build/food.o
g++ -std=c++11 -c src/snake.cpp -o build/snake.o
g++ -std=c++11 -g  -o game build/main.o build/game.o build/food.o build/snake.o -lsfml-graphics -lsfml-window -lsfml-system

Now I have the build directory with the following files:

$ls build/
food.o  game.o  main.o  snake.o

Now i am checking out the docs on: http://www.sfml-dev.org/tutorials/2.0/start-linux.php

the executable is not in the build directory.
There should be a game in root directory of the project. That's the file to execute.

Executing... But it is just automatically crashing without showing any errors!
screenshot from 2016-12-15 20-50-02
@ParadoxZero

That's some progress. Does it crash immediately?

yes i cant even blink my eye πŸ˜„

That's weird, even though the frame was rendered.
Try this,

  • Go to game.cpp
  • In function gameLopp() remove the exit(0)

@ParadoxZero man! the game is working fine... I think you must add a wait before the game is started...
or something like press any key to start the game...

I tried controlling the snake and it worked fine... The game is exiting because it is reaching the end of game (Snake hits the wall)....
πŸ˜„ Good job...

  • Add A wait or key to start before starting the game.
  • Must display a game over message before terminating
    screenshot from 2016-12-15 21-01-52

This is just the core xD
will work on a proper Interface tommorow after the exam.
Didn't get time to build one.
Thanks for the help! πŸ‘ :)

πŸ‘ ❀️ Great job man... Keep it up, I will work on the makefile and submit a PR Soon πŸ˜„

That would be great! thanks again