Beispiel #1
0
void HutObj::update(){

    if(get_hp() < 0){
		set_dead(true);
	}

	if(get_dead()){
		btTransform trans;
		get_body()->getMotionState()->getWorldTransform(trans); 

		if( !spawn_list.empty() ){
			GameObj* new_obj = new HutObj( spawn_list, col_list, trans.getOrigin() );
			spawn_new_obj( new_obj );
		}

	}
}
Beispiel #2
0
void conway_run(int8_t *start_pic)
{
	old_fb = start_pic;
	new_fb = led_matrix_set_fb(old_fb);
	uint8_t	changed = 1; // first time anyway

	led_matrix_set_pixel(8, 4, 1);
	led_matrix_set_pixel(8, 5, 1);
	led_matrix_set_pixel(8, 6, 1);

		
	led_matrix_set_pixel(7, 5, 1);
	led_matrix_set_pixel(7, 11, 1);

	led_matrix_set_pixel(8, 10, 1);
	led_matrix_set_pixel(8, 11, 1);
	led_matrix_set_pixel(8, 12, 1);

	app_reset_tick();
	app_start_tick();

	while(1) {
	if(old_fb == new_fb) {
		uart_puts("the same!!!\n");
		//malloc new fb
	} 

		for(uint8_t x = 0; x < SIZE_X; x ++) {
			for(uint8_t y = 0; y < SIZE_Y; y ++) {
				uint8_t neighbors = living_neighbors(x,y);
				if(neighbors == 3) {
					if(is_dead(x,y)) {
						changed = 1;
					}
					set_alive(x,y);
				}else if(neighbors == 2) {
					if(is_alive(x,y)) {
						set_alive(x,y);
					}else{
						set_dead(x,y);
					}
				}else {
					
					if(is_alive(x,y)) {
						changed = 1;
					}
					set_dead(x,y);
				}
			}
		}
		if(changed == 0) {
			reset_fb();
			app_stop_tick();
			app_reset_tick();
			return;	
		}
		changed = 0;
		/*	while(app_get_tick()) {
			uart_puts("waiting\n");
			_delay_ms(10);
			}*/
		for(int k = 0; k < 50; k++) {
			_delay_ms(10);
		}
		app_dec_tick();
		old_fb = new_fb;
		new_fb = led_matrix_set_fb(new_fb);
	}
}