Ejemplo n.º 1
0
Ant::Ant(QPointF center, float scale, float direction, QObject *parent):
    QObject(parent)
{    
    _center = center;
    _scale = scale;
    _direction = direction;
    _baseShape = baseShape();
    setupShape();
}
Ejemplo n.º 2
0
Laser::Laser(const glm::vec2& position, float angleDegs, LaserType type)
	: m_StartPosition(position)
	, m_Angle(angleDegs)
	, m_Type(type)
	, SPEED(Game::HEIGHT / 1000.f)
{
	setVelocity();
	setupSprite();
	setupShape();
}
Ejemplo n.º 3
0
Asteroid::Asteroid()
    : m_StartPosition(getRandomPosition())
    , m_Velocity(getRandomVelocity())
    , m_RotationSpeed(getRandomRotationSpeed())
    , m_Speed(getRandomSpeed())
    , m_Type(getRandomType())
    , m_HasBeenStruck(false)
{
    setupSprite();
    setupShape();
}
Ejemplo n.º 4
0
Asteroid::Asteroid(const glm::vec2& position, AsteroidType::Type type)
    : m_StartPosition(position)
    , m_Velocity(getRandomVelocity() * SUB_ASTEROID_VELOCITY_FACTOR)
    , m_RotationSpeed(getRandomRotationSpeed() * SUB_ASTEROID_ROTATION_SPEED_FACTOR)
    , m_Speed(getRandomSpeed() * SUB_ASTEROID_SPEED_FACTOR)
    , m_Type(type)
    , m_HasBeenStruck(false)
{
    setupSprite();
    setupShape();
}
Ejemplo n.º 5
0
Powerup::Powerup(const glm::vec2& position, const glm::vec2& velocity, PowerupType::Type type)
	: m_StartPosition(position)
	, m_Velocity(velocity)
	, m_Type(type)
{
	std::vector<float> rotationDirections = { -1.f, 1.f };
	m_RotationSpeed = Random::genFloat(0.18f, 0.36f) * Random::choice(rotationDirections);

	setupSprite();
	setupShape();
}
Ejemplo n.º 6
0
Archivo: Svg.cpp Proyecto: cviejo/mPD
void Svg::setupDiagram(struct svgtiny_diagram * diagram){

	width = diagram->width;
	height = diagram->height;

	paths.clear();

	for(int i = 0; i < (int)diagram->shape_count; i++){
		if(diagram->shape[i].path){
			paths.push_back(ofPath());
			setupShape(&diagram->shape[i],paths.back());
		}else if(diagram->shape[i].text){
			ofLogWarning("Svg") << "setupDiagram(): text: not implemented yet";
		}
	}
}
Ejemplo n.º 7
0
// slots
void Ant::onPositionChanged(QPointF center, QPointF vector)
{       
    _center = center;    

    float x = vector.x();
    float y = vector.y();

    float angleInTriangle = qAtan(y / x);
    float angleInRad = 0;
    if (x >= 0 && y >= 0) {
        angleInRad = angleInTriangle;
    } else if (x < 0 && y >= 0) {
        angleInRad = M_PI + angleInTriangle;
    } else if (x < 0 && y < 0) {
        angleInRad = M_PI + angleInTriangle;
    } else if (x >= 0 && y < 0) {
        angleInRad = angleInTriangle;
    }

    _direction = angleInRad * 180 / M_PI - 90;
    setupShape();

    _mouthPosition = _center + vector * _scale * 1.5;
}