Exemplo n.º 1
0
	void shape::remove_frame(frame_index aFrameIndex)
	{
		if (aFrameIndex >= iFrames.size())
			throw bad_frame_index();
		iFrames.erase(iFrames.begin() + aFrameIndex);
		if (iCurrentFrame >= frame_count())
			iCurrentFrame = 0;
	}
Exemplo n.º 2
0
	rect shape::bounding_box() const
	{
		if (iBoundingBox != boost::none)
			return *iBoundingBox;
		else if (frame_count() > 0 && current_frame().has_extents())
			return rect{ origin() - current_frame().extents() / size{2.0}, current_frame().extents() };
		else
			return rect{ origin(), size{} };
	}
Exemplo n.º 3
0
static VALUE
callers(VALUE self)
{
  VALUE ary = rb_ary_new();

  for (int i = 0; i < FIX2INT(frame_count(self)); i++)
    rb_ary_push(ary, binding_of_caller(self, INT2FIX(i)));

  return ary;
}
Exemplo n.º 4
0
	void shape::paint(graphics_context& aGraphicsContext) const
	{
		if (frame_count() == 0)
			return;
		auto tm = transformation_matrix();
		auto m = map();
		for (auto& vertex : m)
			vertex = tm * vertex;
		if (current_frame().texture() != boost::none)
		{
			if (current_frame().texture_rect() == boost::none)
				aGraphicsContext.draw_texture(texture_map{ {m[0][0], m[0][1]}, {m[1][0], m[1][1]}, {m[2][0], m[2][1]}, {m[3][0], m[3][1]} }, *current_frame().texture());
			else
				aGraphicsContext.draw_texture(texture_map{ {m[0][0], m[0][1]}, {m[1][0], m[1][1]}, {m[2][0], m[2][1]}, {m[3][0], m[3][1]} }, *current_frame().texture(), *current_frame().texture_rect());
		}
		else if (current_frame().colour() != boost::none)
		{
			aGraphicsContext.fill_shape(position() - origin(), m, *current_frame().colour());
		}
	}
Exemplo n.º 5
0
/* This is the entry-point for the game! */
void c_start(void) {
    /* TODO:  You will need to initialize various subsystems here.  This
     *        would include the interrupt handling mechanism, and the various
     *        systems that use interrupts.  Once this is done, you can call
     *        enable_interrupts() to start interrupt handling, and go on to
     *        do whatever else you decide to do!
     */

    seed_rand_with_time();
    init_interrupts();
    init_keyboard();
    init_timer();
    enable_interrupts();

    int board[BOARD_SIZE][BOARD_SIZE] = { };
    animation_descriptor descriptor = { };
    initialize(board);
    int high_score = current_score(board);
    init_video(high_score);
    draw_board(board);
    
    /* Loop forever, so that we don't fall back into the bootloader code. */
    while (1) {
        if (!isemptyqueue()) {
            key k = dequeue();
            if (k == enter_key) {
                for (int *b = *board; b < *board + BOARD_SIZE * BOARD_SIZE; b++) *b = 0;
                initialize(board);
                init_video(high_score);
                draw_board(board);
                continue;
            } else {
                shift_direction direction = key_to_direction(k);

                // Setup animation
                copy_board(board, descriptor.board);
                descriptor.direction = direction;

                // Only add a box if the pieces actually move
                if (shift(board, direction, descriptor.offsets)) {
                    add_random_box(board);
                    int score = current_score(board);
                    if (score > high_score) high_score = score;
                    init_video(high_score);
                }
            }
            
            int num_frames = frame_count(descriptor.direction);
            int incr = get_axis(descriptor.direction) == horizontal_axis ? 12 : 2;
            int frame = 0;
            while (frame <= num_frames) {
                draw_board_frame(descriptor, frame);
                sleep(30);

                if (frame == num_frames) break;
                else frame = min(frame + incr, num_frames);
            }
            draw_board(board);
            
            if (!move_available(board)) {
                draw_failure_message();
            }
        }
    }
}
Exemplo n.º 6
0
	/*! \details Returns the total number of bytes used by the FFIFO buffer (frame size * frame count). */
	u32 size() const { return frame_size() * frame_count(); }
Exemplo n.º 7
0
		T get_interpolated_value( index_t frame0, index_t channel, T pos ) {
			flut_assert( frame0 >= frame_count() - num_frames && frame0 < frame_count() && channel < this->channel_count() );
			index_t ofs0 = ( frame0 % num_frames ) * this->channel_count() + channel;
			index_t ofs1 = ( ( frame0 + 1 ) % num_frames ) * this->channel_count() + channel;
			return ( T(1) - pos ) * data[ ofs0 ] + pos * data[ ofs1 ];
		}
Exemplo n.º 8
0
		T get_value( index_t frame, index_t channel ) {
			flut_assert( frame >= frame_count() - num_frames && frame < frame_count() && channel < this->channel_count() );
			return data[ ( frame % num_frames ) * this->channel_count() + channel ];
		}
Exemplo n.º 9
0
		const T* get_frame( index_t frame ) {
			flut_assert( frame >= frame_count() - num_frames && frame < frame_count() );
			return data[ ( frame % num_frames ) * this->channel_count() ];
		}