zoza.blogg.se

Chains Box2D

Publicerad 2014-02-10 03:08:58 i Allmänt,

Alright, I managed to get Box2D to work with SFML. With some help i also got gravity to work and after that collision with a rectangle.  The reason why I chose rectangle was that it was the easiest way to see that Box2D really worked for us as we only knew that some functions such as create a body and gravity(which we dont even need in our game). The main thing we wanted Box2D was collision, so that we could create fully functional rooms that weren't made up of squares so that we could get the rooms to look like we wanted them. After that I amde so that you were able to walk with the player instead of just being pulled down by gravity as i felt that it was something that needed to be done anyway and that it was easier to check the collision if you can check from different angles.
 
It was pretty simple to make the player to walk in all the directions but to make it stop was another thing. SFML already have a simple way to make an object move, so all i had to do was to add the position to the body of Box2D istead of the player from SFML. What SFML does not have thoguh is a Keypressedonce function and when i looked after an alternativ solution I found out that Events apparently was not fit to use when moving cuz it was not smooth enough. I figured that out by just placing a if else under that If:s that was making the player able to move.
Until this point the caracter was only able to move in straight lines and not diagonally and I struggled a while to make this happen. I got help from a friend to make this happen and the solution was not too complex this time either.
 
After that was done the chains that I suggested we would use was the next step. They are points which are connected to each other with a vector, with connected I mean that they create a wall between them. So they are very effiecient to use to make boundries in a top down game from what I have seen so far. The only problem is that its some work to get there. We were probably not the quickest in setting the whole thing up. But there were many problems with different releases for both sfml and box2d that made it quite difficult to make it work. We will have a sprint meeting tomorrow to see what the next tasks are. But i think it is something along the lines to make enemies and AI to enemies, make the camera move and make the player able to shoot. After that except from stating win/lose conditions and make the time and helth we have a fully functional game. It will not be pretty at that point but it would work and be classified as a game. So I feel confident to make it now. It felt a bit rough when I didnt know if Box2D would work and we faced the option to face that we spent a week to nothing and instead use regular collisions. 
 
I was also working with our last project and it we solved many of the problems we had. We worked on one computer except for when i was playtesting to find bugs. So I did not code much but instead observed what my group partner did as he knows the code best and can bugfix much much much more efficiantly. We still have some stuff left, like some memory leaks, but it should not be any problems to do it.
 
Lastly I wnet through the core of the game that my other group member did so that I am familliar with it. He uses a different structure than the one i previously worked with but it works like that as well.

Kommentarer

Kommentera inlägget här
Publiceras ej

Kategorier

Arkiv

Prenumerera och dela