diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2015-02-21 15:22:21 -0500 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2015-02-21 15:22:21 -0500 |
commit | 59860415a2782694f630f7803ae4bcf445b3f5f1 (patch) | |
tree | 6c5dade6c2915cc68d69d536b465a5c6d7bd53fc | |
parent | e3e5a247c58c6e0b45d81ab61314bd8d1bd530ac (diff) | |
download | therapy-59860415a2782694f630f7803ae4bcf445b3f5f1.tar.gz therapy-59860415a2782694f630f7803ae4bcf445b3f5f1.tar.bz2 therapy-59860415a2782694f630f7803ae4bcf445b3f5f1.zip |
Player can short jump
-rw-r--r-- | maps/embarass.txt | 28 | ||||
-rw-r--r-- | res/tiles2.bmp | bin | 4664 -> 4664 bytes | |||
-rw-r--r-- | shaders/final.fragment | 16 | ||||
-rw-r--r-- | shaders/final.vertex | 8 | ||||
-rw-r--r-- | src/map.h | 1 | ||||
-rw-r--r-- | src/mapview.cpp | 26 | ||||
-rw-r--r-- | src/mapview.h | 1 |
7 files changed, 40 insertions, 40 deletions
diff --git a/maps/embarass.txt b/maps/embarass.txt index 6cf029e..8ef69d3 100644 --- a/maps/embarass.txt +++ b/maps/embarass.txt | |||
@@ -1,25 +1,25 @@ | |||
1 | -1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,9,8,10,8,11,8,10,10,8,11,8,9,10,12,0, | 1 | -1,0,0,0,0,0,0,0,0,0,19,0,0,0,0,0,20,0,0,0,0,0,0,0,18,9,8,10,8,11,8,10,10,8,11,8,9,10,21,0, |
2 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,8,8,8,0,0,0,0,0,0,0,0,0,0,0,0,0,8,12, | 2 | 0,0,0,0,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,18,8,8,17,0,0,0,0,0,0,0,0,0,0,0,0,0,22,21, |
3 | -1,0,0,0,0,0,0,0,0,0,0,0,0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,0,0,0,0,0,0,0,0,0, | ||
22 | 0,0,0,0,4,3,1,2,1,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,1,3,2,1,0,0,0,0,0,0, | ||
23 | 1,2,3,1,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,2,2,4,3,1, | ||
24 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | 20 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
21 | 0,0,0,0,0,0,0,0,0,0,1,4,2,1,3,3,1,4,2,2,1,1,1,3,1,2,4,1,3,2,0,0,0,0,0,0,0,0,0,0, | ||
22 | 0,0,0,0,4,3,1,2,1,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,0,2,1,3,2,1,0,0,0,0,0,0, | ||
23 | 1,2,3,1,4,0,0,0,0,0,20,0,0,0,0,0,0,19,0,0,0,0,0,0,20,0,0,0,0,0,0,0,0,1,1,2,2,4,3,1, | ||
24 | 0,0,0,0,0,0,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,20,0,0,0,0,0,0,0,0,0,0, | ||
25 | Everything Is Embarrassing \ No newline at end of file | 25 | Everything Is Embarrassing \ No newline at end of file |
diff --git a/res/tiles2.bmp b/res/tiles2.bmp index 851f892..1166976 100644 --- a/res/tiles2.bmp +++ b/res/tiles2.bmp | |||
Binary files differ | |||
diff --git a/shaders/final.fragment b/shaders/final.fragment index 4a51ad3..f9d8995 100644 --- a/shaders/final.fragment +++ b/shaders/final.fragment | |||
@@ -4,7 +4,6 @@ in vec2 UV; | |||
4 | in vec3 normIn; | 4 | in vec3 normIn; |
5 | in vec3 camDirIn; | 5 | in vec3 camDirIn; |
6 | in vec3 lightDirIn; | 6 | in vec3 lightDirIn; |
7 | //in vec3 vertPos; | ||
8 | 7 | ||
9 | out vec3 color; | 8 | out vec3 color; |
10 | 9 | ||
@@ -53,7 +52,6 @@ void main() | |||
53 | vec3 norm = normalize(normIn); | 52 | vec3 norm = normalize(normIn); |
54 | vec3 camDir = normalize(camDirIn); | 53 | vec3 camDir = normalize(camDirIn); |
55 | vec3 lightDir = normalize(lightDirIn); | 54 | vec3 lightDir = normalize(lightDirIn); |
56 | //vec3 refl = reflect(camDir, normIn); | ||
57 | 55 | ||
58 | float diffuse = clamp(dot(norm, lightDir), 0.0f, 1.0f); | 56 | float diffuse = clamp(dot(norm, lightDir), 0.0f, 1.0f); |
59 | vec4 colordiff = vec4(0.175, 0.15, 0.2, 1) * diffuse * Tuning_Diff_Brightness; | 57 | vec4 colordiff = vec4(0.175, 0.15, 0.2, 1) * diffuse * Tuning_Diff_Brightness; |
@@ -65,19 +63,7 @@ void main() | |||
65 | 63 | ||
66 | float fres = 1.0f - dot(camDir, norm); | 64 | float fres = 1.0f - dot(camDir, norm); |
67 | fres = (fres*fres) * Tuning_Fres_Brightness; | 65 | fres = (fres*fres) * Tuning_Fres_Brightness; |
68 | vec4 colorfres = vec4(0.45, 0.4, 0.5, 1) * fres;/* | 66 | vec4 colorfres = vec4(0.45, 0.4, 0.5, 1) * fres; |
69 | |||
70 | float lambertian = max(dot(camDirNorm,norm),0.0); | ||
71 | vec4 colorspec = vec4(0.0); | ||
72 | vec4 colorfres = vec4(0.0); | ||
73 | vec4 colordiff = vec4(0.175,0.15,0.2,1) * lambertian * Tuning_Diff_Brightness; | ||
74 | if (lambertian > 0.0) | ||
75 | { | ||
76 | vec3 viewDir = normalize(-vertPos); | ||
77 | vec3 halfDir = normalize(camDirNorm + viewDir); | ||
78 | float specAngle = max(dot(halfDir, normnorm), 0.0); | ||
79 | colorspec = vec4(0.25,0.25,0.25,1) * pow(specAngle, Tuning_Spec_Power) * Tuning_Spec_Brightness; | ||
80 | }*/ | ||
81 | 67 | ||
82 | vec4 emissive = sampleCRT(UV); | 68 | vec4 emissive = sampleCRT(UV); |
83 | 69 | ||
diff --git a/shaders/final.vertex b/shaders/final.vertex index 4c5b1d5..ed6079f 100644 --- a/shaders/final.vertex +++ b/shaders/final.vertex | |||
@@ -8,12 +8,11 @@ out vec2 UV; | |||
8 | out vec3 normIn; | 8 | out vec3 normIn; |
9 | out vec3 camDirIn; | 9 | out vec3 camDirIn; |
10 | out vec3 lightDirIn; | 10 | out vec3 lightDirIn; |
11 | //out vec3 vertPos; | ||
12 | 11 | ||
13 | uniform mat4 MVP; | 12 | uniform mat4 MVP; |
14 | uniform mat4 worldMat; | 13 | uniform mat4 worldMat; |
15 | 14 | ||
16 | const vec3 Tuning_LightPos = vec3(1, 1, -1.0); | 15 | const vec3 Tuning_LightPos = vec3(2, 1, -1); |
17 | 16 | ||
18 | void main() | 17 | void main() |
19 | { | 18 | { |
@@ -22,11 +21,8 @@ void main() | |||
22 | normIn = vertexNormal; | 21 | normIn = vertexNormal; |
23 | 22 | ||
24 | mat3 invWorldRot = transpose(mat3(worldMat[0].xyz, worldMat[1].xyz, worldMat[2].xyz)); | 23 | mat3 invWorldRot = transpose(mat3(worldMat[0].xyz, worldMat[1].xyz, worldMat[2].xyz)); |
25 | //mat3 invWorldRot = mat3(1.0f); | ||
26 | vec3 worldPos = (worldMat * vec4(vertexPosition_modelspace,1)).xyz; | 24 | vec3 worldPos = (worldMat * vec4(vertexPosition_modelspace,1)).xyz; |
25 | |||
27 | camDirIn = invWorldRot * (vec3(2,0,0) - worldPos); | 26 | camDirIn = invWorldRot * (vec3(2,0,0) - worldPos); |
28 | //camDir = worldPos; | ||
29 | lightDirIn = invWorldRot * (Tuning_LightPos - worldPos); | 27 | lightDirIn = invWorldRot * (Tuning_LightPos - worldPos); |
30 | //vec4 vertPos4 = vec4(vertexPosition_modelspace,1); | ||
31 | //vertPos = vec3(vertPos4) / vertPos4.w; | ||
32 | } | 28 | } |
diff --git a/src/map.h b/src/map.h index 2acce59..d7b4ecf 100644 --- a/src/map.h +++ b/src/map.h | |||
@@ -3,6 +3,7 @@ | |||
3 | 3 | ||
4 | class Map { | 4 | class Map { |
5 | public: | 5 | public: |
6 | Map(); | ||
6 | Map(char* filename); | 7 | Map(char* filename); |
7 | ~Map(); | 8 | ~Map(); |
8 | const int* mapdata(); | 9 | const int* mapdata(); |
diff --git a/src/mapview.cpp b/src/mapview.cpp index 78dd770..76d7f02 100644 --- a/src/mapview.cpp +++ b/src/mapview.cpp | |||
@@ -1,10 +1,16 @@ | |||
1 | #include "mapview.h" | 1 | #include "mapview.h" |
2 | 2 | ||
3 | #define JUMP_VELOCITY(h, l) (-2 * (h) / (l)) | ||
4 | #define JUMP_GRAVITY(h, l) (2 * ((h) / (l)) / (l)) | ||
5 | |||
3 | // Initialize jump physics | 6 | // Initialize jump physics |
4 | double jump_height = TILE_HEIGHT*3; | 7 | double jump_height = TILE_HEIGHT*4; |
5 | double jump_length = 0.25 * FRAMES_PER_SECOND; | 8 | double jump_length = 0.25 * FRAMES_PER_SECOND; |
6 | double jump_velocity = -2 * jump_height / jump_length; | 9 | //double jump_velocity = -2 * jump_height / jump_length; |
7 | double jump_gravity = -1 * jump_velocity / jump_length; | 10 | //double jump_gravity = -1 * jump_velocity / jump_length; |
11 | double jump_velocity = JUMP_VELOCITY(TILE_HEIGHT*4, 0.30*FRAMES_PER_SECOND); | ||
12 | double jump_gravity = JUMP_GRAVITY(TILE_HEIGHT*4, 0.30*FRAMES_PER_SECOND); | ||
13 | double jump_gravity_short = JUMP_GRAVITY(TILE_HEIGHT*3, 0.20*FRAMES_PER_SECOND); | ||
8 | 14 | ||
9 | MapView::MapView(Map* first, int x, int y) | 15 | MapView::MapView(Map* first, int x, int y) |
10 | { | 16 | { |
@@ -14,8 +20,8 @@ MapView::MapView(Map* first, int x, int y) | |||
14 | player->y = y; | 20 | player->y = y; |
15 | player->x_vel = 0; | 21 | player->x_vel = 0; |
16 | player->y_vel = 0; | 22 | player->y_vel = 0; |
23 | player->y_accel = jump_gravity_short; | ||
17 | player->x_accel = 0; | 24 | player->x_accel = 0; |
18 | player->y_accel = jump_gravity; | ||
19 | player->w = 10; | 25 | player->w = 10; |
20 | player->h = 12; | 26 | player->h = 12; |
21 | player->onGround = false; | 27 | player->onGround = false; |
@@ -123,6 +129,7 @@ void MapView::input(int key, int action) | |||
123 | { | 129 | { |
124 | player->y_vel = jump_velocity; | 130 | player->y_vel = jump_velocity; |
125 | player->onGround = false; | 131 | player->onGround = false; |
132 | holding_up = true; | ||
126 | } | 133 | } |
127 | break; | 134 | break; |
128 | case GLFW_KEY_DOWN: | 135 | case GLFW_KEY_DOWN: |
@@ -144,6 +151,9 @@ void MapView::input(int key, int action) | |||
144 | case GLFW_KEY_DOWN: | 151 | case GLFW_KEY_DOWN: |
145 | holding_down = false; | 152 | holding_down = false; |
146 | break; | 153 | break; |
154 | case GLFW_KEY_UP: | ||
155 | holding_up = false; | ||
156 | break; | ||
147 | } | 157 | } |
148 | } | 158 | } |
149 | } | 159 | } |
@@ -165,7 +175,13 @@ void MapView::tick() | |||
165 | if (player->x_vel > 16) player->x_vel = 16; | 175 | if (player->x_vel > 16) player->x_vel = 16; |
166 | int playerx_next = player->x + player->x_vel; | 176 | int playerx_next = player->x + player->x_vel; |
167 | 177 | ||
168 | player->y_vel += player->y_accel; | 178 | if (holding_up) |
179 | { | ||
180 | player->y_vel += jump_gravity; | ||
181 | } else { | ||
182 | player->y_vel += jump_gravity_short; | ||
183 | } | ||
184 | |||
169 | if (player->y_vel > 16) player->y_vel = 16; // Terminal velocity | 185 | if (player->y_vel > 16) player->y_vel = 16; // Terminal velocity |
170 | if (player->y_vel < -16) player->y_vel = -16; | 186 | if (player->y_vel < -16) player->y_vel = -16; |
171 | int playery_next = player->y + player->y_vel; | 187 | int playery_next = player->y + player->y_vel; |
diff --git a/src/mapview.h b/src/mapview.h index 06309e3..505ab25 100644 --- a/src/mapview.h +++ b/src/mapview.h | |||
@@ -54,6 +54,7 @@ class MapView : public State { | |||
54 | bool holding_left = false; | 54 | bool holding_left = false; |
55 | bool holding_right = false; | 55 | bool holding_right = false; |
56 | bool holding_down = false; | 56 | bool holding_down = false; |
57 | bool holding_up = false; | ||
57 | mob_t* player; | 58 | mob_t* player; |
58 | 59 | ||
59 | Map* curMap; | 60 | Map* curMap; |