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, 28 November 2014
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.
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.
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.
Subscribe to:
Posts (Atom)