Skip to content

Commit

Permalink
Merge pull request #3 from david-grs/master
Browse files Browse the repository at this point in the history
Update for new project
  • Loading branch information
croosthuizen authored Aug 12, 2018
2 parents 905df5f + f52d781 commit c7e441c
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 0 deletions.
29 changes: 29 additions & 0 deletions project01/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
cmake_minimum_required(VERSION 3.1)

project(snake)

set(CMAKE_CXX_STANDARD 14)

if (NOT DEFINED CINDER_PATH)
message(FATAL_ERROR "CINDER_PATH not set, e.g. -DCINDER_PATH=~/src/cinder")
endif()
include("${CINDER_PATH}/proj/cmake/modules/cinderMakeApp.cmake")

if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
set(cxx_compile_options "-g -Wall -Wextra")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${cxx_compile_options}")

set(SOURCES
application.h
application.cc
)

ci_make_app(
APP_NAME "snake"
SOURCES ${SOURCES}
INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}
CINDER_PATH ${CINDER_PATH}
)


72 changes: 72 additions & 0 deletions project01/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
Snake
=====
This first project consists of developing a simple 2D snake game with [libcinder](http://libcinder.org/)!

There is no particular requirement, the idea is to have fun while practicing your C++ on a real project. The only important
guideline is to keep things as simple as possible — elegance comes with simplicity, and performance too, most of the time.
Snake is a simple game, so should be your code.

You should not need anything else than what we discussed so far: classes, references, std::vector, small and isolated compilation units.

As earlier, I am waiting for your pull requests. Don't edit directly the files, create a directory with your name to avoid conflicts.

Deadline: Tuesday, 21st August



Building libcinder
------------------

1. Install the dependencies needed for libcinder — from [Ubuntu Notes on libcinder.org](https://www.libcinder.org/docs/guides/linux-notes/ubuntu.html):

```
sudo apt-get install libxcursor-dev \
libxrandr-dev \
libxinerama-dev \
libxi-dev \
libgl1-mesa-dev \
libglu1-mesa-dev \
zlib1g-dev \
libfontconfig1-dev \
libmpg123-dev \
libsndfile1 \
libsndfile1-dev \
libpulse-dev \
libasound2-dev \
libcurl4-gnutls-dev \
libgstreamer1.0-dev \
libgstreamer-plugins-bad1.0-dev \
libgstreamer-plugins-base1.0-dev \
gstreamer1.0-libav \
gstreamer1.0-alsa \
gstreamer1.0-pulseaudio \
gstreamer1.0-plugins-bad
```

NOTE: If you are using CentOS instead of Ubuntu, use `yum install` instead of `apt-get install`.

NOTE2: I found [this link](https://github.com/cinder/Cinder/wiki/Cinder-for-Linux-%7C-Fedora-23-24-on-x86_64) about Fedora 23. The article is only one year old so it could work for CentOS.


2. Build `libcinder` (here, Debug build)

```
git clone --recursive https://github.com/cinder/Cinder.git
cd Cinder
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Debug ..
make -j8
```


3. Build your project (= from the skeleton in this directory) by configuring cmake with:

```
cmake -DCMAKE_BUILD_TYPE=Debug -DCINDER_PATH=~/Cinder ..
```

where `~/Cinder` is the directory you cloned in step 2.

NOTE: if you build your application in Release, then you need to build libcinder in Release too.

29 changes: 29 additions & 0 deletions project01/application.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include "application.h"

static const cinder::ivec2 WindowSize{640, 480};

Application::Application()
{}

void Application::prepareSettings(Settings* settings)
{
settings->setWindowSize(WindowSize);
settings->setFrameRate(35.0f);
settings->setResizable(false);
settings->setFullScreen(false);
}

void Application::keyDown(ci::app::KeyEvent)
{}

void Application::setup()
{}

void Application::draw()
{}

void Application::update()
{}

CINDER_APP(Application, ci::app::RendererGl(ci::app::RendererGl::Options().msaa(16)), &Application::prepareSettings)

17 changes: 17 additions & 0 deletions project01/application.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

#include <cinder/app/App.h>
#include <cinder/app/RendererGl.h>

class Application : public ci::app::App
{
public:
Application();

void keyDown(ci::app::KeyEvent) override;
void setup() override;
void draw() override;
void update() override;

static void prepareSettings(Settings*);
};

0 comments on commit c7e441c

Please sign in to comment.