Collecting a powerup

Checking off my list of vital features before an alpha test release, today I implemented a system for keeping track of which collectible items (upgrades and the like) are still available to collect. And I implemented collecting one of them, the propulsion wheel:

I’m not quite happy with the collection announcement yet — I think it needs a little more tweaking before I’m done with it.

For you aspiring game developers reading this and wondering how I got the 2-d sprite to appear to rotate about the y-axis, it’s pretty simple. Like most tricks of this nature, it just involves a little trigonometry:

bool reversed = _rotationTimer > RotationTimeMs / 4 && _rotationTimer < 3 * RotationTimeMs / 4;
Vector2 scale = new Vector2((float) Math.Abs(Math.Cos(_rotationTimer / RotationTimeMs * Math.PI * 2)), 1f);
spriteBatch.Draw(texture, displayPosition, null, Player.Instance.Color, 0f, origin, scale,
                 reversed ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0);

Basically I'm periodically shrinking the image down in the X dimension, then bringing it back to full size, while also flipping the image horizontally for half of the rotation. The trig functions make it look like it's actually smoothly rotating because the unit circle yo.

Tomorrow I've decided to tackle drawing the sprite sheets for the surface of the planet. I also think I might need to shift the entire Tiled map over and down some... all the layers of it. Hopefully that's not such a horrible task as to require me to write a program to do so.

2 thoughts on “Collecting a powerup

  1. Looks good, however I don’t think the collection OSD should hide your character and the item. Moments like these should be extremely satisfying and special for the player (think original Metroid or original Legend of Zelda).

    I’d freeze the action at the moment of collection, play a short jingle unique to collection, then resume gameplay once the jingle ends. Once gameplay has resumed you could show the OSD at the bottom of the screen for five seconds.

    With respect to the jingle you’ll want to make it as impactful as possible. Again think of the item collection sound in Metroid and LoZ, or even the level-up sound in the original Dragon Quest/Warrior for NES (simple, but highly cherished).


    I’ve been doing a lot of sound effect work in my game lately, and the difference between a silent game and one rich with sounds is incalculable. Never to early to start, and hard to stop once you do. Anyway, great work on the game.

Leave a Reply to zachm Cancel reply

Your email address will not be published. Required fields are marked *