Showing posts with label Open source. Show all posts
Showing posts with label Open source. Show all posts

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.

Thoughts on Mozilla Add-on Crisis and Firefox 57.0

I haven't particularly hidden my disdain for the direction Mozilla has taken with their flagship Firefox browser this past couple of years. After a decade of preaching the benefits of Web Apps to my peers ("Better privacy with an app-like experience for Firefox Mobile!"), preaching the advantages of Webrunner-based apps and how customisable they were (remember Songbird/Nightingale, Instantbird?), and anticipating the release of the later cancelled Matchstick... I finally snapped with the news Firefox was to entirely ditch its old, XUL-based add-ons (and even their newer "Jetpack" add-ons).



Numerous add-on developers have expressed their anger (here are some more angry replies in response to their plan to move solely to WebExtensions). What I find most telling is the fact Mozilla representatives seem to refuse to answer or even acknowledge peoples anger, even on their public blog. It leads to the feeling they only discuss and listen within their "open" forums/echo chambers designated for these decisions and discussions. It might seem unfair to label them as such, as this is how open source development generally happens anyway- But it's a label I stand by, as the reality is it can feel intimidating as the average user to even contemplate visiting such a place to air your views... And, more to the point, the "simplified" experience they're aiming at the more beginner user likely hasn't even been discussed and considered with the help of these kinds of users on said forums. Instead, they seem to rely on "questionnaires" which have that sinking feeling of seeking confirmation bias with how they are worded... You know, like when a town council holds an "open consultation" about a project it already intends on doing anyway. It adds weight to the arguments that some people within Mozilla have a "holier than thou" attitude, and think they know the best for their community. It is also an alarming direction to take for an organisation that claims to support the "open web", and seeks pride in being the last big non-profit browser (despite acting incredibly corporate).

But anyway, Mozilla is still an organisation that garners my support, maybe against my better judgement. Their products are those I keep coming back to; I even have gradually changed my add-on habits to ensure I'm no longer using "legacy" extensions. It has meant I have lost some functionality, which only Pale Moon (and in some cases even Google Chrome) can provide.

Then I launched it. And my first thoughts? It's actually incredibly fast. Even with Pale Moon preaching "benchmarks are useless, it's the subjective experience that matters"... My subjective experience, within the first 30 seconds, was that everything felt much smoother and more intuitive. I like the redesigned new tab page (as I mentioned previously, being an avid Pocket user I actually appreciate the integration as well as the fact their article suggestions are, generally, interesting and well-researched). Tab loading is speedy, moving a tab outside to its own window is quick and doesn't result in any video stream freezing (I most do this with Youtube, so I can watch it on one side of the screen whilst I do work on the other). Within a minute, I made it my default browser again, after a few months of uncertainty.,

This doesn't stop me feeling cross with Mozilla. I find their biased language praising moving to "modern web technologies" disgusting, in one stroke implying all the complainers within the add-ons community (as well as the users that champion those add-ons). Equally, I have no problems with WebExtensions, in comparison to the Pale Moon scripture which outright refuses to support them like a toddler. I have never had issues with moving to support them: my only issue is dropping support for well-established add-on systems when WE still isn't feature compatible (and where, in a handful of cases, it never will be). The ball was already dropped with Firefox becoming the browser full of bloated add-ons when Chrome proved it could implenment add-ons in a speedier way. People who jumped ship for speed already made their minds up nearly a decade ago; and Mozilla has been chasing Google's Porsche when Firefox was more of an off-roader in the first place... A Swiss army knife, more focused on customisation. Don't get me wrong, the speed increases they gained within just a few years of Chrome's launch, and without hugely breaking compatibility too, were amazing. But since then they have launched a cocktail of projects which they inevitably ditched... At a time they maybe should have consolidated on just the browser, before the Google Search revenue spring dried up as a result of making Google Default just not having the same value it once did. On top of all these projects, Mozilla put down increasingly difficult hoops for developers to jump through (electrolysis anyone?) leaving most add-on developers feeling fed-up and closing shop.

In my opinion, the best situation would be to either focus on making WebExtensions 100% feature compatible... Or focus on keeping legacy add-on support until it is compatible. I really hope Mozilla realises the error of their ways, before it falls into obscurity. Otherwise it really will be a frightening world where just Google and Microsoft are the internet heavyweights...

To try Firefox 57.0 with Firefox Developer Edition, click here

Mozilla recently updated their "Firefox Nightly" Blog with details of browser version 57 with Firefox Quantum.

Sunday, 24 September 2017

Python App 3: "Plong" For Windows



Another common problem I find with learning a programming language is how far you really need to get into learning a language before you get any useful returns in creating anything that even resembles an everyday Windows/Android game.

So, I was desperate to move on to something as an "Interlude" to my second Python app to investigate how difficult it actually would be to port some form of Python code into a ".exe" or ".apk" we are used to.

In my investigation, I discovered Kivy... Which acts as a library to create and compile apps to Windows, iPhone, Linux, Android and pretty much anything else you could name. So I dived into their Pong Game Tutorial

It was refreshingly simple to set up, as I had already used pip to set up PyCharm (pip feeling very similar to how something like apt-get works). Installing everything I needed was a breeze... Even typing, running and making changes to their code was quite easy considering I'd already had some deeper experience of Python now under my belt... I was probably at about the right part of my education to start "experimenting"!

The only fiddly part was subsequently completing their tutorial to Create A Package For Windows, only really fiddly because you had to manually park command prompt in the empty folder you wanted to compile to, manually add a name in the command you type in then manually edit the created ".spec" file to include the files of your project. I mean really it was easy stuff too, although used to the ease of projects up to now I only question why no-one has simplified this experience as of yet. Equally, it finally made me feel like doing "real" coding.

It spat out a "Plong.exe" file, I launched it... And it ran exactly as it did in PyCharm! Finally, I had created my first ever application! There are some things that niggle me, like the command prompt that opens before the actual game which I wish I could silence (saying that even Steam Games such as Metal Gear Solid V do the same thing). There is also the small fact it isn't completely mine, it is largely the unedited code from their website at the moment as I wanted to quickly progress to actually compiling the thing. But, actually, if you're an intermediate at computing like me (and barely an intermediate at programming) you'll actually find the whole compilation process pretty simple.

Plong.exe is available at https://github.com/GlitchWalker/Python-and-Kivy-Pong-Game/releases, and as always my source code is available at my GitHub

Tuesday, 23 April 2013

Pirate News Top Three 23/04/2013

Worried About Accidental Illegal Filesharing? Get Insurance.

47310

The Local has reported that the Swedish Pirate Party has unveiled a “File-Sharer Fine" Insurance, which will pay out on any fines a person receives as a result of file-sharing. The argument goes that it can be difficult to know what is legal to download and what isn’t, as a result of poor copyright policy as well as contradicting laws in different countries (e.g. regarding mp3/mpg licences). The idea comes from planka.nu, a similar scheme in which people can insure against getting caught without a ticket on the Stockholm Metro system. It would be interesting to see what the premiums would be like and how they are calculated.

Full Article At The Local: Pirate Party launches file-sharer fine insurance

 

International Pirate Parties Compared

buttons-636x310

With the ever-growing Pirate Movement straddled across many continents and very largely influenced by their respective memberships (and rightly so), The Pirate Times has started working on a table which compares the policies that national Pirate Parties have decided to campaign or have a policy on, although at the moment it is very general. Interesting points include the focus on Church-State Separation in a number of Eastern European states, as well as the obvious near-unanimous agreement on policies such as Patent Reform, Privacy and Net Neutrality.

Full Article Available At The Pirate Times: The Pirate Times Pirate Party Policy Comparison Table

 

Cameron To Opt-Out of EU Social Media Policy?

DAP

It seems popular right now to slag off anything that comes from the EU; the apparently undemocratic institution we elect MEPs to every year is a force of evil, makes it illegal for us to call ourselves British anymore, etc. etc. Although this might win votes, it seems the current government is taking the very position it criticises the Labour Party of doing; namely opposition for the sake of opposition. David Cameron seems to be intent on opting-out of EU legislation that would mean companies such as Google and Facebook are required to remove all of your data if you request it. I’ll leave the question open as to whether this seems a good idea or not.

Full Article At Pirate Party UK Blog: Opinion: Cameron Wants to Forget The Right to be Forgotten

Tuesday, 26 February 2013

New Interface For Firefox Mobile Nightly Version 22

I don't deny I love living on the edge when it comes to software like Firefox. There's something cool about saying "Haha, I saw it first!" And seeing what new surprises await.

I updated my Nightly version of Firefox today to find they seem to have overhauled the interface. The tab menu is now in the top right, and when tapped the open tabs are now arranged as horizontal screenshot icons rather than the focus being on a vertical list.

The interface isn't complete, however, as tapping the sync button shows. The menu of tabs on other computers is hidden underneath the awesomebar, making it impossible to access some of them. However this is the development version, so bugs are yet to be ironed out.

Feeling adventurous? Check it out on the Firefox Nightly Website.



EDIT: After trying the nightly on my Nexus 4, it turns out the interface upgrade is only for the tablet version of Android.

Saturday, 9 February 2013

FBI Agents Torrent Pirates Of The Caribbean (or they may as well)

With the help of ScanEye, a Bittorrent monitoring company, TorrentFreak has reported that a number of IP addresses for the popular file-sharing protocol come from non other than those registered to various FBI agencies. It is also likely that these would have been downloads for personal use, as they were spread across a number of months. This contrasts with their behaviour in undercover "entrapment".

Would people working for one of the biggest "intelligence" agencies in the world really be so careless? As one commenter points out:

At the end of the day, even the FBI's staff are just regular people like you and I who want to experience and share culture with everyone abroad.

It would certainly be ironic if the agency had to arrest its own staff as a result of RIAA/MPAA tracking.

Full Article at Torrentfreak: FBI Employees Download Pirated Movies and TV-Shows

Saturday, 21 January 2012

My Weapon Of Choice Is... Blowfish

Being on Ubuntu Linux restricts me a tiny bit in which text editor I can use; either because software isn't compatible at all with it, or because it would be compatible but I need to compile it on my system, or run it under WINE. This is a good thing really, considering the fact I would like to learn the art of Webcraft using solely Open Source Software.

By default on my system I have been playing around with Gedit, usually just to copy pieces of text or code there and back that I wanted to edit. However I also gave Blowfish Editor a go, and found it was much better at auto-completing my text (not that I needed it of course- my previous lesson had taught me extremely well ;). It is nice to have the coding equivalent of a spell-check, though.

Hello World says Hello World to editor containing Hello World...


Enhanced by Zemanta

Friday, 2 December 2011

About me. Creativity. And... Stuff.


Hi all, this is the first of what I hope will be a huge number of amazing adventures we shall embark on, into the world of super amazing and definitely not geeky HTML and Design. First about me.
I’m a 20-something armchair eco-warrior, although in my head I’m still 15, and I hark from the City of Lincoln in that small island known at the United Kingdom. I had been diagnosed with the affliction of Bipolar, which means I am regularly dogged by very low depressions and occasionally very high periods of productivity and creativity which are fun but ultimately unsustainable and usually end up in causing many problems. However my aim is to cease being dictated to by my label and instead try and use some of that energy for good. Sometimes failing. Although I have been on national radio talking about mental health and the like, as well as affecting national policy on mental health problems, so have been successful in some senses. It’s just a shame that, at present, I have very little paid work!!
I have a lot of piecemeal knowledge on HTML and graphics design I learnt by doing at school, and also picked up a lot of design skills in college and university. My reasons for joining the P2PU webcraft school was in the hope that I can put all this knowledge together and do what I do best, which is creating things. If I could make a tiny living from the work I do, then that would be so much better too. I also agree with the open source ethos of free ideas being shared for free. On a more technical side I am interested in trying to create everything I do using open source software, and have restricted my web design to Ubuntu (or the Linux Mint flavour, to be exact) to try and force me to learn how to use the very much comparable free software.
Enhanced by Zemanta