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!Blog picture 2

Blog week 2 – Alot

En reaktion på ”Blog week 2 – Alot

  1. Hej Christoffer!
    Det är roligt att höra att projektet går åt rätt riktning och att du känner dig mera bekväm med SFML:s API. Efter att ha läst andra stycket så förstår jag att du har lagt mycket tid på att omstrukturera programmet den senaste veckan. Vissa saker som du kunde ha gått in i mera detalj är andra egenskaper dina ”entities” har, så som om den kan kollidera med ”entities”, om/hur den styrs (ai vs io). Så att man får en överblik gällande designen för spelet. Just nu vet man bara att alla ”entities” kommer att ha en grafisk representation. I andra stycket får man veta att du har försökt att slå ihop kod från två projekt men inte exakt vilka delar. Då jag har läst samma kurs så kan jag göra ett antagande att det är IEntity klassen, men du för gärna också gå in i detalj vad det är för problem, eventuella lösningar och varför du gav upp. I fjärde stycket så använder du ordet ”reforge”, men jag tror att ”refactor” skulle passa in bättre i denna kontext. Du nämner även att du använder en iterator men jag är osäker om du använder ”den” till något annat än att rendera dina ”entities” och/eller updatera dem. I sista stycket skriver du ”just with a command…”, betyder detta att du använder dig av ”factory pattern”, något liknande designmönster eller något helt annat? Sedan när du avslutar inlägget så nämner ”one simple counter”, jag har tyvärr ingen aning om vad problemet är här och varför din lösning hjälper.

    Gilla

Lämna en kommentar