-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbird.cpp
More file actions
47 lines (40 loc) · 1.19 KB
/
bird.cpp
File metadata and controls
47 lines (40 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "bird.h"
Bird::Bird(float x, float y, float radius, QTimer *timer, QPixmap pixmap, b2World *world, QGraphicsScene *scene):GameItem(world)
{
// Set pixmap
g_pixmap.setPixmap(pixmap);
g_pixmap.setTransformOriginPoint(g_pixmap.boundingRect().width()/2,g_pixmap.boundingRect().height()/2);
g_size = QSize(radius*2,radius*2);
// Create Body
b2BodyDef bodydef;
bodydef.type = b2_dynamicBody;
bodydef.bullet = true;
bodydef.position.Set(x,y);
bodydef.userData = this;
g_body = world->CreateBody(&bodydef);
b2CircleShape bodyshape;
bodyshape.m_radius = radius;
b2FixtureDef fixturedef;
fixturedef.shape = &bodyshape;
fixturedef.density = BIRD_DENSITY;
fixturedef.friction = BIRD_FRICTION;
fixturedef.restitution = BIRD_RESTITUTION;
g_body->SetAngularDamping(3);
g_body->CreateFixture(&fixturedef);
// Bound timer
connect(timer, SIGNAL(timeout()), this,SLOT(paint()));
paint();
scene->addItem(&g_pixmap);
life=30000;
shoot = false;
ready = false;
fire = false;
dead = false;
}
void Bird::setLinearVelocity(b2Vec2 velocity)
{
g_body->SetLinearVelocity(velocity);
}
void Bird::Special()
{
}