Exemple #1
0
//rotate 90deg cw unless arg is 0
void
b(int cw){
	
	int i;
	char tmp;
	
	if(cw != 0){
		//rotates the face and adjacent ones clockwise
		rotate_cw(this_cube->full_cube[0].side, SIDE_WIDTH);
		for(i = 0; i < SIDE_WIDTH; i++){
		  
			tmp=this_cube->full_cube[0].side[0][i];
			this_cube->full_cube[0].side[0][i] = this_cube->full_cube[3].side[i][SIDE_WIDTH - 1];
			this_cube->full_cube[3].side[i][SIDE_WIDTH - 1] = this_cube->full_cube[1].side[SIDE_WIDTH - 1][i];
			this_cube->full_cube[1].side[SIDE_WIDTH - 1][i] = this_cube->full_cube[2].side[i][0];
			this_cube->full_cube[2].side[i][0] = tmp;
			
		}
		
	} else {
		//rotates the face and adjacent sides counter-clockwise
		rotate_ccw(this_cube->full_cube[0].side, SIDE_WIDTH);
		for(i = 0; i < SIDE_WIDTH; i++){
			
			tmp=this_cube->full_cube[0].side[0][i];
			this_cube->full_cube[0].side[0][i] = this_cube->full_cube[2].side[i][0];
			this_cube->full_cube[2].side[i][0] = this_cube->full_cube[1].side[SIDE_WIDTH - 1][i];
			this_cube->full_cube[1].side[SIDE_WIDTH - 1][i] = this_cube->full_cube[3].side[i][SIDE_WIDTH - 1];
			this_cube->full_cube[3].side[i][SIDE_WIDTH - 1] = tmp;

		}
	}
}
Exemple #2
0
void undo_turn(struct Board* b, struct Turn* t){
   /* Keep game-piece counter up-to-date */
   b->filled--;
   b->colour = 3 - (b->colour);
   if(t->dir == CW){
      rotate_ccw(b, t->quad);
   }
   else{
      rotate_cw(b, t->quad);
   }
   b->board[t->row][t->col] = NONE;
}
Exemple #3
0
void do_turn(struct Board* b, struct Turn* t){
   /* Keep game-piece counter up-to-date */
   b->filled++;
   b->board[t->row][t->col] = b->colour;
   if(t->dir == CW){
      rotate_cw(b, t->quad);
   }
   else{
      rotate_ccw(b, t->quad);
   }
   /* Swap active player: 3 - 2 = 1; 3 - 1 = 2 */
   b->colour = 3 - (b->colour);
}
	void player_system::update(double dt)
	{
		current_dt = dt;
		memset(ent_cache, 0x00, sizeof(hs::entity *)*hs::cfg::entity_system.entity_pool_size);
		cache_size = em->get_entities_posessing_component(comp_player::family_id, ent_cache, hs::cfg::entity_system.entity_pool_size);
		
		for (int i = 0; i < cache_size; i++)
		{
			current_entity = ent_cache[i];
			current_pos = current_entity->get<hs::comp::position>();
			player = current_entity->get<comp_player>();
			
			if (hs::g_input.has_touched_down())
			{
				bool valid = true;
				if (hs::g_input.get_current_touch_location().y > 440 &&
					hs::g_input.get_current_touch_location().x > 280)
					valid = false;
				
				if (valid)
				{
					if (hs::g_input.get_current_touch_location().y > 400)
					{
						if (hs::g_input.get_current_touch_location().x < 160)
							rotate_ccw();
						else
							rotate_cw();
					}

					if (hs::g_input.get_current_touch_location().y > 100 &&
						hs::g_input.get_current_touch_location().y < 400 )
					{
						if (hs::g_input.get_current_touch_location().x < 160)
						{
							move_left();
						}
						else
						{
							move_right();
						}
					}

					if (hs::g_input.get_current_touch_location().y < 100)
					{
						player->fast_drop = true;
						player->timer = 0.1;
					}
				}
			}
			
			if (hs::g_input.has_touched_up())
			{
				if (player->fast_drop)
				{
					player->fast_drop = false;
//					player->timer = player->fall_time * global::g_state.difficulty;
				}
			}
			handle_state_falling();
		}
	}
Exemple #5
0
void
Critter::move()
{
    const MyDouble T = MyDouble(qtime.elapsed()) / 1e3;
    MyDouble cp;
    switch(state)
    {
    case ALIVE_AND_MOVING_ON_EDGE:
        current_position_along_edge = initial_position_along_edge + velocity * T; // scalar
        if(current_position_along_edge < edge->info().length) {
            current_coords = initial_coords + direction * current_position_along_edge; // vector
            frame_by_frame();
        }
        else {
            // Turn at node
            const My_node_ptr N = edge->target;

            last_edge = edge;   // We need last_edge to interpolate turning.

            handle_turn_at_node(N);
            check_collision_with_intelligence(N);
            
            // cout << endl << "Crossing node " << N << endl;
            // maze->list_intelligence_at_nodes();

            // handle_turn_at_node(N) updated edge; therefore the edge
            // referenced in initialize_critter_on_new_edge() is
            // different from the one just referenced.

            // initialize_critter_on_new_edge();
            initialize_critter_at_start_of_turn();
            state = ALIVE_AND_TURNING_ON_NODE;
        }
        break;                  // We break _out_ of switch statement.
    case ALIVE_AND_TURNING_ON_NODE:
        if(rotate_clockwise) {
            Transformation_E2d rotate_cw =
                Transformation_E2d(ROTATION,
                                   angular_velocity * T);
            instantaneous_direction = rotate_cw(instantaneous_direction);
            frame_by_frame();
        }
        else {
            Transformation_E2d rotate_ccw =
                Transformation_E2d(ROTATION,
                                   - angular_velocity * T);
            instantaneous_direction = rotate_ccw(instantaneous_direction);
            frame_by_frame();
        }

        /*MyDouble*/ cp = cross_product(instantaneous_direction.getVector_E2(),
                                    edge->info().direction.getVector_E2());

        if( (rotate_clockwise && cp > 0.0) || (!rotate_clockwise && cp < 0.0) )
            current_Z_angle_in_degrees = Two_D_to_Three_D::z_angle_in_radians(instantaneous_direction) * 180.0 / M_PI;
        else {
            state = ALIVE_AND_MOVING_ON_EDGE;
            initialize_critter_on_new_edge();
            qtime.start();
        }
        break;
    case KNOCKED_OUT:
        current_position_along_edge = initial_position_along_edge + velocity * T; // scalar
        if(current_position_along_edge < KNOCKING_OUT_LENGTH)
            current_coords = initial_coords + direction * current_position_along_edge; // vector
        else {
            state = DEAD;
            initialize_on_death();
        }
        break;
    case DEAD:
        if(qtime.elapsed() > CRITTER_DEATH_TIME) {
            state = ALIVE_AND_MOVING_ON_EDGE;

            edge = maze->get_random_outgoing_edge( maze->get_random_node() );

            initialize_critter_on_new_edge();
        }
        break;
    }
}
Exemple #6
0
static int fbcon_rotate_font(struct fb_info *info, struct vc_data *vc)
{
	struct fbcon_ops *ops = info->fbcon_par;
	int len, err = 0;
	int s_cellsize, d_cellsize, i;
	const u8 *src;
	u8 *dst;

	if (vc->vc_font.data == ops->fontdata &&
	    ops->p->con_rotate == ops->cur_rotate)
		goto finished;

	src = ops->fontdata = vc->vc_font.data;
	ops->cur_rotate = ops->p->con_rotate;
	len = (!ops->p->userfont) ? 256 : FNTCHARCNT(src);
	s_cellsize = ((vc->vc_font.width + 7)/8) *
		vc->vc_font.height;
	d_cellsize = s_cellsize;

	if (ops->rotate == FB_ROTATE_CW ||
	    ops->rotate == FB_ROTATE_CCW)
		d_cellsize = ((vc->vc_font.height + 7)/8) *
			vc->vc_font.width;

	if (info->fbops->fb_sync)
		info->fbops->fb_sync(info);

	if (ops->fd_size < d_cellsize * len) {
		dst = kmalloc(d_cellsize * len, GFP_KERNEL);

		if (dst == NULL) {
			err = -ENOMEM;
			goto finished;
		}

		ops->fd_size = d_cellsize * len;
		kfree(ops->fontbuffer);
		ops->fontbuffer = dst;
	}

	dst = ops->fontbuffer;
	memset(dst, 0, ops->fd_size);

	switch (ops->rotate) {
	case FB_ROTATE_UD:
		for (i = len; i--; ) {
			rotate_ud(src, dst, vc->vc_font.width,
				  vc->vc_font.height);

			src += s_cellsize;
			dst += d_cellsize;
		}
		break;
	case FB_ROTATE_CW:
		for (i = len; i--; ) {
			rotate_cw(src, dst, vc->vc_font.width,
				  vc->vc_font.height);
			src += s_cellsize;
			dst += d_cellsize;
		}
		break;
	case FB_ROTATE_CCW:
		for (i = len; i--; ) {
			rotate_ccw(src, dst, vc->vc_font.width,
				   vc->vc_font.height);
			src += s_cellsize;
			dst += d_cellsize;
		}
		break;
	}

finished:
	return err;
}