Browse Source

Made it more a game (ie interactive)

master
Joshua Moerman 12 years ago
parent
commit
250a3be500
  1. 136
      GLGameTemplate/App.h
  2. 202
      GLGameTemplate/Game.h
  3. 5
      GLGameTemplate/Shaders/effectShader.fsh
  4. 4
      GLGameTemplate/ViewController.h
  5. 19
      GLGameTemplate/ViewController.mm
  6. 35
      GLGameTemplate/myGL.h
  7. 111
      GLGameTemplate/statics.h
  8. 8
      SkyRoads.xcodeproj/project.pbxproj

136
GLGameTemplate/App.h

@ -18,37 +18,49 @@
#include "interpolator.h" #include "interpolator.h"
#include "statics.h" #include "statics.h"
#include "myGL.h"
using namespace gl; // I know this is bad
#include "Game.h"
#define kWindowWidth 1024 #define kWindowWidth 1024
#define kWindowHeight 768 #define kWindowHeight 768
#define kFBOWidth 128 #define kFBOWidth 128
#define kFBOHeight 128 #define kFBOHeight 128
constexpr static const char* attributes[] = {
"position",
"normal",
"color",
"tex_coord0"
};
struct App { struct App {
constexpr static int preferred_frames_per_second(){ return 60; } constexpr static int preferred_frames_per_second(){ return 60; }
constexpr static bool multisample(){ return false; } constexpr static bool multisample(){ return false; }
constexpr static bool depth(){ return true; } constexpr static bool depth(){ return true; }
constexpr static std::vector<std::string> get_attributes(){ template <size_t N>
std::vector<std::string> v; static std::vector<std::string> from_strarray(const char* const (& strs)[N]) {
v.push_back("position"); std::vector<std::string> v(N);
v.push_back("normal"); for(auto i = 0; i < N; ++i){
v.push_back("color"); v.push_back(strs[i]);
v.push_back("tex_coord0"); }
return v; return v;
} }
constexpr static std::string getPath(std::string name, std::string kind){ static std::string getPath(std::string name, std::string kind) {
return [[[NSBundle mainBundle] pathForResource:[NSString stringWithUTF8String:name.c_str()] ofType:[NSString stringWithUTF8String:kind.c_str()]] UTF8String]; return [[[NSBundle mainBundle] pathForResource:[NSString stringWithUTF8String:name.c_str()] ofType:[NSString stringWithUTF8String:kind.c_str()]] UTF8String];
} }
constexpr static std::array<GLfloat, 16> from_carray(GLfloat const (& v)[16]){ static std::array<GLfloat, 16> from_carray(GLfloat const (& v)[16]) {
std::array<GLfloat, 16> a; std::array<GLfloat, 16> a;
for(int i = 0; i < 16; ++i) a[i] = v[i]; for(int i = 0; i < 16; ++i) a[i] = v[i];
return a; return a;
} }
constexpr static std::array<GLfloat, 16> transpose(std::array<GLfloat, 16> const & v){ static std::array<GLfloat, 16> transpose(std::array<GLfloat, 16> const & v) {
std::array<GLfloat, 16> a; std::array<GLfloat, 16> a;
for(int i = 0; i < 4; ++i) for(int i = 0; i < 4; ++i)
for(int j = 0; j < 4; ++j) for(int j = 0; j < 4; ++j)
@ -56,9 +68,6 @@ struct App {
return a; return a;
} }
typedef std::array<GLfloat, 7> Vertex;
typedef std::array<Vertex, 8> Quad; //degenerate
int counter; int counter;
float time; float time;
unsigned int width, height; unsigned int width, height;
@ -73,7 +82,7 @@ struct App {
J::interpolator<std::array<GLfloat, 16>> color_transformation; J::interpolator<std::array<GLfloat, 16>> color_transformation;
std::vector<Quad> quads; Game game;
App(float w, float h) App(float w, float h)
: counter(0) : counter(0)
@ -82,14 +91,14 @@ struct App {
, height(h) , height(h)
, aspect(w/h) , aspect(w/h)
, color_scheme(0) , color_scheme(0)
, noise_shader(getPath("teaShader", "vsh"), getPath("teaShader", "fsh"), get_attributes()) , noise_shader(getPath("teaShader", "vsh"), getPath("teaShader", "fsh"), from_strarray(attributes))
, texture_shader(getPath("textureShader", "vsh"), getPath("textureShader", "fsh"), get_attributes()) , texture_shader(getPath("textureShader", "vsh"), getPath("textureShader", "fsh"), from_strarray(attributes))
, effect_shader(getPath("effectShader", "vsh"), getPath("effectShader", "fsh"), get_attributes()) , effect_shader(getPath("effectShader", "vsh"), getPath("effectShader", "fsh"), from_strarray(attributes))
, fbo1(kFBOWidth, kFBOHeight) , fbo1(kFBOWidth, kFBOHeight)
, fbo2(kFBOWidth, kFBOHeight) , fbo2(kFBOWidth, kFBOHeight)
, color_transformation(transpose(from_carray(color_transformations[0])), 1.0) , color_transformation(transpose(from_carray(color_transformations[0])), 1.0)
, game()
{ {
make_quads();
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
} }
@ -103,85 +112,15 @@ struct App {
void change_color(){ void change_color(){
++color_scheme %= colors; ++color_scheme %= colors;
color_transformation.set_value(transpose(from_carray(color_transformations[color_scheme]))); color_transformation.set_value(transpose(from_carray(color_transformations[color_scheme])));
}
void make_quads(){
quads.reserve(number_of_quads);
for(int yy = 0; yy < level_height; ++yy){
for(int xx = 0; xx < level_width; ++xx){
if(level[xx + level_width*yy] == 0) continue;
const double size = 1.0;
double x = xx - (int)level_width/2;
double z = -5.0 -level_height + yy;
double y = -1.0;
Quad q;
// deg.
q[0][0] = x - size*0.5;
q[0][1] = y;
q[0][2] = z - size*0.5;
q[1][0] = x - size*0.5;
q[1][1] = y;
q[1][2] = z - size*0.5;
// real quad
q[2][0] = x - size*0.5;
q[2][1] = y;
q[2][2] = z - size*0.5;
q[3][0] = x - size*0.5;
q[3][1] = y;
q[3][2] = z + size*0.5;
q[4][0] = x + size*0.5;
q[4][1] = y;
q[4][2] = z - size*0.5;
q[5][0] = x + size*0.5;
q[5][1] = y;
q[5][2] = z + size*0.5;
// deg.
q[6][0] = x + size*0.5;
q[6][1] = y;
q[6][2] = z + size*0.5;
q[7][0] = x + size*0.5;
q[7][1] = y;
q[7][2] = z + size*0.5;
//double r = rand() / (double) RAND_MAX;
//double g = rand() / (double) RAND_MAX;
//double b = rand() / (double) RAND_MAX;
for(auto& v : q){
v[3] = (x + 2.0) / 5.0;
v[4] = 0.5;
v[5] = (yy < level_height && yy > level_height - 7)? 1.0 : 0.0;
v[6] = 1.0;
}
quads.push_back(q); // TEMPORARY:
} game.position.y = -1.0;
} game.speed.y = 0.0;
} }
void update(float dt) { void update(float dt) {
time += dt; time += dt;
for(auto& q : quads){ game.update(dt);
for(auto& v : q){
v[2] += dt * 7.0;
}
if(q[0][2] > 10.0) {
for(auto& v : q){
v[2] -= level_height;
}
}
}
color_transformation.interpolate(dt); color_transformation.interpolate(dt);
@ -211,7 +150,7 @@ struct App {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
effect_shader.begin(); effect_shader.begin();
effect_shader.set_uniform("time", counter * counter * 0.00001f); effect_shader.set_uniform("time", time);
texture(effect_shader, read_fbo); texture(effect_shader, read_fbo);
} }
@ -220,20 +159,13 @@ struct App {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
noise_shader.begin(); noise_shader.begin();
noise_shader.set_uniform("time", time);
GLKMatrix4 p1 = GLKMatrix4MakePerspective(GLKMathDegreesToRadians(80.0f), aspect, 0.01f, 20.0f); GLKMatrix4 p1 = GLKMatrix4MakePerspective(GLKMathDegreesToRadians(80.0f), aspect, 0.01f, 20.0f);
GLKMatrix4 p2 = GLKMatrix4MakeLookAt(0.0, 0.0, 9.0, 0.0, -2.0, 0.0, 0.0, 1.0, 0.0); GLKMatrix4 p2 = GLKMatrix4MakeLookAt(0.0, 0.0, game.position.z + 2.0, 0.0, -2.0, game.position.z - 7.0, 0.0, 1.0, 0.0);
GLKMatrix4 projectionMatrix = GLKMatrix4Multiply(p1, p2); GLKMatrix4 projectionMatrix = GLKMatrix4Multiply(p1, p2);
GLKMatrix4 modelViewMatrix = GLKMatrix4Identity;
GLKMatrix4 modelViewProjectionMatrix = GLKMatrix4Multiply(projectionMatrix, modelViewMatrix);
GLKMatrix3 normalMatrix = GLKMatrix3InvertAndTranspose(GLKMatrix4GetMatrix3(modelViewMatrix), NULL);
noise_shader.set_uniform("modelViewProjectionMatrix", modelViewProjectionMatrix.m, 0);
noise_shader.set_uniform("normalMatrix", normalMatrix.m, 0);
noise_shader.set_uniform("time", time); game.draw(projectionMatrix, noise_shader);
noise_shader.set_attribute("position", 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), &quads[0][0][0]);
noise_shader.set_attribute("color", 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), &quads[0][0][3]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, quads.size()*8);
} }
void texture(J::shader const & tex_shader, J::fbo const & read_fbo) { void texture(J::shader const & tex_shader, J::fbo const & read_fbo) {

202
GLGameTemplate/Game.h

@ -0,0 +1,202 @@
//
// Game.h
// SkyRoads
//
// Created by Joshua Moerman on 12/22/12.
// Copyright (c) 2012 Vadovas. All rights reserved.
//
#ifndef SkyRoads_Game_h
#define SkyRoads_Game_h
#import <GLKit/GLKit.h>
#include "statics.h"
#include "myGL.h"
static const float accel = 4.0;
static const float max_speed = 9.0;
struct Game{
std::vector<Quad> quads;
std::vector<Vertex> spaceship;
struct Position {
float x, y, z;
} position;
struct Speed {
float x, y, z;
} speed;
struct Box {
Position min, max;
} boundingbox;
Game()
: position({0.0, -1.0, 0.0})
, speed({0.0, 0.0, 0.0})
, boundingbox({-0.2, 0.0, -0.3, 0.2, 0.0, 0.3})
{
make_spaceship();
make_quads();
}
void make_spaceship(){
spaceship.resize(5);
spaceship[0] = {-1.0, 0.0, 2.0, 0.5, 0.0, 0.0, 0.0};
spaceship[1] = { 1.0, 0.0, 2.0, 0.5, 0.0, 0.0, 0.0};
spaceship[2] = { 0.0, 1.0, 1.5, 1.0, 0.2, 0.0, 0.0};
spaceship[3] = { 0.0, 0.0, -2.0, 1.0, 0.0, 1.5, 0.0};
spaceship[4] = {-1.0, 0.0, 2.0, 0.5, 0.0, 0.0, 0.0};
float scale = 0.7;
for(auto& v : spaceship){
v = gl::scale(v, scale*0.3, scale*0.2, scale*0.4);
}
}
void make_quads(){
quads.reserve(number_of_quads);
for(int zz = 0; zz < level_length; ++zz){
for(int xx = 0; xx < level_width; ++xx){
if(level[xx + level_width*zz] == 0) continue;
const double size = 1.0; // DONT CHANGE
double x = xx - (int)level_width/2;
double z = zz;
double y = -1.0;
Quad q;
// deg.
q[0][0] = x - size*0.5;
q[0][1] = y;
q[0][2] = z - size*0.5;
q[1][0] = x - size*0.5;
q[1][1] = y;
q[1][2] = z - size*0.5;
// real quad
q[2][0] = x - size*0.5;
q[2][1] = y;
q[2][2] = z - size*0.5;
q[3][0] = x - size*0.5;
q[3][1] = y;
q[3][2] = z + size*0.5;
q[4][0] = x + size*0.5;
q[4][1] = y;
q[4][2] = z - size*0.5;
q[5][0] = x + size*0.5;
q[5][1] = y;
q[5][2] = z + size*0.5;
// deg.
q[6][0] = x + size*0.5;
q[6][1] = y;
q[6][2] = z + size*0.5;
q[7][0] = x + size*0.5;
q[7][1] = y;
q[7][2] = z + size*0.5;
//double r = rand() / (double) RAND_MAX;
//double g = rand() / (double) RAND_MAX;
//double b = rand() / (double) RAND_MAX;
for(auto& v : q){
v[3] = 0.2*std::abs(x);
v[4] = 1.0 - 0.2*std::abs(x);
v[5] = (level[xx + level_width*zz] > 1)? 1.0 : 0.0;
v[6] = 1.0;
}
quads.push_back(q);
}
}
}
void update(float dt){
speed.z -= dt * accel;
if(speed.z < -max_speed) speed.z = -max_speed;
position.z += dt * speed.z;
for(auto& q : quads){
if(q[0][2] > position.z + 4.0) {
for(auto& v : q){
v[2] -= level_length;
}
}
}
if(check() && position.y > -1.1){
// alive
position.y = -1.0;
speed.y = 0.0;
} else {
speed.y -= dt * 4.0;
position.y += dt * speed.y;
}
}
int clamp(int x, int min, int max){
return (x < min) ? min :
((x > max) ? max : x);
}
int position_to_index(Position p){
int amp = level_width/2;
int x = clamp(std::round(p.x), -amp, amp) + amp;
int z = int(std::round(p.z)) % int(level_length);
if(z < 0) z += level_length;
return x + level_width*z;
}
bool check(){
for(auto x : {boundingbox.min.x, boundingbox.max.y}){
for(auto z : {boundingbox.min.z, boundingbox.max.z}){
int index = position_to_index({position.x + x, 0.0, position.z + z});
if(level[index] > 0) return true;
}
}
return false;
}
void draw(GLKMatrix4 projectionMatrix, J::shader& shader){
draw_spaceship(projectionMatrix, shader);
draw_quads(projectionMatrix, shader);
}
void draw_spaceship(GLKMatrix4 projectionMatrix, J::shader& shader){
GLKMatrix4 modelViewMatrix = GLKMatrix4Identity;
GLKMatrix4 modelViewProjectionMatrix = GLKMatrix4Multiply(projectionMatrix, modelViewMatrix);
GLKMatrix3 normalMatrix = GLKMatrix3InvertAndTranspose(GLKMatrix4GetMatrix3(modelViewMatrix), NULL);
shader.set_uniform("modelViewProjectionMatrix", modelViewProjectionMatrix.m, 0);
shader.set_uniform("normalMatrix", normalMatrix.m, 0);
shader.set_attribute("position", 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), &quads[0][0][0]);
shader.set_attribute("color", 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), &quads[0][0][3]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, quads.size()*8);
}
void draw_quads(GLKMatrix4 projectionMatrix, J::shader& shader){
GLKMatrix4 modelViewMatrix = GLKMatrix4MakeTranslation(position.x, position.y, position.z);
GLKMatrix4 modelViewProjectionMatrix = GLKMatrix4Multiply(projectionMatrix, modelViewMatrix);
GLKMatrix3 normalMatrix = GLKMatrix3InvertAndTranspose(GLKMatrix4GetMatrix3(modelViewMatrix), NULL);
shader.set_uniform("modelViewProjectionMatrix", modelViewProjectionMatrix.m, 0);
shader.set_uniform("normalMatrix", normalMatrix.m, 0);
shader.set_attribute("position", 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), &spaceship[0][0]);
shader.set_attribute("color", 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), &spaceship[0][3]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, spaceship.size());
}
};
#endif

5
GLGameTemplate/Shaders/effectShader.fsh

@ -16,8 +16,9 @@ void main( void ) {
if(length(orig.xyz) <= 0.01){ if(length(orig.xyz) <= 0.01){
gl_FragColor.b = positionVarying.y*0.5+0.5; gl_FragColor.b = positionVarying.y*0.5+0.5;
gl_FragColor.g = 0.5 * gl_FragColor.b * (cos(positionVarying.x*3.0) + 1.0); gl_FragColor.g = 0.5 * gl_FragColor.b * (0.1 * cos(positionVarying.x*3.0) + 1.0);
gl_FragColor.r = sin(-positionVarying.y*positionVarying.x*(10.0 + sin(time*0.1337)) + time*0.2337); gl_FragColor.r = 0.2 * abs(sin(-positionVarying.y*positionVarying.x*(10.0 + sin(time*0.51337)) + time*time*0.2337))
+ 0.2 * abs(sin(-(positionVarying.y-0.7)*positionVarying.x*(8.0 + sin(time*0.41337)) - time*time*0.1337 + 1.0));;
} else { } else {
gl_FragColor = exposure*(mix*orig + (1.0 - mix)*normalize(orig)); gl_FragColor = exposure*(mix*orig + (1.0 - mix)*normalize(orig));
} }

4
GLGameTemplate/ViewController.h

@ -9,6 +9,8 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <GLKit/GLKit.h> #import <GLKit/GLKit.h>
@interface ViewController : GLKViewController @interface ViewController : GLKViewController{
UIButton *left, *right;
}
@end @end

19
GLGameTemplate/ViewController.mm

@ -24,6 +24,8 @@
@synthesize context = _context; @synthesize context = _context;
- (void)dealloc { - (void)dealloc {
[left release];
[right release];
[_context release]; [_context release];
[super dealloc]; [super dealloc];
} }
@ -44,6 +46,15 @@
[self setupGL]; [self setupGL];
left = [[UIButton buttonWithType:UIButtonTypeCustom] retain];
left.frame = CGRectMake(0, 48, view.frame.size.width / 2, view.frame.size.height - 48);
left.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
[view addSubview: left];
right = [[UIButton buttonWithType:UIButtonTypeCustom] retain];
right.frame = CGRectMake(view.frame.size.width / 2, 48, view.frame.size.width / 2, view.frame.size.height - 48);
right.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
[view addSubview: right];
UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom]; UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0, 0, view.frame.size.width, 48); button.frame = CGRectMake(0, 0, view.frame.size.width, 48);
button.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; button.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
@ -107,6 +118,14 @@
} }
app->update(self.timeSinceLastUpdate); app->update(self.timeSinceLastUpdate);
if(left.highlighted)
app->game.position.x -= 0.1;
if(right.highlighted)
app->game.position.x += 0.1;
if(app->game.position.x > 2.0) app->game.position.x = 2.0;
if(app->game.position.x < -2.0) app->game.position.x = -2.0;
} catch (std::exception & e) { } catch (std::exception & e) {
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
throw e; throw e;

35
GLGameTemplate/myGL.h

@ -0,0 +1,35 @@
//
// myGL.h
// SkyRoads
//
// Created by Joshua Moerman on 12/22/12.
// Copyright (c) 2012 Vadovas. All rights reserved.
//
#ifndef SkyRoads_myGL_h
#define SkyRoads_myGL_h
#import <GLKit/GLKit.h>
#include <array>
namespace gl {
typedef std::array<GLfloat, 7> Vertex;
typedef std::array<Vertex, 8> Quad; //degenerate
Vertex translate(Vertex v, GLfloat x, GLfloat y, GLfloat z){
v[0] += x;
v[1] += y;
v[2] += z;
return v;
}
Vertex scale(Vertex v, GLfloat x, GLfloat y, GLfloat z){
v[0] *= x;
v[1] *= y;
v[2] *= z;
return v;
}
}
#endif

111
GLGameTemplate/statics.h

@ -71,51 +71,120 @@ static const GLfloat tex_quad[] = {
}; };
static const int level[] = { static const int level[] = {
1,0,0,0,0,
0,1,0,0,0,
0,0,1,0,0,
0,0,0,1,0,
0,0,0,0,1,
1,1,1,1,1, 1,1,1,1,1,
1,0,0,0,0, 0,1,1,1,1,
1,1,0,0,0, 0,0,1,1,1,
0,1,1,0,0,
0,0,1,1,0,
0,0,0,1,1, 0,0,0,1,1,
0,0,0,0,1,
0,0,0,1,1, 0,0,0,1,1,
0,0,1,1,0, 0,0,1,1,0,
0,1,1,0,0, 0,1,1,0,0,
1,1,0,0,2,
1,0,0,2,2,
0,0,0,2,2,
0,0,0,2,2,
0,0,2,2,0,
0,2,2,2,0,
0,2,2,0,0,
2,2,0,0,0,
2,2,0,0,0,
2,2,0,0,1,
2,0,0,1,1,
0,0,1,1,1,
0,1,1,1,0,
1,1,1,0,0,
1,1,0,0,0, 1,1,0,0,0,
1,0,0,0,0, 1,0,0,0,0,
1,1,1,1,1, 1,1,0,0,0,
0,1,1,0,0,
0,0,1,1,0,
0,0,0,1,1,
0,0,0,0,1,
0,0,0,1,0,
0,0,1,0,1,
0,1,0,1,0, 0,1,0,1,0,
1,0,1,0,1, 1,0,1,0,1,
0,1,0,1,0, 0,1,0,1,0,
1,0,1,0,1, 1,0,1,0,1,
0,1,0,1,0, 0,1,0,1,0,
1,1,1,1,1, 1,0,1,0,0,
0,1,0,0,0,
1,0,0,0,0, 1,0,0,0,0,
1,0,0,0,0, 1,0,0,0,0,
1,0,0,0,0, 1,0,0,0,0,
1,0,0,0,0, 1,0,0,0,0,
1,1,0,0,0, 1,1,0,0,0,
1,1,1,0,0, 1,1,1,0,0,
1,1,1,1,0, 0,1,1,1,0,
1,1,1,1,1,
0,1,1,1,1,
0,0,1,1,1, 0,0,1,1,1,
0,0,0,1,1, 0,0,0,1,1,
0,0,0,0,1, 2,2,0,0,1,
0,0,0,0,1, 2,2,0,0,1,
0,0,0,0,1, 0,0,0,1,1,
0,0,0,0,1, 0,0,1,1,1,
0,1,1,1,0,
1,1,1,0,0,
1,1,0,0,0,
1,0,0,2,2,
1,0,0,2,2,
1,1,0,0,0,
1,1,1,0,0,
1,1,1,1,0,
1,1,1,1,1,
2,2,2,2,2,
0,2,2,2,2,
0,0,2,2,2,
0,0,0,2,2,
0,0,0,0,2,
1,1,1,1,1,
1,1,1,1,0,
1,1,1,0,0,
1,1,0,0,0,
1,0,0,0,0,
2,2,2,2,2,
0,2,2,2,2,
0,0,2,2,2,
0,0,0,2,2,
0,0,0,0,2,
1,1,1,1,1,
1,1,1,1,1,
0,1,1,1,0,
0,0,1,0,0,
0,0,1,0,0,
0,0,1,0,0,
0,0,2,0,0,
0,0,1,0,0,
0,0,2,0,0,
0,1,1,1,0,
0,2,2,2,0,
0,1,1,1,0,
0,2,2,2,0,
1,1,1,1,1,
2,2,2,2,2,
1,1,1,1,1,
2,2,1,2,2,
2,2,1,2,2,
2,1,1,1,2,
2,1,1,1,2,
1,1,1,1,1, 1,1,1,1,1,
1,1,0,2,2,
1,1,0,2,2,
1,1,0,2,2,
1,1,0,2,2,
2,2,0,1,1,
2,2,0,1,1,
2,2,0,1,1,
2,2,0,1,1,
2,2,2,2,2,
2,2,2,2,2,
2,2,2,2,2,
2,2,2,2,2,
2,2,1,2,2,
2,1,1,1,2,
}; };
static const size_t level_width = 5; static const size_t level_width = 5;
static const size_t level_height = sizeof(level) / sizeof(level[0]) / level_width; static const size_t level_length = sizeof(level) / sizeof(level[0]) / level_width;
static const size_t number_of_quads = std::count(level, level+level_height*level_width, 1); static const size_t number_of_quads = std::count(level, level+level_length*level_width, 1);
#endif #endif

8
SkyRoads.xcodeproj/project.pbxproj

@ -44,6 +44,7 @@
/* End PBXContainerItemProxy section */ /* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
42458D5C168605DA0089C2A3 /* Game.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Game.h; sourceTree = "<group>"; };
4280A9171553DD4C00664DC2 /* SkyRoads.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SkyRoads.app; sourceTree = BUILT_PRODUCTS_DIR; }; 4280A9171553DD4C00664DC2 /* SkyRoads.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SkyRoads.app; sourceTree = BUILT_PRODUCTS_DIR; };
4280A91B1553DD4C00664DC2 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 4280A91B1553DD4C00664DC2 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
4280A91D1553DD4C00664DC2 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 4280A91D1553DD4C00664DC2 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
@ -69,6 +70,7 @@
42E092C61553FF6B002EA900 /* textureShader.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = textureShader.fsh; sourceTree = "<group>"; }; 42E092C61553FF6B002EA900 /* textureShader.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = textureShader.fsh; sourceTree = "<group>"; };
42E092C71553FF6B002EA900 /* textureShader.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = textureShader.vsh; sourceTree = "<group>"; }; 42E092C71553FF6B002EA900 /* textureShader.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = textureShader.vsh; sourceTree = "<group>"; };
42E092CE15540515002EA900 /* statics.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = statics.h; sourceTree = "<group>"; }; 42E092CE15540515002EA900 /* statics.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = statics.h; sourceTree = "<group>"; };
42FF1C4C1685F15500E1541C /* myGL.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = myGL.h; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
@ -123,6 +125,8 @@
children = ( children = (
42E092CE15540515002EA900 /* statics.h */, 42E092CE15540515002EA900 /* statics.h */,
42E092971553F367002EA900 /* App.h */, 42E092971553F367002EA900 /* App.h */,
42458D5C168605DA0089C2A3 /* Game.h */,
42FF1C4C1685F15500E1541C /* myGL.h */,
42E092A81553FDDB002EA900 /* Shaders */, 42E092A81553FDDB002EA900 /* Shaders */,
42E092981553F7E6002EA900 /* GLViews */, 42E092981553F7E6002EA900 /* GLViews */,
4280A9261553DD4C00664DC2 /* Supporting Files */, 4280A9261553DD4C00664DC2 /* Supporting Files */,
@ -318,6 +322,8 @@
buildSettings = { buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_BIT)"; ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99; GCC_C_LANGUAGE_STANDARD = gnu99;
@ -343,6 +349,8 @@
buildSettings = { buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_BIT)"; ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES; COPY_PHASE_STRIP = YES;
GCC_C_LANGUAGE_STANDARD = gnu99; GCC_C_LANGUAGE_STANDARD = gnu99;