Tuesday 26 September 2017

Python App 2: Working, animated HP bars + Working items + building my Party!

Firstly, I think I'm in a fair position now to offer some constructive criticism of the course. Although it is amazing that in the 10 years since leaving school this is the first course I have finally gotten more than a quarter through, let alone genuinely learning a programming language finally in my life, I sometimes find the lack of certainty frustrating. It would be one thing if it were a real lecture, but leaving in mistakes rather than editing them out doesn't help my own confidence in what I have learned. Especially when one or two mistakes broke the game I was working on (even more frustrating as I tend to deviate slightly, at least once making me think it was my own fault before rewatching and realising his error). It would be one thing if it was an end of video test to spot a deliberate error, but I should at least be able to trust the tutor's own code as a barometer with which to measure my own (especially for an absolute beginner).

I have turned it into somewhat of a game, where I pause the video and try to spot the error myself first, but still. It makes the learning experience needlessly difficult and harder to grasp. I don't want these words to be taken as slagging off the course, as on the other hand I enjoy the more conversational style. It means I can, generally, follow along. One other minor frustration is that he tends to have the program front and center on his recordings, wheras I would prefer either to have it only covering one one half of the screen (so I can code along with it on the other side), or to have the video tall and fill the entire screen, so I can snap it to one of the sides.



Now that is out of the way, onto what I was learning today. Firstly, I implemented some proper item usage code. Because I had already created a "charge" function (is function the right word? I get a little confused with the lingo, I mean something that works something out and comes back to you), I could use that for mp healing items too. I also replaced some of my own code with his, to do with only healing max hp/mp for elixers (rather than just healing a blanket 9999MP, which had the same effect but looked strange when the status came up as that on healing to max... It looks cleaner just having "fully restore mp".

After that, it was a kind of combined task to create animated statusbars with adding new party members. In some ways they went hand-in-hand with each other, and to my surprise it was increadiblyeasy (you just use classes, which act like a metaphorical "mould" when there is more than one of something, like characters). It was interesting seeing how to make the code cleaner by only calling a few lines of code a number of times (rather than copying and pasting that same piece of code multiple times, which is inefficient and results in a longer, and uglier, document).

It was quite a similar experience creating the hp bars. There is actually only one code for what a Name/HP/MP bar looks like... Then, for every character, it peeks at that template, and adds the character's own stats to it.  Again, it was fascinating seeing solutions to problems I'd never even considered when sat at home playing games. I mean, if I thought about it logically I'd probably imagine it look something similar, but it's cool to implement these things myself and have them do the work for me.

My one frustration was... name lengths. I wasted a great deal of time trying to figure out how to deliver a fixed 9 character field for names on the HP bar, so they are laid out in something like a table rather than all over the place (and so, when a status update is posted like "Ronius attacks for 85!" it doesn't end up appearing "Ronius    attacks for 85!". I gave up in the end... Which is maybe for the best, seeing as I want to somehow give this more of a GUI for Android and Windows (using Kivy), which will likely require an entirely different solution!

As usual, my code is available to peruse and learn from at my GitHub page.  The course I am learning from is Nick Germaine's "The Complete Python Course: Beginner to Advanced!" Available at StackSkills.

No comments:

Post a Comment