Showing posts with label RPG. Show all posts
Showing posts with label RPG. Show all posts

Wednesday, 27 September 2017

Python App 2: The Finishing Touches (For Now)

Firstly, I again need to make the point... The tutor making mistakes then correcting them mid-video is extremely frustrating. I guess it is good to see his troubleshooting process, but again it nearly broke my game... I had to rewrite at least one portion, which I put my hands up could have been due to my unorthodox changes, but equally I was coming across the same errors he did during the video so it compounded the problem quite a lot.



Really it sounds like I did nothing much else when I word it as putting the "finishing touches", when in reality there was quite a bulk of work. I added multiple enemies (and being able to target those multiple enemies), and also gave them the ability to attack individually and give them a rudimentary AI (they heal themselves while their health is low, otherwise that is the one ability they don't use). In my own version, I also gave them the "Pray" magic I had created myself earlier, meaning they also replenish their own MPs. It has really given the enemies some real teeth, and needing some strategy to defeat!

I had also spent maybe 45 minutes trying to see how I could recreate it as a GUI application using Kivy, but realised I didn'y actually know enough about the ins-and-outs to effectively transfer it over, with buttons and the likes, even if I can create on a whim fancy buttons (that don't actually hook up to or do anything). I decided to continue with the course instead, at least until I've finished his lessons on using the built-in Python interfaces. Maybe then I'll have a better idea of how to manipulate the code better?

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.

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.

Monday, 25 September 2017

Python App 2: Magic Class, Fixing Heals and Charge MP magic type!

It's a pretty awesome feeling when you first use what you have learned to fumble around the code and create something entirely new.



The last lesson I completed was to do with moving magic into its own class rather than the main script. And, although the tutor nearly broke his (and my) game because of a mistake he made in the video, I managed to finish it successfully. I then realised I hadn't included a "heal" function for my Player... So I hacked it together, using some of the code for dealing damage, and replacing the minus sign with a plus. I also added an "if" statement that set the hp to maxhp if the HP went above that amount (effectively capping the HP to whatever the max is.

As such, the magic code looked like this:

...
def take_damage(self, dmg):
self.hp -= dmg
if self.hp < 0:
self.hp = 0
return self.hp

def heal(self, dmg):
self.hp += dmg
if self.hp > self.maxhp:
self.hp = self.maxhp

...
 I then added a line to my main code copying the black magic code but replacing it as such:


...
if spell.type == "white":
player.heal(magic_dmg)
print(bcolors.OKBLUE + "\n" + spell.name + " heals for", str(magic_dmg), "HP." + bcolors.ENDC)
elif spell.type == "black":
enemy.take_damage(magic_dmg)
print(bcolors.OKBLUE + "\n" + spell.name + " attacks for", str(magic_dmg), "HP." + bcolors.ENDC)
...

Feeling pleased with my work, I decided to create a magic that charges some MP called Pray (at a 0MP cost); first I created another copy of the heal code, but tweaked it as such:

...
def charge(self, dmg):
self.mp += dmg
if self.mp > self.maxmp:
self.mp = self.maxmp
...

And then finished by adding an extra line to the main script:

...
elif spell.type == "charge":

player.charge(magic_dmg)
print(bcolors.OKBLUE + "\n" + spell.name + " charges", str(magic_dmg), "MP." + bcolors.ENDC)
...

And... Well, it worked! Which astounded me! It may be a tiny thing, but it shows me that I'm actually learning the ropes and create my own deviations rather than purely copying/pasting code! It appears I'm actually understanding it!

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.

Sunday, 24 September 2017

Python App 2: Adding a Magic and Game Over System

I have continued bulldozing through the course today, and my silly text RPG now has a magic system as well as a way to get a "Game Over". The application now starts straight into an enemy battle, and the played character has a limited amount of HP/MP, along with the enemy having a limited amount of HP. The application ends when either the player's hp or the enemy's hp reaches 0.



The biggest problem I'm finding is the same thing I bump into learning programming in the past: The further I go into it, the less in control I feel of the code and understanding what it does. All I have been doing mostly is copying almost verbatim the instructors code- although I do seem quick at finding typo errors when it doesn't run properly. I have also made my own changes to the program, such as making the text detailing enemy and player hp/mp stand out more, and giving different colours to the instructor (so text involving magic or MP are universally blue, for example).

I suppose these are the bugbears of learning anything unfamiliar. The thing is I know each of the systems individually and how and why they work. It's just, as a whole, I would have difficulty tracking down how or why a certain part of the code does a certain thing, without spending 30 seconds or so reading through it and remembering what each part of the code does. Still, the fact I can make little changes that work out how I want them to shows I must understand what I am coding on some level?

As usual, the code is available for study at: https://github.com/GlitchWalker/Python-RPG/

Saturday, 23 September 2017

Python App 2: A simple RPG



Astonishingly enough, I kept to my word. I spent some more time on the beginner to advanced Python course at Stackskills, learnt some "advanced techniques", and am now on the second project. As my title indeed suggests, its aim is to create a simple text-based RPG. The code I'm working on is of course available at my Github page although be warned that for the time being it simply includes some of the character set-up code.

I have also spent some time sprucing up the Blog, seeing as it was based on code some seven years old. First I reset to the default dynamic theme- which still looks, surprisingly,  modern. My next step is to add silly little features like a Last.fm "Now Playing" widget if I am listening to music, and to add back some colour to the defaults. Gone is the snot green- I'm likely to go with either purple or red. I've also changed the font to the beautiful and easier to read Fira Sans, based on the Firefox logo font and also used in the short-lived Firefox OS.

Monday, 25 February 2013

Game Of The Day 25/02/2013 - Final Fantasy XIII-2

That's right. You'd think after my scathing review of this game's predecessor I'd not touch the series again with a barge pole. However, after seeing it for £5 in Asda, I thought what the heck. It's worth the price to try it out.

And I was very pleasantly surprised.

From the beautiful but substance-less carcass of FFXIII is a much better thought out, more engrossing and, most importantly, more fun game. I've already finished the main storyline after about a week. Now it's the standard box-ticking exercise of events/mysteries/battles every RPG has in order to pursue sidequests and "fully" complete the game. I'll provide a more detailed review at a later date; but for now this post is just to provide some thoughts on this game as the game I have most played today.