textpsys
changeset 1:57c6f7b70126
renamed to textpsys
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Wed, 19 Aug 2015 09:17:20 +0300 |
parents | a4ffd9e6984c |
children | 4b1360a5d54d |
files | Makefile src/effect.cc src/effect.h src/main.cc src/tbomb.cc src/tbomb.h |
diffstat | 6 files changed, 133 insertions(+), 133 deletions(-) [+] |
line diff
1.1 --- a/Makefile Wed Aug 19 09:13:48 2015 +0300 1.2 +++ b/Makefile Wed Aug 19 09:17:20 2015 +0300 1.3 @@ -1,7 +1,7 @@ 1.4 src = $(wildcard src/*.cc) 1.5 obj = $(src:.cc=.o) 1.6 dep = $(obj:.o=.d) 1.7 -bin = textbomb 1.8 +bin = textpsys 1.9 1.10 1.11 CXXFLAGS = -std=c++11 -pedantic -Wall -g
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/src/effect.cc Wed Aug 19 09:17:20 2015 +0300 2.3 @@ -0,0 +1,117 @@ 2.4 +#include <stdio.h> 2.5 +#include <stdlib.h> 2.6 +#include "opengl.h" 2.7 +#include "effect.h" 2.8 +#include "psys.h" 2.9 + 2.10 +#include "hello1.h" 2.11 +#include "hello2.h" 2.12 +#include "pimg.h" 2.13 + 2.14 +static PSysParam ppmain; 2.15 +static PSysParam ppexpl, ppflame; 2.16 + 2.17 +static ParticleSystem psys; 2.18 +static Image *pimg; 2.19 +static Image *simg[2]; 2.20 + 2.21 +bool fx_init() 2.22 +{ 2.23 + ppmain.spawn_rate = 20000; 2.24 + ppmain.size = 0.06; 2.25 + ppmain.spawn_range = 0.01; 2.26 + ppmain.life = 0.4; 2.27 + ppmain.gravity = Vector3(0, 0.01, 0); 2.28 + 2.29 + ppmain.pcolor_start = Vector3(0.717, 0.494, 0.951) * 0.6; 2.30 + ppmain.pcolor_end = Vector3(0.9, 0.135, 0.005) * 0.6; 2.31 + ppmain.pcolor_mid = lerp(ppmain.pcolor_start, ppmain.pcolor_mid, 0.5); 2.32 + 2.33 + ppmain.palpha_start = 1.0; 2.34 + ppmain.palpha_mid = 0.5; 2.35 + ppmain.palpha_end = 0.0; 2.36 + 2.37 + ppmain.pscale_start = 1.0; 2.38 + ppmain.pscale_mid = 1.0; 2.39 + ppmain.pscale_end = 7.0; 2.40 + 2.41 + pimg = new Image; 2.42 + pimg->pixels = (unsigned char*)img_particle.pixel_data; 2.43 + pimg->width = img_particle.width; 2.44 + pimg->height = img_particle.height; 2.45 + 2.46 + ppmain.pimg = pimg; 2.47 + 2.48 + simg[0] = new Image; 2.49 + simg[0]->pixels = (unsigned char*)img_hello1.pixel_data; 2.50 + simg[0]->width = img_hello1.width; 2.51 + simg[0]->height = img_hello1.height; 2.52 + 2.53 + simg[1] = new Image; 2.54 + simg[1]->pixels = (unsigned char*)img_hello2.pixel_data; 2.55 + simg[1]->width = img_hello2.width; 2.56 + simg[1]->height = img_hello2.height; 2.57 + 2.58 + ppmain.spawn_map = simg[0]; 2.59 + ppmain.spawn_map_speed = 0.8; 2.60 + psys.pp = ppmain; 2.61 + 2.62 + // explosion parameters 2.63 + ppexpl = ppmain; 2.64 + ppexpl.pcolor_start = ppmain.pcolor_mid; 2.65 + ppexpl.pcolor_mid = lerp(ppexpl.pcolor_start, ppexpl.pcolor_end, 0.5); 2.66 + 2.67 + ppexpl.palpha_start = 1.0; 2.68 + ppexpl.palpha_mid = 0.5; 2.69 + ppexpl.palpha_end = 0.05; 2.70 + 2.71 + ppexpl.pscale_start = 1.0; 2.72 + ppexpl.pscale_mid = 3.0; 2.73 + ppexpl.pscale_end = 5.0; 2.74 + ppexpl.gravity = Vector3(0, -6, 0); 2.75 + 2.76 + // flame parameters 2.77 + ppflame = ppexpl; 2.78 + ppflame.pcolor_start = Vector3(1.0, 0.8, 0.2) * 0.5; 2.79 + ppflame.pcolor_mid = Vector3(1.0, 0.3, 0.2) * 0.5; 2.80 + ppflame.pcolor_end = Vector3(0.1, 0.1, 0.1); 2.81 + //ppflame.pcolor_mid = lerp(ppflame.pcolor_start, ppflame.pcolor_end, 0.6); 2.82 + 2.83 + ppflame.life = 0.5; 2.84 + ppflame.life_range = 0.25; 2.85 + ppflame.size = 0.07; 2.86 + ppflame.size_range = 0.03; 2.87 + ppflame.spawn_rate = 18000; 2.88 + ppflame.gravity = Vector3(0, 2, 0); 2.89 + 2.90 + ppflame.palpha_start *= 0.7; 2.91 + ppflame.palpha_mid *= 0.7; 2.92 + ppflame.palpha_end *= 0.7; 2.93 + 2.94 + return true; 2.95 +} 2.96 + 2.97 +void fx_cleanup() 2.98 +{ 2.99 + delete pimg; 2.100 + delete simg[0]; 2.101 + delete simg[1]; 2.102 +} 2.103 + 2.104 +void fx_draw(unsigned long msec) 2.105 +{ 2.106 + static unsigned long prev_msec; 2.107 + float dt = (msec - prev_msec) / 1000.0; 2.108 + prev_msec = msec; 2.109 + 2.110 + psys.update(dt); 2.111 + psys.draw(); 2.112 +} 2.113 + 2.114 +void fx_dbg() 2.115 +{ 2.116 + psys.explode(Vector3(0, 0, 0), 2.5, ppflame.life, 1.5); 2.117 + psys.pp = ppflame; 2.118 + //psys.explode(Vector3(0, -0.2, 0), 3.0, 1.5); 2.119 + //psys.pp = ppexpl; 2.120 +}
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/src/effect.h Wed Aug 19 09:17:20 2015 +0300 3.3 @@ -0,0 +1,10 @@ 3.4 +#ifndef TBOMB_H_ 3.5 +#define TBOMB_H_ 3.6 + 3.7 +bool fx_init(); 3.8 +void fx_cleanup(); 3.9 + 3.10 +void fx_draw(unsigned long msec); 3.11 +void fx_dbg(); 3.12 + 3.13 +#endif // TBOMB_H_
4.1 --- a/src/main.cc Wed Aug 19 09:13:48 2015 +0300 4.2 +++ b/src/main.cc Wed Aug 19 09:17:20 2015 +0300 4.3 @@ -6,7 +6,7 @@ 4.4 #else 4.5 #include <GLUT/glut.h> 4.6 #endif 4.7 -#include "tbomb.h" 4.8 +#include "effect.h" 4.9 4.10 void display(); 4.11 void idle(); 4.12 @@ -38,10 +38,10 @@ 4.13 glutReshapeFunc(reshape); 4.14 glutKeyboardFunc(keyboard); 4.15 4.16 - if(!tbomb_init()) { 4.17 + if(!fx_init()) { 4.18 return 1; 4.19 } 4.20 - atexit(tbomb_cleanup); 4.21 + atexit(fx_cleanup); 4.22 4.23 start_time = glutGet(GLUT_ELAPSED_TIME); 4.24 glutMainLoop(); 4.25 @@ -54,7 +54,7 @@ 4.26 4.27 glClear(GL_COLOR_BUFFER_BIT); 4.28 4.29 - tbomb_draw(msec); 4.30 + fx_draw(msec); 4.31 4.32 glutSwapBuffers(); 4.33 assert(glGetError() == GL_NO_ERROR); 4.34 @@ -93,7 +93,7 @@ 4.35 break; 4.36 4.37 case ' ': 4.38 - tbomb_dbg(); 4.39 + fx_dbg(); 4.40 break; 4.41 } 4.42 }
5.1 --- a/src/tbomb.cc Wed Aug 19 09:13:48 2015 +0300 5.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 5.3 @@ -1,117 +0,0 @@ 5.4 -#include <stdio.h> 5.5 -#include <stdlib.h> 5.6 -#include "opengl.h" 5.7 -#include "tbomb.h" 5.8 -#include "psys.h" 5.9 - 5.10 -#include "hello1.h" 5.11 -#include "hello2.h" 5.12 -#include "pimg.h" 5.13 - 5.14 -static PSysParam ppmain; 5.15 -static PSysParam ppexpl, ppflame; 5.16 - 5.17 -static ParticleSystem psys; 5.18 -static Image *pimg; 5.19 -static Image *simg[2]; 5.20 - 5.21 -bool tbomb_init() 5.22 -{ 5.23 - ppmain.spawn_rate = 20000; 5.24 - ppmain.size = 0.06; 5.25 - ppmain.spawn_range = 0.01; 5.26 - ppmain.life = 0.4; 5.27 - ppmain.gravity = Vector3(0, 0.01, 0); 5.28 - 5.29 - ppmain.pcolor_start = Vector3(0.717, 0.494, 0.951) * 0.6; 5.30 - ppmain.pcolor_end = Vector3(0.9, 0.135, 0.005) * 0.6; 5.31 - ppmain.pcolor_mid = lerp(ppmain.pcolor_start, ppmain.pcolor_mid, 0.5); 5.32 - 5.33 - ppmain.palpha_start = 1.0; 5.34 - ppmain.palpha_mid = 0.5; 5.35 - ppmain.palpha_end = 0.0; 5.36 - 5.37 - ppmain.pscale_start = 1.0; 5.38 - ppmain.pscale_mid = 1.0; 5.39 - ppmain.pscale_end = 7.0; 5.40 - 5.41 - pimg = new Image; 5.42 - pimg->pixels = (unsigned char*)img_particle.pixel_data; 5.43 - pimg->width = img_particle.width; 5.44 - pimg->height = img_particle.height; 5.45 - 5.46 - ppmain.pimg = pimg; 5.47 - 5.48 - simg[0] = new Image; 5.49 - simg[0]->pixels = (unsigned char*)img_hello1.pixel_data; 5.50 - simg[0]->width = img_hello1.width; 5.51 - simg[0]->height = img_hello1.height; 5.52 - 5.53 - simg[1] = new Image; 5.54 - simg[1]->pixels = (unsigned char*)img_hello2.pixel_data; 5.55 - simg[1]->width = img_hello2.width; 5.56 - simg[1]->height = img_hello2.height; 5.57 - 5.58 - ppmain.spawn_map = simg[0]; 5.59 - ppmain.spawn_map_speed = 0.8; 5.60 - psys.pp = ppmain; 5.61 - 5.62 - // explosion parameters 5.63 - ppexpl = ppmain; 5.64 - ppexpl.pcolor_start = ppmain.pcolor_mid; 5.65 - ppexpl.pcolor_mid = lerp(ppexpl.pcolor_start, ppexpl.pcolor_end, 0.5); 5.66 - 5.67 - ppexpl.palpha_start = 1.0; 5.68 - ppexpl.palpha_mid = 0.5; 5.69 - ppexpl.palpha_end = 0.05; 5.70 - 5.71 - ppexpl.pscale_start = 1.0; 5.72 - ppexpl.pscale_mid = 3.0; 5.73 - ppexpl.pscale_end = 5.0; 5.74 - ppexpl.gravity = Vector3(0, -6, 0); 5.75 - 5.76 - // flame parameters 5.77 - ppflame = ppexpl; 5.78 - ppflame.pcolor_start = Vector3(1.0, 0.8, 0.2) * 0.5; 5.79 - ppflame.pcolor_mid = Vector3(1.0, 0.3, 0.2) * 0.5; 5.80 - ppflame.pcolor_end = Vector3(0.1, 0.1, 0.1); 5.81 - //ppflame.pcolor_mid = lerp(ppflame.pcolor_start, ppflame.pcolor_end, 0.6); 5.82 - 5.83 - ppflame.life = 0.5; 5.84 - ppflame.life_range = 0.25; 5.85 - ppflame.size = 0.07; 5.86 - ppflame.size_range = 0.03; 5.87 - ppflame.spawn_rate = 18000; 5.88 - ppflame.gravity = Vector3(0, 2, 0); 5.89 - 5.90 - ppflame.palpha_start *= 0.7; 5.91 - ppflame.palpha_mid *= 0.7; 5.92 - ppflame.palpha_end *= 0.7; 5.93 - 5.94 - return true; 5.95 -} 5.96 - 5.97 -void tbomb_cleanup() 5.98 -{ 5.99 - delete pimg; 5.100 - delete simg[0]; 5.101 - delete simg[1]; 5.102 -} 5.103 - 5.104 -void tbomb_draw(unsigned long msec) 5.105 -{ 5.106 - static unsigned long prev_msec; 5.107 - float dt = (msec - prev_msec) / 1000.0; 5.108 - prev_msec = msec; 5.109 - 5.110 - psys.update(dt); 5.111 - psys.draw(); 5.112 -} 5.113 - 5.114 -void tbomb_dbg() 5.115 -{ 5.116 - psys.explode(Vector3(0, 0, 0), 2.5, ppflame.life, 1.5); 5.117 - psys.pp = ppflame; 5.118 - //psys.explode(Vector3(0, -0.2, 0), 3.0, 1.5); 5.119 - //psys.pp = ppexpl; 5.120 -}
6.1 --- a/src/tbomb.h Wed Aug 19 09:13:48 2015 +0300 6.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 6.3 @@ -1,10 +0,0 @@ 6.4 -#ifndef TBOMB_H_ 6.5 -#define TBOMB_H_ 6.6 - 6.7 -bool tbomb_init(); 6.8 -void tbomb_cleanup(); 6.9 - 6.10 -void tbomb_draw(unsigned long msec); 6.11 -void tbomb_dbg(); 6.12 - 6.13 -#endif // TBOMB_H_