ARTIFACT BLOG #5 COLLECTIBLES

Stars!

This week all three of us sat down and did our tasks together, so that we wouldn’t have someone get stuck on a task just before beta. One of the things we’ve done is collecting stars when enemies dies. You collect the stars to get a better score.

The stars themselves work almost exactly like the enemy bullets, only they get added when the enemy’s life has hit zero rather than when they’re in attack range of the player.

When the star is added, and the player isn’t close enough to collect, they get a velocity to spread out. To make the stars not fly off the screen we multiply the function to get the velocity with a float that decreases over time. As to not make the stars all pile up in one place, we define the position in the constructor as “setRotation(rand() % 360);”, and then set the rotation to rotate in relevance to the player’s position. The rand function makes the stars, for the most part, spread out in a circle around the enemy’s position where it died.

To then gather the stars we used the same velocity/rotation that the enemies and bullets use to know where the player is and move towards it’s direction, only the stars have the velocity and rotation in it’s update instead of it’s constructor. So they work as a homing missile when the player is close enough. We then use our overlap function to delete the stars when they reach the player’s position.  Currently we don’t count the stars collected, but it’s something to be made tonight (beta’s tomorrow).

collectstars 

As for the overlap, we’ve remade the previous one. The first one we made only checked the overlap between the player bullets and one of the enemies, but with another enemy and enemy bullets we decided to make it anew. All of the beforementioned objects are so called game objects, and the game objects inherit SceneNode’s functions. In Gameobject.cpp we have an overlap function (bool GameObject::Overlap(sf::Vector2f position, float p_fRadius)) so we can check the overlap between any game objects. If the overlap is true an object either loses a life or gets deleted immediately (bullets/stars).

It’s currently 22:32 on thursday and right now we’re sitting with the HUD (Life/Stars) as well as the winning and losing state. It’s gonna be a fun (?) night. We’ve also, finally, changed the second enemy’s textures so it doesn’t look like a melee enemy punching bullets out of thin air. The animations were finished quite a while ago, but we just never took the time to implement them. It looks quite badass now!

morkerbadass

Leave a comment