libpsys
diff examples/simple/simple.c @ 8:a10f19674147
ha!
author | John Tsiombikas <nuclear@mutantstargoat.com> |
---|---|
date | Tue, 27 Sep 2011 21:47:27 +0300 |
parents | 6e5342a2529a |
children | 9c24273f211b |
line diff
1.1 --- a/examples/simple/simple.c Tue Sep 27 07:52:01 2011 +0300 1.2 +++ b/examples/simple/simple.c Tue Sep 27 21:47:27 2011 +0300 1.3 @@ -12,6 +12,7 @@ 1.4 #include <imago2.h> 1.5 #include "psys.h" 1.6 1.7 +void cleanup(void); 1.8 void disp(void); 1.9 void idle(void); 1.10 void reshape(int x, int y); 1.11 @@ -41,21 +42,30 @@ 1.12 glClearColor(0.05, 0.05, 0.05, 1); 1.13 1.14 if(!(tex = load_texture("pimg.png"))) { 1.15 - fprintf(stderr, "failed to load the FUCKING TEXTURE GOD DAMN IT\n"); 1.16 + fprintf(stderr, "failed to load the texture\n"); 1.17 return 1; 1.18 } 1.19 1.20 if(!(ps = psys_create())) { 1.21 return 1; 1.22 } 1.23 - psys_set_grav(ps, v3_cons(0, -9, 0), 0); 1.24 - psys_set_life(ps, 2, 0); 1.25 - psys_set_texture(ps, tex); 1.26 + psys_set_value3(&ps->attr.grav, 0, v3_cons(0, -9, 0)); 1.27 + psys_set_anm_rnd(&ps->attr.life, 0, 2, 0); 1.28 + psys_set_value3(&ps->attr.spawn_range, 0, v3_cons(0.2, 0.2, 0.2)); 1.29 + psys_set_anm_rnd3(&ps->attr.dir, 0, v3_cons(0, 0, 0), v3_cons(2, 2, 2)); 1.30 + ps->attr.tex = tex; 1.31 + 1.32 + atexit(cleanup); 1.33 1.34 glutMainLoop(); 1.35 return 0; 1.36 } 1.37 1.38 +void cleanup(void) 1.39 +{ 1.40 + psys_free(ps); 1.41 +} 1.42 + 1.43 void disp(void) 1.44 { 1.45 static unsigned int prev_msec; 1.46 @@ -101,7 +111,7 @@ 1.47 { 1.48 bnstate[bn - GLUT_LEFT_BUTTON] = state == GLUT_DOWN; 1.49 if(bn == GLUT_LEFT_BUTTON) { 1.50 - psys_set_rate(ps, state == GLUT_DOWN ? 30.0 : 0.0, 0); 1.51 + psys_set_value(&ps->attr.rate, 0, state == GLUT_DOWN ? 30.0 : 0.0); 1.52 psys_set_pos(ps, get_mouse_hit(x, y), 0); 1.53 } 1.54 }