Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- include "sgsxgmath";
- global initialWidth = 1024;
- global initialHeight = 576;
- function initialize()
- {
- global Window = SS_CreateWindow( "Fancy visualization [1]", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, initialWidth, initialHeight, SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGLMAYBE );
- Window.initRenderer( SS_RENDERER_DONTCARE, SS_RENDERER_DONTCARE, SS_RENDERER_VSYNC );
- global Font = SS_CreateFont( "familiar-pro-bold.otf", 32 );
- global FontBig = SS_CreateFont( "familiar-pro-bold.otf", 64 );
- global TxSpinner = SS_CreateTexture( "spinner.png", "mipmaps" );
- SS_InitDrawFunctions();
- global lasttime = ftime();
- global T = 0;
- global particle_count = 100;
- global particle_positions = floatarray_buffer( particle_count * 2 );
- global particle_time_offsets = floatarray_buffer( particle_count );
- particle_positions.randbox( vec2( 0, 0 ), vec2( 1024, 576 ) );
- particle_time_offsets.randbox( 0.0, 32.0 );
- }
- function update()
- {
- global lasttime;
- var curtime = ftime();
- var delta = curtime - lasttime;
- lasttime = curtime;
- if( delta > 1.0/15.0 )
- delta = 1.0/15.0;
- W = Window.width;
- H = Window.height;
- SS_Clear( color(0.1,0.1,0.1) );
- SS_SetCameraUI( 0, W, 0, H );
- global T;
- T += delta;
- SS_DrawColor2VRect( 0, 0, W, H, 0.2, 0.2, 0.2, 1, 0.05, 0.05, 0.05, 1 );
- spdT = T * 1;
- mpc0 = ( sin( spdT * 3 ) + sin( spdT * 5 ) + sin( spdT * 7 ) > 1.3 ) * 2.0;
- mpc1 = ( sin( spdT * 2 ) + sin( spdT * 4 ) + sin( spdT * 5 ) > 1.3 ) * 2.0;
- mpc2 = ( sin( spdT * 1 ) + sin( spdT * 3 ) + sin( spdT * 6 ) > 1.3 ) * 1.4;
- SS_SetCamera2D( 1024/2 + mpc0 - mpc2, 576/2 + mpc1 - mpc2, 300-T*2, 1024/576, 0 );
- for( i = 0; i < particle_count; ++i )
- {
- px = particle_positions[ i * 2 + 0 ];
- py = particle_positions[ i * 2 + 1 ];
- pq = sin( T + particle_time_offsets[ i ] ) * 0.5 + 0.5;
- pq *= pq;
- SS_DrawTextLine( "+", FontBig, px, py, color(1,1,1,0.25*pq) );
- }
- SS_SetCameraUI( 0, W, 0, H );
- textlen = T * 37 % 100 - 5;
- if( textlen < 0 ) textlen = 0;
- text = string_part( "Loading...", 0, textlen );
- SS_DrawTextLine( text, Font, W - 192, H - 64, color(0.9,0.91,0.92,0.5) );
- SS_Draw({ preset = "box", texture = TxSpinner, position = vec2(48,H-48), scale = vec2(48,48), angle = T * 2 });
- SS_Present();
- }
- function on_event( e )
- {
- if( e.type == SDL_QUIT )
- global sys_exit = true;
- }
- function cleanup()
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement