Blog week 2 – Alot
|
So this last week has been really busy with programming, especially this thursday. Everything that should have been done for the alpha has been done, and not only that. All the code has been improved, I myself has learned the SFML library better, and now its a bit more object oriented in the code so its not just a big cluster of code. However, the most interesting thing I’ve done this week is probably the diffrent arrays of each entity, so i could create infinite new sprites. (no not infinite, but you get the point!) So I started to create all the difrent classes of the difrent entities i where having in the main file, becuase without it I cant really think of a way of creating new things while running the code. I long thought of a way to do this, and i tried to look at the code Jerry gave us with the SDL_Arkanoid, since its a pretty basic code it could probably fit inside my code aswell. however many trials, errors and crashes later i gave up on that. So i started to look on the internet, and i stumbled across some code wich would do the somewhat the same thing i wanted to do. So i tried to reforge the code so it would fit in to my code and try it out, to my suprice it worked! Immediately I started to use this with my difrent classes, and to my suprice wich worked out better than i expected. I made it so when i created a sprite while running the code, it would give it a Rect wich would later be turned in to a hitbox, animations for the sprites and a update command wich would move and cycle through the frames. And also with this I used an iterator to get to the diffrent objects. You could spawn arrows, enemies and powerups and many of them! Just with a command, every object to it has nothing to do with the one before, its animation is on another frame, it does its own thing just as i wanted! now it was only simple rinse and repeat for the other classes. It all went well untill i came to the powerup class, they are all pretty similar right now so there isnt that much difference between them, but when i started drawing out the powerups with the iterator. I probably sat with the same problem for half an hour trying to figure out it, i compared the 2 classes to eachother, not a single problem. Tried most of the stuff just to make it work. No error or anything since it wasnt faulty code the program where running. But after a while i found it, one simple counter, all it took. and then the program was running just fine! |
