Eyes Align – Devlog 1

When making a futuristic game about space, you can’t just have aliens, fancy weapons and spaceships, but you also need cool sound effects to help your high-tech world come to life. And for this devlog I’m going to show how simple it is to design a laser blast from a space gun using a synthesizer.

The laser blast effect I made for our game Eyes Align, I used Native Instruments’ VST plug in FM8 as it handles frequency modulation very well and also has a bold mid-range that I’m looking for.

By analyzing the sound of common laser gun sounds(like the ones from Star Wars) I could hear that they use a simple waveform with a fast envelope modulator controlling the pitch. Here is one pitch modulation that I used in one of the shots.

2

As you cant see, it has a peak going from low, to high, and to low again under a millisecond and produces a quick percussion like transient. After that a hard curve gives the pitch-bend that is the body of the sound. But the pitch modulation alone isn’t good enough, as it leaves a low pitch hum when a note is held down. To fix this, another envelope with a fast release is added to control the volume.

1

To give the sound additional texture, the same envelope curve can control the noise filer’s amplification when the wave is routed through the x operator in FM8.

The raw sound can sound very dry, and depending on the environment additional effects can be applied like phasers, ring-modulators, reverbs, etc. The environment in our game reflects sounds, so a reverb filter was added to make it sound natural. 

(I would attach one of the sounds I made, but you need premium to add sound files to blog posts.)

Eyes Align – Devlog 1

Space Giraffa – Update 6

During this week I have made a checkpoint manager class and checkpoint objects. When the player finish an enemy wave a checkpoint appears from the right side on the screen and drift past the player. When the player see this checkpoint (that will look like a bear holding a sign) they’ll know that they can jump to this point in the game through the level select screen.

I made some changes in the enemy manager class so that any observing instance can change the level file during run-time, hence made it possible to jump to any enemy wave. Previously we had every enemy wave stored in one level file. But had to change it because it is much easier to start at a specific wave when using separate files than looking for a position in one file

So this is how it’s supposed to work: When there are no alive enemies left from one file, the checkpoint manager spawn a checkpoint. When the player avatar passes the checkpoint it disappears and the next level file is loaded. This happens until the last wave and the last checkpoint triggers the enemy manager to spawn the boss. When the boss is defeated one last call to the checkpoint manager is done and the game state proceeds to the victory screen.

checkddd

I don’t actually know if it work because I have just implemented it. But according to my calculations it should work. Maybe. There is some features that my version of the source code do not have and I have to implement it until I can make sure my checkpoint feature work like it should.

Since this is the last day our group can work on the project, I have been working hard on getting the last things that was left implemented. One of them was cave obstacle that would act as a tutorial region. Because the cave walls only bounces the player back, its only purpose is to teach the player about collision and how big the collision box is. By doing it this way the player don’t have to figure it out by colliding with the enemies later in the game.

After the player have passed the cave obstacle, it will also get a checkpoint so the player don’t have to player it again.

I’m going to get back to my coding so, have a good one ♥!

Space Giraffa – Update 6

Space Giraffa – Update 5

Other than recovering from Monday’s beta presentation, this week has been pretty mild. I have chosen some easier tasks to complete for this scrum session. One of them was a High score system that can add entries and sort them with the previous score entries which are loaded from a save file.

First of all, I created a struct called “Entry” that contains an integer and a string data type. The integer stores the users’ score and the string stores the name associated with that score. This makes it easier to keep track of the name while sorting the scores. By including the “algorithm” header I have access to the sort function. Algorithm’s sort function can sort a vector array by comparing any value from two elements using a self defined binary function. Something like this:

struct SortFunction {

          bool operator() (int I, int J) { return (I < J); }

};

The function don’t have to be imbedded in a struct.

The class’ constructor opens a text file and imports every previous score and its name and adds it to a vector array. Later when a user wants to submit their score to the high score table a function will do that for them.

This function first checks whether the user’s name already exists somewhere on the high score table.

If they do, the entry’s score is changed. But is it doesn’t exist, a new entry is created containing the score and the user’s name and placed in the vector array.

When that is done the array is sorted using a special binary function that compares two entry objects by their integer value.

bubbl

The score system class can also retrieve names and scores from a desired place in the array. This feature is only going to be used when drawing the score board.

Our game’s main protagonist “Giraffa” has felt very stiff when flying around in space. We wanted to add something more to the player avatar to make it feel more dynamic. The biggest request has been to make the giraffe’s legs flail as the she moves. This will add to a more comic aesthetic to the player avatar. I am currently working on this visual feature and have written down some pseudo code to help me find a good solution. I’ll either simulate some simple rope physics or just rotate the lags by the amount of horizontal speed but this is one of the things I link with programming.

Now I have to get back to my coding, so have a good one!

Space Giraffa – Update 5

Code review of Mermaid River

In the game Mermaid River the class called “Captain” is represented as the playable avatar in the game. An object pointer of captain is stored as a private member in a derived class called “GameState”. When the game state’s “Enter” function is executed, the captain gets a struct filled with pointers to different objects like draw manager, state manager, mouse, etc. But all of the instances weren’t used like the state manager. They could have send only the useful modules to captain instead.

The captain object is updated inside an if statement when game state is updated. But captain’s update function takes a copy of a harpoon object which is provided by game state by dereferencing a harpoon pointer. But this copy only serves a small purpose inside the function by telling its windup time to the captain. This copying could be avoided by only sending that necessary value to the captain directly. But if they need more data from harpoon, captain could instead take a const(for safety) reference. The harpoon class is pretty big and has a lot of variables that needs to be copied and less RAM is used when passing a reference through a parameter.

Very quick recap:

The player object aka Captain has a very loose coupling but it also has some unused instances lying around. The latter is not a big deal.

~Adrian Lavrell

Code review of Mermaid River

Space Giraffa – Update 4

This week I’ve been working hard on the beta stage on our group’s game Space Giraffa. There have been many late nights of hard labor. If it wasn’t for our unfortunate code mishap, and had to rebuild much of our code, we wouldn’t have to stress in order to get everything implemented till dead-line. But as long as we don’t encounter any problems with our current code structure we might have a chance to get everything done. Yay? Otherwise we have to be satisfied with only the vital features.

But at least one good thing happened this week. I was done with all my work from our groups sprint planning so I took about an hour and a half and built an easy level maker for our game. We use text files to store every level and it was difficult to add enemies to file. Not only was it hard but we programmers only knew how to make one. And because we programmers have to work on the game, and the graphic artists did not have much to do, my conclusion was to assign that work for them. Which is now made possible with my “level-creating-tool”.

Level_ede

This is how my level maker looks like. The enemies are represented as colorful dots that stores information in them. Information like velocity and position. The user can move each of the sliders to adjust the horizontal and vertical movement of an entity. That black area is a smaller version of the game window and every entity’s position gets scaled to fit inside the tool’s smaller window. When the user decides to save a level to be used in the game, the tool internally calculates where each entity should be positioned on the screen.

The “Edit Button” gives the user the ability to move and replace an entity with the mouse without creating a new entity. When edit mode is turned off, the mouse can only add and delete entities.

Because we programmers have to focus on getting every feature implemented, I created this tool to make it easier for the graphic artists to help out with level design. It also makes the process A LOT quicker.

That was every thing from me and now I have to get back to programming again so may the force be with you!

Space Giraffa – Update 4

Space Giraffa – Update 3

This week I’ve been working on our beta project and implemented some features to make more visuals appear on the screen. We basically scrapped our alpha project and started from scratch with the beta. We had to do this because our alpha project was using pure OpenGL render calls and our programming teacher was not happy with that. This puts us programmers way behind schedule and the deadline for the beta is creeping up on us. So I have been hard at work with the game and tried to reuse as much old code as possible.

One of the new visual features is sprite animation. SFML already supports a good sprite class UV coordinates and transformations of any kind, but it lacks the feature to be animated. There are lots of different ways to create sprite animation, the simpler the better. The principles of sprite animation is to cycle with a desirable speed.

I wrapped some SFML objects together with some variables inside a class I called “Animation”. This class now contains SFML sprite and a rectangle from SFML which will be the sprites texture region. I assign a couple of member variables to store time, speed, and max frames.

The first function in the animation class in “init”. Init is called after an object of Animation is created and takes in four parameters; max frames, cycle speed, width, and height. Width, height, and max frames a self explanatory but cycle speed is a bit ambiguous. The cycle speed is how fast a frame changes to the next frame.

Every sprite animation have to be updated too. The update function is very simple. The timer is added with the frame speed, multiplied with the games delta time to make the animation run smoothly. Then an if statement checks if time is larger than max frames and if true, max frames is subtracted from timer to make the animation loop. The texture regions x axis is then set to the rounded value of timer multiplied with the sprites width.
spr_rocket

This is our rocket sprite made by the graphics team that demonstrates how each frame has to be aligned to work. One frame has the size 128 pixels and the texture in total has 256. When the timer reach one, the region is moved 128 pixels to the left. It repeats until it reaches the last frame where it is placed at the start again.

rocket_animation

This is how it looks in motion.

Space Giraffa – Update 3

Flight of the Giraffa – Update 2

This week I’ve created Button class for our GUI. The button class works just like a collision box with a state. The state is either “pressed” or “not pressed” and is determent whether a mouse button is pressed and also if the mouse’s position is inside its bounds. This is what happens inside the function “SetPressed”.

The statement can later be retrieved from a “IsPressed” function. The Second half of button, is the Reset function. It will reset the state from true to false, but if the button was previously pressed (and is still within its bounds) it will return true, and false if it was not. With this feature I can check if the user releases their mouse button. This will make clicking button feel like they were actually clicked and would allow the player to avert the cursor if they regret pressing a button.

During run-time a button object would work like this: If a mouse press statement is true the set pressed function checks if the cursor is inside its bounding box. If that statement is true it will set the state to true (pressed) and will continue to be so until reset is called. Now draw functions can check this value and make the button appear different while pressed. Now reset is called and the state is set to false again. If I place reset in an if statement, I could execute a function whenever that statement id fulfilled(released).

When working with the Scorched Earth clone I did not want to be restricted to a specific button size. So I used a method called “9-Slice Scaling”, which means that a button sprite is separated into 9 parts. Like this image shows:

9-slice-scale

A, C, G, and I are placed according to specified dimension. D is aligned to A and stretched vertically to reach G. The same goes for F but from C to I. B and H is stretched horizontally. To fill the gap E is aligned with A and stretched both vertically and horizontally to I. I implemented this in our game so we could have dynamically sized buttons with rounded edges or beveled texture.

Flight of the Giraffa – Update 2

Flight of the Giraffa – Update 1

This week I have created classes to manage entities in our game “Flight of the Giraffa”, which is group 9’s project for Game Design II. Flight of the Giraffe is a 2D, side scrolling space shooter with a bullet-hell theme, where you play as a giraffe dodging bullets in space.

To manage every object appearing on screen, I have managers for every type of entity in our game. The manager will keep track of a certain type of entity and update it, draw it on the screen, and later destroy it when finished. Important functions like collision will also be checked in this class by testing one entity with every element stored in the manager.

I do collision checking using Separate Axis Theorem with two shape objects stored in a base class every entity inherits from. Right now it can only check for overlap between two convex polygons but collision with circles will be implemented.

By keeping every entity type separate, collision check is much more efficient. When having every entity type stored in a single manager the collision will be troublesome because when I want to check collision between every player bullet and every enemy, I’d have to iterate through the whole list again and bypass every entity that is not an enemy. Another problem would be when I want to check collision between the player and a power up and the manager contains another 1000 elements of enemy bullet. Then the program have to iterate a 1000 times more instead of only one.

Later I will give each entity manager its own vertex array and run it through a shader program. With this shader I can tint sprites or make them glow if that would be necessary.

In Flight of the Giraffa, there is a power up that clears the screen on enemy bullets. This feature is a 100 timer easier when having a separate list for enemy projectiles.

My first attempt for a separate entity manager was to use a generic class using templates. This manager does not depend on the data type and only focuses on storing, updating, and drawing elements in a vector array. The problem with this approach that every entity have different needs and behaviors, and most problems occurred in the realm of collision detection.

Most of the problems using a generic manager could be solved by using a more complex structure. But I see no reason to over complicate my code when everything works just fine with multiple entity managers.

Flight of the Giraffa – Update 1