示例#1
0
int
MMain(int argc, char *argv[])
{
    MMUNUSED(argc);
    MMUNUSED(argv);

    tileset_fixed_test();

    return(TEST_EXITCODE);
}
示例#2
0
int
MMain(int argc, char *argv[])
{
	MMUNUSED(argc);
	MMUNUSED(argv);

	shared_basic_test();
	weak_basic_test();

	return(TEST_EXITCODE);
}
bool
BounceColliderComponent::collision(ColliderComponent &c, float d, const CollisionData &data)
{
	MMUNUSED(c);
	MMUNUSED(d);
	MMUNUSED(data);

	const Math::Vector2 &l_vel = movement()->velocity();
	const float l_mag = l_vel.magnitude();
	const Math::Vector2 l_normal = l_vel.normalized(l_mag);
	Math::Vector2 l_pvel = (l_normal * (2.f * l_normal.dot(l_vel * -1.f)) + l_vel);
	movement()->velocity() = l_pvel.normalize(l_pvel.magnitude()) * l_mag;

	return(true);
}
示例#4
0
bool
TilesetBase::deserialize(XMLElement &n)
{
	MMUNUSED(n);
	/* TODO: Implement */
	return(false);
}
示例#5
0
MARSHMALLOW_NAMESPACE_USE

static void
SignalHandler(int signal, siginfo_t *siginfo, void *context)
{
	MMUNUSED(signal);
	MMUNUSED(siginfo);
	MMUNUSED(context);

	if (!Event::EventManager::Instance()) {
		MMERROR("\n*** Unix system signal received. But can't queueing quit event message yet... Ignoring. ***\n");
		return;
	}

	MMDEBUG("\n*** Unix system signal received. Queueing quit event message. ***\n");
	Event::SharedEvent l_event = new Event::QuitEvent;
	Event::EventManager::Instance()->queue(l_event);
}
示例#6
0
PCM::Handle *
PCM::Open(uint32_t sample_rate, uint8_t bit_depth, uint8_t channels)
{
	MMUNUSED(sample_rate);

	PCM::Handle *l_handle(new Handle);

	l_handle->buffer_size = (sample_rate/MARSHMALLOW_ENGINE_FRAMERATE) * (bit_depth/8) * channels;
	l_handle->buffer = new char[l_handle->buffer_size];

	MMDEBUG("Dummy PCM device opened.");

	return(l_handle);
}
bool
PlayerColliderComponent::collision(ColliderComponent &c, float d,
                                   const Game::CollisionData &data)
{
	MMUNUSED(d);

	if (!movement()) return(false);

	const Math::Vector2 norm =
	    movement()->velocity().
	        normalized(movement()->velocity().magnitude());

	if (c.id().str() == "platform") {
		if (data.rect.left  < 1 && norm.x > 0) {
			position()->position().x =
				c.position()->position().x -
				    (c.size()->size().width / 2.f + size()->size().width / 2.f);
			movement()->velocity().x *= -0.4f;
		}
		else if (data.rect.right < 1 && norm.x < 0) {
			position()->position().x =
				c.position()->position().x +
				    (c.size()->size().width / 2.f + size()->size().width / 2.f);
			movement()->velocity().x *= -0.4f;
		}
		else if (data.rect.top < 1 && norm.y < 0) {
			position()->position().y =
				c.position()->position().y +
				    (c.size()->size().height / 2.f + size()->size().height / 2.f);
			m_platform = true;
			movement()->velocity().y = 0;
		}
		else if (data.rect.bottom < 1 && norm.y > 0) {
			position()->position().y =
				c.position()->position().y -
				    (c.size()->size().height / 2.f + size()->size().height / 2.f);
			movement()->velocity().y *= -0.4f;
		}
	}
	else if (c.id().str() == "bounce") {
		if (data.rect.top < 1 && norm.y < 0) {
			movement()->velocity().y = 900.f;
		}
	}
	return(true);
}
示例#8
0
void
Backend::Tick(float delta)
{
	MMUNUSED(delta);
}
示例#9
0
void
Box2DComponent::update(float d)
{
	MMUNUSED(d);

	if (!m_p->position) {
		m_p->position = entity().getComponentType("Game::PositionComponent").
		    staticCast<PositionComponent>();
	}

	if (!m_p->render) {
		m_p->render = entity().getComponentType("Game::RenderComponent").
		    staticCast<RenderComponent>();
	}

	if (!m_p->init && !m_p->b2layer && m_p->position) {
		WeakSceneLayer l_layer = entity().layer().scene().getLayerType("Game::Box2DSceneLayer");
		m_p->b2layer = l_layer.cast<Box2DSceneLayer>();

		if (!m_p->b2layer) {
			MMWARNING("Box2DComponent used with non Box2D Scene!");
			return;
		}

		b2World &l_world = m_p->b2layer->world();

		/* create box2d body */
		b2BodyDef bodyDef;
		bodyDef.type = static_cast<b2BodyType>(m_p->body_type);
#define DEGREE_TO_RADIAN 0.0174532925f
		if (m_p->render) bodyDef.angle = m_p->render->mesh()->rotation() * DEGREE_TO_RADIAN;
		bodyDef.position.Set
		    (m_p->position->position().x,
		     m_p->position->position().y);
		m_p->body = l_world.CreateBody(&bodyDef);

		/* create shape */
		b2PolygonShape l_dynamicBox;
		l_dynamicBox.SetAsBox(m_p->size.width  / 2.f,
		                      m_p->size.height / 2.f);

		/* create fixture */
		b2FixtureDef l_fixtureDef;
		l_fixtureDef.shape = &l_dynamicBox;
		l_fixtureDef.density = m_p->density;
		l_fixtureDef.friction = m_p->friction;
		m_p->body->CreateFixture(&l_fixtureDef);

		m_p->init = true;
	}

	/* abort if not initialized */
	if (!m_p->init)
		return;

	b2Vec2 l_position = m_p->body->GetPosition();
	float32 l_angle = m_p->body->GetAngle();

	/* entity position */
	m_p->position->position().x = l_position.x;
	m_p->position->position().y = l_position.y;

	/* render mesh rotation */
	if (m_p->render) {
#define RADIAN_TO_DEGREE 57.2957795f
		Graphics::WeakMeshBase l_gbase(m_p->render->mesh().staticCast<Graphics::MeshBase>());
		if (l_gbase) l_gbase->setRotation(fmodf(l_angle * RADIAN_TO_DEGREE, 360.f));
	}
}
示例#10
0
bool
SceneLayerBase::deserialize(XMLElement &n)
{
    MMUNUSED(n);
    return(true);
}