Advertisement
xerpi

PSP shit wave

Jun 20th, 2014
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.17 KB | None | 0 0
  1. void draw_wave(int start_y, unsigned int color, float amplitude, float frequency, float lambda, float time)
  2. {
  3.     sceGuDisable(GU_TEXTURE_2D);
  4.    
  5.     #define STEP_SIZE 2
  6.    
  7.     float _2A = 2.0f * amplitude;
  8.     float k = _2PI/lambda;
  9.     float omega = _2PI*frequency;
  10.    
  11.     int x;
  12.     for (x = 0; x < 480; x += STEP_SIZE) {
  13.        
  14.         float y = _2A*cosf(k*x)*sinf(omega*time);
  15.        
  16.         struct ya2d_vertex_1ui3s *vertices = sceGuGetMemory(4 * sizeof(struct ya2d_vertex_1ui3s));
  17.         vertices[0].color = color;
  18.         vertices[0].x = x;
  19.         vertices[0].y = 272;
  20.         vertices[0].z = 0;
  21.        
  22.         vertices[1].color = color;
  23.         vertices[1].x = x;
  24.         vertices[1].y = start_y + y;
  25.         vertices[1].z = 0;
  26.  
  27.         vertices[2].color = color;
  28.         vertices[2].x = x + STEP_SIZE;
  29.         vertices[2].y = 272;
  30.         vertices[2].z = 0;
  31.        
  32.         vertices[3].color = color;
  33.         vertices[3].x = x + STEP_SIZE;
  34.         vertices[3].y = start_y + y;
  35.         vertices[3].z = 0;
  36.        
  37.         sceGumDrawArray(GU_TRIANGLE_STRIP, GU_COLOR_8888|GU_VERTEX_16BIT|GU_TRANSFORM_2D, 4, 0, vertices);  
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement