Team 12 report 4 – Angular object placement
|
Hello everybody! This week has been quite rough and the task I was presented with was a real challenge. This week I tackled object placement in our 2D sidescroller. The objects in our game should be placed dynamically to fit into the levels we create. The levels will not only be on a horizontal axis, they will angle down and up to create a better gameplay experience. This was a very challenging task and down below I will describe what I have made, how I made it and why I made it. Why our game needed a dynamic object placement: The game will as above stated feature angled backgrounds and segments that will go up and down. To get all of the objects placed in a good fashion without ”hardcoding” their placement a system will be needed to find out where the objects should be placed within the level. So what is this that I have made? I made this system that reads the backgrounds orientation, placement and angle in order to place out the objects and obstacles in our game in the right X and Y coordinates. Here is the interesting part and where most of the blogs content will be. How I made the system and how it works on a more technical level. I will try to describe it as down to earth as I can but it is not a simple system and to be honest I don not understand it myself 100%, I just know in theory how it works. The backgrounds are the key to this system. Marwan Al Salman in my group made the background change their position and angel using the law of cosinus. This made it so that the backgrounds where placed ontop of each other while overlapping to create a fluent level. The system I made was an extension to his system and builds ontop of his code. What it does is that it has functions that gets the backgrounds angels from the backgrounds while also taking the top left position of the background. When the functions have taken these variables I place out the objects on the top left corner of the backgrounds, after that I get the angel from the background and use it in a function which uses the law of cosinus to calculate how much the X and Y values of the objects are going to change. In practice this creates a line where all of the objects spawn. If my explanation of the object placement system was unclear I hope this awsome paint picture can do some talking and give a visual representation of how it works. |
