Exemple #1
0
static void draw_star(struct star * star, int z_move)
{
    int x_draw, y_draw;

    x_draw = star->x / star->z + SCREEN_WIDTH / 2;
    if(x_draw < 1 || x_draw >= SCREEN_WIDTH)
    {
       init_star(star, z_move);
       return;
    }

    y_draw = star->y / star->z + SCREEN_HEIGHT/2;

    if(y_draw < 1 || y_draw >= SCREEN_HEIGHT)
    {
       init_star(star, z_move);
       return;
    }

    putPixelScreen(RGB(255, 255, 255), x_draw, y_draw);
    if(star->z < 5*Z_MAX_DIST/6)
    {
       putPixelScreen(RGB(255, 255, 255), x_draw, y_draw-1);
       putPixelScreen(RGB(255, 255, 255), x_draw-1, y_draw);
       if(star->z < Z_MAX_DIST/2)
       {
          putPixelScreen(RGB(255, 255, 255), x_draw+1, y_draw);
          putPixelScreen(RGB(255, 255, 255), x_draw, y_draw+1);
       }
    }
}
Exemple #2
0
int		process_instance( livido_port_t *my_instance, double timecode )
{
	int len =0;
	uint8_t *O[4]= {NULL,NULL,NULL,NULL};

	int palette;
	int w;
	int h;
	
	//@ get output channel details
	int error	  = lvd_extract_channel_values( my_instance, "out_channels", 0, &w,&h, O,&palette );
	if( error != LIVIDO_NO_ERROR )
		return LIVIDO_ERROR_NO_OUTPUT_CHANNELS; //@ error codes in livido flanky

	int uv_len = lvd_uv_plane_len( palette,w,h );
	len = w * h;
	
	starfield_t *starfield = NULL;
	if ( livido_property_get( my_instance, "PLUGIN_private", 0, &starfield ) != LIVIDO_NO_ERROR )
    	return LIVIDO_ERROR_INTERNAL;

	//@ get parameter values
	int		number_of_stars =  lvd_extract_param_index( my_instance,"in_parameters", 0 );
	int		speed = 2 + lvd_extract_param_index( my_instance, "in_parameters", 1 );

	livido_memset( O[0], 0, len );
	livido_memset( O[1], 128, uv_len );
	livido_memset( O[2], 128, uv_len );

	int center_x = w >> 1;
	int center_y = h >> 1;
	int i;
	int temp_x, temp_y;
	
	STAR **stars = starfield->stars;

	for( i = 0; i < number_of_stars; i ++ ) {
			
		stars[i]->zpos -= stars[i]->speed;

		if( stars[i]->zpos <= 0 ) {
			init_star( stars[i], i + 1, speed );
		}

		temp_x = (stars[i]->xpos / stars[i]->zpos ) + center_x;
		temp_y = (stars[i]->ypos / stars[i]->zpos ) + center_y;

		if( temp_x < 0 || temp_x > (w-1) || temp_y < 0 || temp_y > (h-1) ) {
			init_star( stars[i], i + 1, speed );
			continue;
		}

		O[0][ temp_y * w + temp_x ] = stars[i]->color;
	}
	

	return LIVIDO_NO_ERROR;
}
Exemple #3
0
static void move_star(struct star * star, int z_move)
{
    star->z -= z_move * star->velocity;

    if (star->z <= 0 || star->z > Z_MAX_DIST)
        init_star(star, z_move);
}
Exemple #4
0
static void init_vs_recipy(struct vs_recipy *vs)
{
	int i;
 	vs->objname[0] = 0;
 	vs->chart[0] = 0;
 	vs->frame[0] = 0;
	vs->ra = 0.0;
	vs->dec = 0.0;
	vs->cnt = 0;
	for (i=0; i<vs->max_cnt; i++)
		init_star(&(vs->s[i]));
	vs->usewcs = 0;
	vs->p.r1 = 5;
	vs->p.r2 = 8;
	vs->p.r3 = 14;
	vs->p.sky_method = APMET_MEDIAN;
	vs->p.sigmas = 1.0;
	vs->p.max_iter = 4;
	vs->p.sat_limit = 30000;
	vs->p.quads = ALLQUADS;
	strcpy(vs->repstar, "m");
	strcpy(vs->repinfo, "ftns");
//	vs->altitude = 0.0;
	vs->airmass = 0.0;
	vs->scint_factor = 3.0;
}
Exemple #5
0
static void starfield_add_stars(struct starfield * starfield, int nb_to_add)
{
    int i, old_nb_stars;

    old_nb_stars = starfield->nb_stars;
    starfield->nb_stars += nb_to_add;

    if(starfield->nb_stars > (SCREEN_WIDTH*SCREEN_HEIGHT*20)/100)
        starfield->nb_stars = (SCREEN_WIDTH*SCREEN_HEIGHT*20)/100;

    for(i=old_nb_stars; i < starfield->nb_stars; i++)
    {
        init_star(&(starfield->tab[i]), starfield->z_move);
    }
}
Exemple #6
0
livido_init_f	init_instance( livido_port_t *my_instance )
{
	starfield_t *starfield = (starfield_t*) livido_malloc( sizeof(starfield_t));
    starfield->stars = (STAR**) livido_malloc(sizeof(STAR*) * MAX_STARS );

	int i;
	for( i = 0; i < MAX_STARS ; i ++ ) {
		starfield->stars[i] = (STAR*) livido_malloc( sizeof(STAR) );
		init_star( starfield->stars[i], i + 1 , 2 );
	}

	livido_property_set( my_instance, "PLUGIN_private", LIVIDO_ATOM_TYPE_VOIDPTR,1, &starfield);

	return LIVIDO_NO_ERROR;
}
void ram(void)
{
	short centerx = RESX >> 1;
	short centery = RESY >> 1;
	short i;
	uint8_t key = 0;

	for (i = 0; i < NUM_STARS; i++) {
		init_star(stars + i, i + 1);
	}

	static uint8_t count = 0;
	while(1) {
		count++;
		count%=256;
		key = getInputRaw();
		if (key == BTN_ENTER) {
			break;
		} else if ( count%4 == 0 ) {
			if (key == BTN_UP && ship.speed < SPEED_MAX) {
				ship.speed++;
			} else if (key == BTN_DOWN && ship.speed > SPEED_STOP) {
				ship.speed--;
			} else if (key == BTN_NONE && count % 12 == 0) {
				/* converge towards default speed */
				if (ship.speed < SPEED_DEFAULT)
					ship.speed++;
				else if (ship.speed > SPEED_DEFAULT)
					ship.speed--;	
			}
		}

		if (ship.speed > SPEED_WARP) {
			set_warp_lights(1);
		} else {
			set_warp_lights(0);
		}

        if (count % 3 == 0) OFF(LED4);
		if (ship.speed == 0 && count%6==0) 
            drift_ship();
 

		int dx=0;
		int dy=0;
		setExtFont(GLOBAL(nickfont));
		setTextColor(0x00,0xFF);
		dx=DoString(0,0,GLOBAL(nickname));
		dx=(RESX-dx)/2;
		if(dx<0) dx=0;
		dy=(RESY-getFontHeight())/2;

		lcdFill(0x00);
		DoString(dx,dy,GLOBAL(nickname));

		for (i = 0; i < NUM_STARS; i++) {
			stars[i].z -= ship.speed;

			if (ship.speed > 0 && stars[i].z <= 0)
				init_star(stars + i, i + 1);

			short tempx = ((stars[i].x * 30) / stars[i].z) + centerx;
			short tempy = ((stars[i].y * 30) / stars[i].z) + centery;

			if (tempx < 0 || tempx > RESX - 1 || tempy < 0 || tempy > RESY - 1) {
				if (ship.speed > 0) { /* if we are flying, generate new stars in front */
					init_star(stars + i, i + 1);
				} else { /* if we are drifting, simply move those stars to the other end */
					stars[i].x = (((tempx%RESX)-centerx)*stars[i].z)/30;
					stars[i].y = (((tempy%RESY)-centery)*stars[i].z)/30;
				}
				continue;
			}

			lcdSetPixel(tempx, tempy, 0xFF);
			if (stars[i].z < 50) {
				lcdSetPixel(tempx + 1, tempy, 0xFF);
			}
			if (stars[i].z < 20) {
				lcdSetPixel(tempx, tempy + 1, 0xFF);
				lcdSetPixel(tempx + 1, tempy + 1, 0xFF);
			}
		}

		lcdDisplay();

		delayms_queue_plus(50,0);
	}
	set_warp_lights(0);
}