Пример #1
0
 /* This isn't really the right way to do this; a better way
  * would be to use a timer to push user events onto the
  * event queue.
  */
 void play() {
     if (frames.size() > 0) {
         while (playing) {
             show_surface(frames[current_frame++]);
             if (current_frame == frames.size()) current_frame = 0;
             SDL_Delay(delay_ms);
         }
     }
 }
int main( int argc, char* args[] )
{
    //Quit flag
    bool quit = false;

    //Initialize
    if( init() == false )
    {
        return 1;
    }

    //Load the files
    if( load_files() == false )
    {
        return 1;
    }

    //Show the background
    show_surface( 0, 0, background );

    //Create and run the threads
    threadA = SDL_CreateThread( blitter_a, NULL );
    threadB = SDL_CreateThread( blitter_b, NULL );

    //Wait for the threads to finish
    SDL_WaitThread( threadA, NULL );
    SDL_WaitThread( threadB, NULL );

    //While the user hasn't quit
    while( quit == false )
    {
        //If there's an event to handle
        if( SDL_PollEvent( &event ) )
        {
            //If the user has Xed out the window
            if( event.type == SDL_QUIT )
            {
                //Quit the program
                quit = true;
            }
        }
    }

    //Clean up
    clean_up();

    return 0;
}
int blitter_b( void *data )
{
    //Y offset
    int y = 10;

    //Go through the surface
    for( int b = 0; b < 5; b++ )
    {
        //Wait
        SDL_Delay( 200 );

        //Show surface
        show_surface( ( SCREEN_WIDTH / 2 ) + ( ( ( SCREEN_WIDTH / 2 ) - text[ b ]->w ) / 2 ), y, text[ b ] );

        //Move down
        y += 100;
    }

    return 0;
}
Пример #4
0
/* return TRUE if a command match, FALSE if not */
static TBOOLEAN
 show_two()
{
    if (almost_equals(c_token, "p$lot")) {
	(void) putc('\n', stderr);
	show_plot();
	c_token++;
    } else if (almost_equals(c_token, "par$ametric")) {
	(void) putc('\n', stderr);
	show_parametric();
	c_token++;
    } else if (almost_equals(c_token, "poi$ntsize")) {
	(void) putc('\n', stderr);
	show_pointsize();
	c_token++;
    } else if (almost_equals(c_token, "enc$oding")) {
	(void) putc('\n', stderr);
	show_encoding();
	c_token++;
    } else if (almost_equals(c_token, "pol$ar")) {
	(void) putc('\n', stderr);
	show_polar();
	c_token++;
    } else if (almost_equals(c_token, "an$gles")) {
	(void) putc('\n', stderr);
	show_angles();
	c_token++;
    } else if (almost_equals(c_token, "ti$cs")) {
	(void) putc('\n', stderr);
	show_tics(TRUE, TRUE, TRUE, TRUE, TRUE);
	c_token++;
    } else if (almost_equals(c_token, "tim$estamp")) {
	(void) putc('\n', stderr);
	show_xyzlabel("time", &timelabel);
	fprintf(stderr, "\twritten in %s corner\n", (timelabel_bottom ? "bottom" : "top"));
	if (timelabel_rotate)
	    fputs("\trotated if the terminal allows it\n\t", stderr);
	else
	    fputs("\tnot rotated\n\t", stderr);
	c_token++;
    } else if (almost_equals(c_token, "su$rface")) {
	(void) putc('\n', stderr);
	show_surface();
	c_token++;
    } else if (almost_equals(c_token, "hi$dden3d")) {
	(void) putc('\n', stderr);
	show_hidden3d();
	c_token++;
    } else if (almost_equals(c_token, "cla$bel")) {
	(void) putc('\n', stderr);
	show_label_contours();
	c_token++;
    } else if (almost_equals(c_token, "xti$cs")) {
	show_tics(TRUE, FALSE, FALSE, TRUE, FALSE);
	c_token++;
    } else if (almost_equals(c_token, "yti$cs")) {
	show_tics(FALSE, TRUE, FALSE, FALSE, TRUE);
	c_token++;
    } else if (almost_equals(c_token, "zti$cs")) {
	show_tics(FALSE, FALSE, TRUE, FALSE, FALSE);
	c_token++;
    } else if (almost_equals(c_token, "x2ti$cs")) {
	show_tics(FALSE, FALSE, FALSE, TRUE, FALSE);
	c_token++;
    } else if (almost_equals(c_token, "y2ti$cs")) {
	show_tics(FALSE, FALSE, FALSE, FALSE, TRUE);
	c_token++;
    } else if (almost_equals(c_token, "xdti$cs")) {
	show_tics(TRUE, FALSE, FALSE, TRUE, FALSE);
	c_token++;
    } else if (almost_equals(c_token, "ydti$cs")) {
	show_tics(FALSE, TRUE, FALSE, FALSE, TRUE);
	c_token++;
    } else if (almost_equals(c_token, "zdti$cs")) {
	show_tics(FALSE, FALSE, TRUE, FALSE, FALSE);
	c_token++;
    } else if (almost_equals(c_token, "x2dti$cs")) {
	show_tics(FALSE, FALSE, FALSE, TRUE, FALSE);
	c_token++;
    } else if (almost_equals(c_token, "y2dti$cs")) {
	show_tics(FALSE, FALSE, FALSE, FALSE, TRUE);
	c_token++;
    } else if (almost_equals(c_token, "xmti$cs")) {
	show_tics(TRUE, FALSE, FALSE, TRUE, FALSE);
	c_token++;
    } else if (almost_equals(c_token, "ymti$cs")) {
	show_tics(FALSE, TRUE, FALSE, FALSE, TRUE);
	c_token++;
    } else if (almost_equals(c_token, "zmti$cs")) {
	show_tics(FALSE, FALSE, TRUE, FALSE, FALSE);
	c_token++;
    } else if (almost_equals(c_token, "x2mti$cs")) {
	show_tics(FALSE, FALSE, FALSE, TRUE, FALSE);
	c_token++;
    } else if (almost_equals(c_token, "y2mti$cs")) {
	show_tics(FALSE, FALSE, FALSE, FALSE, TRUE);
	c_token++;
    } else if (almost_equals(c_token, "sa$mples")) {
	(void) putc('\n', stderr);
	show_samples();
	c_token++;
    } else if (almost_equals(c_token, "isosa$mples")) {
	(void) putc('\n', stderr);
	show_isosamples();
	c_token++;
    } else if (almost_equals(c_token, "si$ze")) {
	(void) putc('\n', stderr);
	show_size();
	c_token++;
    } else if (almost_equals(c_token, "orig$in")) {
	(void) putc('\n', stderr);
	show_origin();
	c_token++;
    } else if (almost_equals(c_token, "t$erminal")) {
	(void) putc('\n', stderr);
	show_term();
	c_token++;
    } else if (almost_equals(c_token, "rr$ange")) {
	(void) putc('\n', stderr);
	show_range(R_AXIS, rmin, rmax, autoscale_r, "r");
	c_token++;
    } else if (almost_equals(c_token, "tr$ange")) {
	(void) putc('\n', stderr);
	show_range(T_AXIS, tmin, tmax, autoscale_t, "t");
	c_token++;
    } else if (almost_equals(c_token, "ur$ange")) {
	(void) putc('\n', stderr);
	show_range(U_AXIS, umin, umax, autoscale_u, "u");
	c_token++;
    } else if (almost_equals(c_token, "vi$ew")) {
	(void) putc('\n', stderr);
	show_view();
	c_token++;
    } else if (almost_equals(c_token, "vr$ange")) {
	(void) putc('\n', stderr);
	show_range(V_AXIS, vmin, vmax, autoscale_v, "v");
	c_token++;
    } else if (almost_equals(c_token, "v$ariables")) {
	show_variables();
	c_token++;
    } else if (almost_equals(c_token, "ve$rsion")) {
	show_version(stderr);
    } else if (almost_equals(c_token, "xr$ange")) {
	(void) putc('\n', stderr);
	show_range(FIRST_X_AXIS, xmin, xmax, autoscale_x, "x");
	c_token++;
    } else if (almost_equals(c_token, "yr$ange")) {
	(void) putc('\n', stderr);
	show_range(FIRST_Y_AXIS, ymin, ymax, autoscale_y, "y");
	c_token++;
    } else if (almost_equals(c_token, "x2r$ange")) {
	(void) putc('\n', stderr);
	show_range(SECOND_X_AXIS, x2min, x2max, autoscale_x2, "x2");
	c_token++;
    } else if (almost_equals(c_token, "y2r$ange")) {
	(void) putc('\n', stderr);
	show_range(SECOND_Y_AXIS, y2min, y2max, autoscale_y2, "y2");
	c_token++;
    } else if (almost_equals(c_token, "zr$ange")) {
	(void) putc('\n', stderr);
	show_range(FIRST_Z_AXIS, zmin, zmax, autoscale_z, "z");
	c_token++;
    } else if (almost_equals(c_token, "z$ero")) {
	(void) putc('\n', stderr);
	show_zero();
	c_token++;
    } else if (almost_equals(c_token, "a$ll")) {
	c_token++;
	show_version(stderr);
	show_autoscale();
	show_bars();
	show_border();
	show_boxwidth();
	show_clip();
	show_contour();
	show_dgrid3d();
	show_mapping();
	(void) fprintf(stderr, "\tdummy variables are \"%s\" and \"%s\"\n",
		       dummy_var[0], dummy_var[1]);
	show_format();
	show_style("data", data_style);
	show_style("functions", func_style);
	show_grid();
	show_xzeroaxis();
	show_yzeroaxis();
	show_label(0);
	show_arrow(0);
	show_linestyle(0);
	show_keytitle();
	show_key();
	show_logscale();
	show_offsets();
	show_margin();
	show_output();
	show_parametric();
	show_pointsize();
	show_encoding();
	show_polar();
	show_angles();
	show_samples();
	show_isosamples();
	show_view();
	show_surface();
#ifndef LITE
	show_hidden3d();
#endif
	show_size();
	show_origin();
	show_term();
	show_tics(TRUE, TRUE, TRUE, TRUE, TRUE);
	show_mtics(mxtics, mxtfreq, "x");
	show_mtics(mytics, mytfreq, "y");
	show_mtics(mztics, mztfreq, "z");
	show_mtics(mx2tics, mx2tfreq, "x2");
	show_mtics(my2tics, my2tfreq, "y2");
	show_xyzlabel("time", &timelabel);
	if (parametric || polar) {
	    if (!is_3d_plot)
		show_range(T_AXIS, tmin, tmax, autoscale_t, "t");
	    else {
		show_range(U_AXIS, umin, umax, autoscale_u, "u");
		show_range(V_AXIS, vmin, vmax, autoscale_v, "v");
	    }
	}
	show_range(FIRST_X_AXIS, xmin, xmax, autoscale_x, "x");
	show_range(FIRST_Y_AXIS, ymin, ymax, autoscale_y, "y");
	show_range(SECOND_X_AXIS, x2min, x2max, autoscale_x2, "x2");
	show_range(SECOND_Y_AXIS, y2min, y2max, autoscale_y2, "y2");
	show_range(FIRST_Z_AXIS, zmin, zmax, autoscale_z, "z");
	show_xyzlabel("title", &title);
	show_xyzlabel("xlabel", &xlabel);
	show_xyzlabel("ylabel", &ylabel);
	show_xyzlabel("zlabel", &zlabel);
	show_xyzlabel("x2label", &x2label);
	show_xyzlabel("y2label", &y2label);
	show_datatype("xdata", FIRST_X_AXIS);
	show_datatype("ydata", FIRST_Y_AXIS);
	show_datatype("x2data", SECOND_X_AXIS);
	show_datatype("y2data", SECOND_Y_AXIS);
	show_datatype("zdata", FIRST_Z_AXIS);
	show_timefmt();
	show_locale();
	show_zero();
	show_missing();
	show_plot();
	show_variables();
	show_functions();
	c_token++;
    } else
	return (FALSE);
    return (TRUE);
}