tisdag 10 december 2019

Jumping & Bugfixes

I modified Brackeys code for moving. I made it possible to jump when standing on another character. This was done by checking multiple raycasts under the play, if a collision with another player is close enough, a bool will tell the game that the player is standing "on solid ground". Before this a more simpler check worked fairly well, with only 1 ray. However, as other team members modified the sizes of the playable characters, there was a period when it wasn't possible to jump while standing on another character. I feel that this is a design flaw in the code or Unity. Solid code should be able to handle these kinds of changes in my opinion.

I also from time to time tested the game. If I found too obvious bugs, like a bullet colliding with the water, I fixed it. I also made it so that bullets always gets destroyed if they fly out of the map. In the image below it is shown that the spells are being shot at the wrong layer, causing them to collide with the water (or lava).




Game Code

I created the MainScript.cs and Model.cs, among other things. MainScript is our games "main"-method. Funnily enough, we use its looping Update and FixedUpdate to loop the game logic. Model.cs is a more condensed class with the core game logic defined in it. The name is inspired from the design pattern called Model-View-Controller. The idea with this pattern is to handle all of the core logic separately, in order to make it easier by having less coupling in the code.

I also create some other separate functions for aiming and moving. In regards of moving I first wanted to make it from scratch, but in order to speed things up I made use of Unity's pre-defined moving controllers. As an extra help I used some code from "Brackeys", a famous tutorial persona on YouTube. I also viewed one of his videos when I was creating colliders for characters.

I created Unit.cs, which can be used as a base for any kind of unit in the game. In this case, we never made a player class that inherits from Unit, but instead just used the Unit class directly for the players.

When a player aims, an ellipse, or circle is drawn around the player. This was done by using straight lines fom Unity's Linerenderer. How can lines be used to draw circles? Well, I created many points in a diamond shape around the player. Then, if I recall correctly, I projected each of these points to the closest position on the ellipse around the player using this formula from StackOverflow: https://math.stackexchange.com/questions/22064/calculating-a-point-that-lies-on-an-ellipse-given-an-angle/22067#22067

This gives an acceptable ellipse, but I think if done in a better way, the points could be distributed more evenly accross the elipse. After projecting the points, I used them to draw lines.

In a similar fashion I made use of the mathematical to position an arrow for aiming.

Menu

I made the first version of the menu, with not so great art. The sprites for the UI was switched but most, if not all, of the functionality remained unchanged. I wanted it to be possible to select your own user name. To eachieve this, I just added a class called "IOstuff". This is responsible for checking if a saved file exists and if so return previously defined user-names. IOstuff saved the setting that is entered in the menu. The saved files are then reloaded when the game starts, in order to transfer data between scenes. At first I was thinking of using static variables for this instead, but it turned out to be so much easier to read and write to files instead. If a read or write fails, an object is returned anyways with some standard data. Therefore, the game is less prone to crashing.

GitHub

In the following image, some contributions can be seen to the project, where I am "marcus1337".



As it can be seen, most of my code went into the beginning of the project. My code was more or less the foundation for how the rest of the code would be added. The cause for lisandlops large jump by the end is because a large amount of sound files were added and removed. I can't see, oddly enough, a graph representing Diego, but he added many spells.



Generally, it becomes harder to add more content into the project at a later stage, than in the beginning. The reason is because you have to take into account that more and more becomes spaghetti. With proper planning this is avoidable to some extent. In this project however, there was not enough communication to keep the codebase at a high quality, so if I were to make a another game alone, I would probably not want to reuse all of the code used in this project.



Writing GDD

I did not do much the night before the hand in of the GDD, so if there are minor changes to my text, it could be explained from that. I was responsible for writing the chapter 2-4, which I also did. Later on, I saw that no one had wrote anything for chapter 1, so I wrote that as well. I think Daniel added one image to that chapter by the end.

We used a skeleton of pre-defined chapter headers. The document was created via Overleaf, where you always use LaTex.

As an extra precaution, I downloaded everything written on LaTex the morning of the deadline day. Then I ran the text in Microsoft Word in order to find primarily grammatical errors. I also found and took use of some text change suggestions from Word. I feel that this was important as there were many, many spelling and grammatical errors overall. I strongly believe that its important to read everything you write several times. Sometimes for non native English speakers that is not enough, as it can be hard to use flawless grammar. Therefore, tools like Microsoft Word is of big help.

For some topics for the GDD, I was not fully aware on what I should write. So, I researched online about my given areas. This gave me inspiration as for what content I could put into the GDD. In total I used up at least 16 pages.


Making videos

I made two videos, where of one was saved to the GDD. To create these I used Windows Movie Maker. Movie maker have the restriction that you can only add one extra sound per video. So in the final video I saved the video 3 times and reused it in video maker to add 3 different sounds. Now after, I realize that I could have added them separately in Audacity instead. Anyways, in this blog I will show the videos that I made.

The primary reason as for I made a second video, is that a group member wanted to have certain updates featured in the video.






söndag 17 november 2019

Differentiate from Worms

From the feedback on our presentation, some suggested to make the land more realistic. Such that if you destroy the foundation of the ground, it can collapse. We have two different concept videos for how we may implement this as a group:





I think the fact that the ground can explode or collapse is a good path to differentiate from worms. I am also considering if you should add AI units.

Adding Visuals


At the moment, the game looks pretty much exactly as it is shown in the video clip. Since a lot of different things have been added, it would be difficult to mention them all in a summarized form. Hence, I will provide a shortlist of things that have been added so far by me:

Shooting, two players, countdown timer, movement, raycasts to avoid players moving each others, number above players showing HP, detect when players or projectiles fly out of the map, handling of turn events (can be improved), elipse around players when aiming (not a great visual, but helps in debugging), added so the players can jump while on top of eachother (before it was only possible when standing on the ground), a "Game Over" UI is shown when someone wins or both dies.

A great feature, that is mandatory for any Worms-like game is map destruction, I did not add this but another team member is working on it quite successfully as shown in the video. Also other members are working on a website, sound effects and adding different types of spells.

Combining the logic

Screenshot of gameplay

A lot of things are coming togheter now. When I started writing this blog post the art was mostly just squares and the background black like in this image. The idéa was originally to have the game be more or less exactly like Worms. However, we later decided to let the players jump in any direction and also possibly change walking direction while in air.

The timer has also been added. A boolean checks if the turn is over, and if so the game switches who plays. A bug exists if that a spell splits into other spells there is a short context switch, so the game will switch turn while the splitted spell projectiles still fly. This could be fixed in a lot of different ways but it's not entirely clear which way is the best. One way is to just add a delay before truly ending the turn and check if there still are any projectiles in the air. While this could work, I personally don't like having a constant time always being added if there could exist a better way.

There was a problem that has been fixed now. The issue was that the aim is supposed to be in a oval shape around the player objects, if the shape isn't a square. So initially we used a unit circle for aiming towards the mouse pointer, however this clearly don't work as it should as seen in one of the images due to the aim being an elipse.

To solve the problem I searched the internet via Google, especially for StackOverflow posts. On StackOverflow I found a good post about how to have a point go along an elipse by using a quite sophisticated equation, shown in this link: https://math.stackexchange.com/questions/22064/calculating-a-point-that-lies-on-an-ellipse-given-an-angle/22067#22067

This worked exactly like I wanted if I also multiplied by 2 after following the equation. I am not entirely sure why I needed to multiply by 2, but my assumption is that otherwise it's just the arrow tip that collides with the elipse, but I wanted the arrow to point out from the edges.

fredag 1 november 2019

Starting out

The group has agreed on a game concept. I came up with the idéa for what game we should try to create. It was the only idéa that was suggested however. The impression I get is that it will be possible to complete the main concept within the short time limit this project has been given.

What we have done is setting up the environment. We chose to develop for computers using the Unity engine. The game will be able to run cross-platform on Windows, Mac and Linux.

The plan is to create a game similar to Worms, or a no longer existing game that was called "Arcanists". The game will be turn-based and allow for two or more human players. The goal is to destroy one another by casting one spell per turn. Each turn have a time limit. The game itself is very easy to create, but we all worry about the novelty aspect of the game. Because of that worry we have decided to change some game mechanics in order to make the game less similar to the other mentioned games above.