Categories

Sunday, 14 December 2014

Bomberman Begins

Too be honest, I have really been slacking this week (and a big part of my classmates have too). Maybe it is because it is soon Christmas. Maybe it is tiredness from the game-jam we had, combined with the hobbit movie marathon and a lot of alumni guest lectures that took up our time. We have at least done something this week. We put together functionality for images other than Bitmap files for our games projects, which really just was to include another library called SDL_image that goes well with the rest of the SDL library, it was pretty much included the same way as SDL was. Also we learned how to output text onto the screen in our game windows which we did with, you've guessed it, yet another library not included in the original SDL. This was a bit more interesting though since we had to transform letters from a font into a picture to draw on the screen.

We have at least started on our final work for the course, which will be to create a clone of  a classical game, in which I chose Bomberman. Joakim Ädel joined my project, so hopefully we will get more done than we could individually. I have started working on automatic random map generation and put the pieces of our old projects together into a base to create the Bomberman clone from. I've also looked slightly into git, which really seems like a lovely software that I wished I had learned and used way earlier. Git is basically a program which you use to keep track of different version of a project. The power of git though compared to like Dropbox or any other version controlled storage is that you can have a "branch" for every new feature to implement in the code. This allows you to work on multiple features at the same time. For instance I might have a branch for trying to fix a specific bug and a branch for adding a new feature. Both of those two branches are connected to the latest official version of the project, When I get done with a branch, that is to say when I have succeeded to implement the bug fix or a new feature, I can make the finished branch into the "master", which basically means making the branch the official latest version of the project. When I get done with the other bug or feature branch I can then merge this new branch with the master. And it is here the magical witchcraft is going on, because here the bug fix and the new feature becomes one. The smart thing about git is that it only saves the changes of the content of files so it is possible for a file to be edited in two or more branches simultaneously, the only times there will be a conflict (if I have understood it right) is if the same parts in a file is being changed in both branches differently. Then that part must be manually merged, which in code means making that piece of code work for both branches. This also allows for many people to work on individual branches with individual problems. People can even work on the same problem but different parts of it (a branching in a branch). Or just compete for having the best solution to a problem. It is also easy to go back to an older version, and since every new version is described by the changes that was made to it,  it is easy to know what happened and when.

I am very excited to make my own game in C++ out of the things I know and the ideas I have. It is actually what I came here for, to be able to create games, to be able to create great interactive experiences for other people. So it shouldn't be hard for me to keep motivated. From now on I'll program and learn as much as I possibly can, because in the end, the amount of effort I put in now will determine how good the chances are for me to follow my dreams. And honestly, what I am doing right now is actually a part of that dream, and probably it is also a part of the dream that a lot of people in my class have. So there is really no reason for us to not give it all we can.


Saturday, 6 December 2014

Weak four (on my part)

This week has been purely about how to use the SDL library and about dividing things into appropriate classes as a foundation of games. That means we have one class for starting everything, one class for drawing everything on the screen, one class for handling states, etc... We learned to handle input from mouse and keyboard, we learned how to make a core loop of clearing screen drawing screen and presenting screen and lastly we larned about states, which was pretty confusing. We (a bunch of students) have planned to go through the code we have got on the lectures and try to explain it line by line for each others until we get it.

I like this week because it has been the first to introduce me to mostly, for me, new material.

This week has been extra slow because of some complementary work in other courses and because of the preparations for the game jam on the weekend.

I could probably have done better somehow.

Next week I'll try to analyse my time better so that I know how to improve.

Now GAME JAM!

Friday, 28 November 2014

BlogPosts[2] = new blogPost(3);

Hopefully this works now. Apparently my blog posts wasn't showing up for some reason. I guess I just missed the right instructions or something. Anyways, this has been the result of week three:

It has been way too much and way too little at the same time. As I have programmed before the exercises seemed like a repetition of what I have already learned, but with some small changes in syntax, which was really annoying to find out about because there were not any good error messages when they arose. So one fourth of the week has been trying to figure out minimal syntax errors and programming language differences, C++ is on top of the "most pedantic languages I have tested" list , the second fourth have been figuring out solutions to programming problems and the last half has been spent helping others in the class with understanding object oriented programming and how to use objects and why they should be used. Everyone I helped seemed to understand what classes and objects are good for and what differs them, but somehow they did things wrong. An example was the exercise where we were to create a card and a deck class, and the to store the "cards" in a "deck". People usually stored all the cards in the card class as if the card class was a holder for all the cards and then they didn't see the purpose of the deck class.  Maybe it was the high tempo, maybe the instructions wasn't clear enough in the exercise document, I don't know. I feel bad though for the ones that has not programmed before or have forgotten object oriented programming if it was long ago because this week was probably heavy for them with a lot of new information in a short period of time.

Here is an example of how I did the card class, just to show of or something:
(The const string arrays are declared with static in the header file to not take up the memory for suits and ranks more than once)

I actually skipped the majority of the seminars this week, partly because I have been feeling a sick and exhausted and partly because the only valuable information for me was the syntax differences, I have been working with objects so many times before so just listening to how it all works was kind of painful. (I checked the files uploaded on the portal and asked friends if I missed anything though so I guess it's cool.)

To make better progress I could probably have focused more on my own progress instead of my friends, though as I have said before in this blog, I think there is big value in helping others because you learn in the process of  explaining things as simple as you can.

I have a bunch of exercises from this week left unfinished. I'll try to finish them off before next week. It will probably not be too hard, I just need to clear my mind.

Friday, 21 November 2014

It has been a Pong week..

This week has been fully packed with programming! We have gone through pointers and functions and a lot of fun stuff and by the end of the week we learned how to make pong with the sdl library! I am still a bit lost in the SDL library because I am new to it, but I am pretty used to the structure of the code, because I have done similar things in flash. This was a bit messy thought because we have not gone through classes yet, so we had to make the entire game in one class, which means all code in one big text file. Not a good idea if you want to keep track of things...
After the first Pong lesson where we only made one paddle work, I made both the paddles work and then I started making the rest of the game in the way I thought of, because I got really inspired to make games. It worked fine and I think it was really good practice for what would come. It was problematic though when I got back to class the day after and we were to continue, because I had already written the code in my way, and it was a lot different and also less professional than the code solutions our teacher showed us. So I ended up trying to follow his steps on the screen while at the same time changing my own code so it wouldn't interfere with the new code. In the end the result was really great and it made me really happy. Next time I am going to save different versions so that I don't get carried away and then need delete code instead of just opening an older project version. I feel really inspired to do more games in SDL, but right now I need to focus on finishing the training assignment.

Saturday, 15 November 2014

Programming week one!

Hi there blog!

Long time no see. I have been busy doing stuff so nothing has been happening here lately.
This week the programming course started! I love programming so for me to just be able to focus all my time on stuff that I love a lot is amazing.

Since I have been programming a bunch before there wasn't really anything new to me concept wise. The thing that differs in how programming languages are operated is usually just syntax, which often is not very different from most other programming languages. So I have been taking it easy this week. People from the class have been hanging out at school after the lectures to practice programming. I have been there, helping those who needs helps and exchanging knowledge with those being around the same programming level as me. I have been testing some grid based programming and tried to make a snake game in the console.

We got a list of non mandatory programming exercises which I could finish pretty fast. I think it really helped that I had been practicing programming not so long ago so I had it fresh in my mind. I finished the codeacademy.com python course a while before this course started and I finished a summer course this summer, also in python, called "sommarprogrammering" which translates directly to summer programming. Also this summer I have been looking at some videos, which really is a great way to learn, where a guy talks about how to program in c++ from the basics and up.


Process of unfinished snake game:
So I made a two dimensional int array, which I at best can explain to you non programmers as a list filled with lists that are filled with numbers, where every number represents something. 0 means empty space, 1 means snake part, 2 means apple. I had an infinite loop*, as timer and a sleep function for delay, making the program wait to not make the game go too fast. Then I found this function online that returned true only if a keyboard key with a certain keycode was pressed. I figured out the key codes for the arrow keys then I made the program just check in every clock tick if any of the arrow keys were pressed. If any of them returned true I changed the direction of the snake head in the direction of the arrow. The difference is just if the snake head's x and y coordinates goes +1 or -1 every clock tick. Then I just took the coordinates of the snake head and turned that coordinate into the two dimensional array, by using y as list list index number and x as number list index number, and then changing the value in that location 1 if it was 0 before. Every tick I had another loop that cleared the screen form text and then recreated the two dimensional array into a new text that the program then pushes out on the console screen. I realized that the console wasn't that fast too update the text on the screen, so the game was doomed to lag and be slow. I stopped developing that project then because that killed my motivation.

* An infinite loop is basically a list of instructions that the program goes through one by one until the end of the list where the program goes back to the first instruction and this repeats forever until the program stops or reaches a message that tells it to stop.


What could I have done better this week?
I could have asked for harder programming tasks earlier to make the most of my time. I have also been thinking about creating and posting videos about programming, because I have heard that one of the best way to remember things is to teach it to others. I believe there is this quote by Einstein that "if you can't explain it simply to others you don't know it good enough" or something like that. I really believe that is true, even if I can do these tasks and know how to do them, if I can't do them easily in a simple way then it will take too much energy for me too do things that are harder than these things. Also teaching out to others motivates you to check everything so you don't give out false or vague information.

This weekend I am going to look into SDL, which is a programming library we will be using, and try to do something graphical and maybe record a video of it to help others in my class. I'll also look into a lot programming and c++ terms on Wikipedia to get a deeper view of what the things are and why they exist. Next week I'll continue to go on the lectures so there isn't anything fundamental in c++ programming that I miss and so that I can ask questions if they would arise.