69
69
//Scene::GetCamera()->position = position;
72
Creature::Creature() : Entity(),
77
sprite = new SpriteAnimation("creature.png", FILTER_NONE, 64, 64);
78
sprite->Add("idle", 0, 0, 0.35f);
83
SetCollider(new RectangleCollider(32, 32));
85
velocity = Vector2::Random() * ACCELERATION;
87
//set aiTime to random so creatures tick at different times
88
aiTime= (float(rand()) / float(RAND_MAX)) * 2.0f;
91
void Creature::Update()
95
aiTime += Monocle::deltaTime;
101
direction = Vector2::zero;
105
direction = Vector2::Random();
113
velocity += direction * ACCELERATION * Monocle::deltaTime;
115
velocity.x = APPROACH(velocity.x, 0, FRICTION * Monocle::deltaTime);
116
velocity.y = APPROACH(velocity.y, 0, FRICTION * Monocle::deltaTime);
121
position.x += velocity.x * Monocle::deltaTime;
122
while (Collide("Solid"))
125
if (velocity.x == 0) { break; }
126
//printf("collision1\n");
127
position.x -= SIGN(velocity.x, 0.1);
129
if (xcol) {velocity.x = 0;}
131
position.y += velocity.y * Monocle::deltaTime;
132
while (Collide("Solid"))
135
if (velocity.y == 0) { break; }
136
//printf("collision2\n");
137
position.y -= SIGN(velocity.y, 0.1);
139
if (ycol) {velocity.y = 0;}
74
144
DarkScene::DarkScene() : Scene()