Blog week 3 – Scrolling map, tiled?

Blog Picture 3
Hello!

Previously in the game we needed a scrolling background, however now we needed to start to actually make the background since it needs to mix up a bit so it would not seem so repetetive, and do other things like having a funktioning paralax, make a more flexible enviorment that could do more instead of just scrolling.

So we started to look at different ways of doing it, we had tiled wich Tommi suggested to us, and then we had the idea of doing everything from within the code just doing an array. However the array way takes longer time while tiled does the exactly same thing and you instantly get a visual feedback on how its going to look.

So we chose the tiled way, after looking at some tips on how tiled worked with the code I tried to figure out a way how to do it, but without any succsess I chose to look at a tutorial. Found a good one that explained it nicely, so i decided to try it out. But once again without any succsess i could not figure out what the program wanted to get it to work, however hope was not gone yet! So i contacted the programming group just to hear if someone got it to work, and i got another tutorial on how to do it. So i followed that tutorial and the same thing happend again, it did not work.

Plan B! Wich I am now currently workign on, so first of all was to create the sprites for it. Since i will be reusing the same squares and just change the texturerect I can easily make it look less repetable, at the same time I also created the sides and it was the same thing there, less repetable. However now i could try to fiddle with the paralax scrolling, all i did was to make the sides that are closer move a bit faster, and it did all the diference.

After that I have not done anymore but I am planning to when we start with the array diffrent sets of tiles will show, and/or maybe a random generated number will decide what to draw on each of the sprites, we have yet to decide that. But with this we can start designing the level for the game. Plannign on making the same way on how enemies should spawn also, its a good but a time consuming way.

Blog week 3 – Scrolling map, tiled?

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

Blog week 1 – Projectile shooting

Blog picture 1

Hi!
The whole prototyping has been rough, not becuase it was hard but more lack of time. And by lack of time i do not mean that we had little time but our group prioritised the wrong thig, since writing everything in main seemed wrong so we started to build an engine.

However we started prototyping and I’ve done so the character can shoot and aim with the mouse, however its a bit strange right now since its flying all over where i do not want it to be. I’ve yet to figure out a good way for the arrow to move exactly thowars the possition of the mouse.

I have a way to calculate the angle that is between the character and the mouse now i only need a way to draw a ”line” and make the arrow move according to it. But right now the arrow flies off somewhere mostly upwards of to the left, however it stays on the screen and does not travel out from it, no clue why. Never gotten it to fly to the right for now, but I can’t really continue unless im getting this correct.

Before I tried the angle calculation I though that maybe a way to use linear equation with Y = kx + m so i calculated delta X and delta Y and divided to get k and let the Y possition of the arrow be influenced by the x possition and only let it move right or left. The idea was good but in initiation it did not work, how do i know that? Well there where three possitions the arrow could be in, one in the top right, one in the middle top and the last was  in the top left. So i gave up on the idea of that, maybe i could have gotten it to work with enough time but i felt it was a hard and painfull way.

After that i started with the other way of doing it, I already had both delta X and Y so i could start from there, and in c++ there is a thing called atan2 wich could be used as a way to calculate angle so i took atan2(delta X, delta Y) / 180 * PI and this is really where I am at right now, trying to figure out a way to make it shoot to the point of the mouse.

Blog week 1 – Projectile shooting