OSDN Git Service

hk
[psychlops/cpp_document.git] / Psychlops.manual / sample_cpp_file / 3�� / 3.2_�����_���h�b�g4.cpp
1 #include <psychlops.h>
2 using namespace Psychlops;
3
4 const int dotsize=4;
5 const int width=100;
6 double height=50;
7 double temp1;
8 double speed=1;
9 double phase=0;
10 int frame=0;
11 Psychlops::Rectangle rect1[width];
12 Psychlops::Color col;
13 Psychlops::Image Noise1[width];
14
15 void psychlops_main() {
16
17         Canvas sampleA(Canvas::fullscreen);
18         
19         for(int x=0; x<width; x++){
20                 Noise1[x].set(dotsize,height*dotsize);
21                 rect1[x].set(dotsize, dotsize);
22                 for(int y=0; y<height; y++){
23                         temp1=Psychlops::random();
24                         col.set(temp1);
25                         Noise1[x].rect(rect1[x],col);
26                         rect1[x].shift(0, dotsize);
27                 }       
28         }
29         while(!Input::get(Keyboard::spc)){
30                 for(int x=0; x<width; x++){
31                         phase=(double)-1/2*(width*dotsize)+(int)(x*dotsize+frame*speed*dotsize)%(int)(width*dotsize);
32                         Noise1[x].centering().shift(phase,0);
33                         Noise1[x].draw();
34                 }
35                 sampleA.flip();
36                 frame++;
37         }
38 }