Jordan Bonser
  • Home
  • CV
  • University Work
    • Second Year Work >
      • Top-Down Shooter
    • Third Year Work >
      • Terrain Analysis Project >
        • Terrain Analysis Tool
        • Game Demonstration
      • Post Processing
      • Android Application - Sports Centre
  • Projects
    • Unity Development >
      • Lerpz Tutorial
      • Dare to be Digital Entry - "Lit"
      • Unity Game
    • Geometry Instancing
    • Road to Eldorado
    • Level Editor
    • OpenGL Work
    • JBEngine
  • Blog
  • Tutorials
    • Flask Session Timeout

Development Blog

PyGame Flappy Bird

22/7/2018

0 Comments

 
Recently I saw an advert for some Stack Skills courses. On seeing it I remembered I had purchased a load of courses on an offer a while ago so I decided to take a look at what I had.

Python - Become a Professional Programmer

One of the courses I purchased was a python course. A lot of it was python basics, but there was also a couple of more advanced ones:
  • ​Create a Web Application with Flask
  • Create a Web Application with Django
  • Create a Flappy Bird Clone with PyGame
I've already created web apps with Flask before and may try the Django one soon but today I decided to follow the PyGame tutorial.

Progress so far...

I managed to complete the tutorial but there are definitely aspects I want to improve. I followed the tutorial fairly closely as to make it easier and only changed subtle things.

The problem with the tutorial is that the code is fairly inconsistent, the structure isn't particularly great and there is no testing or comments.

Examples of this, are things like variable naming:
block_move = 3
x_block = surfaceWidth
y_block = 0
block_width = 75
Why wouldn't you just call it block_x and block_y to follow convention, also the use of camel case is interchanged with snake case a few times, such as the surfaceWidth variable above and also with functions as well:
gameOver():
replay_or_quit():
Okay so maybe I'm being a little harsh and those things I didn't actually add into my version but it does make you wonder about a lot of the information out there. How much of the tutorials and courses are actually written by people who have just about learnt enough about the subject to be able to tell it to someone else?

​

Where to go from here?

So now that I've completed the tutorial I've taken a step back and taken a look at the code and I already want to refactor a lot of it. So here is a list of the things I want to do (regardless of whether I ever get round to doing them:

Testing!

So like I said earlier there was not a single sign of a test in the whole tutorial, which is no surprise really. Most tutorials are simply to give someone the basics of how something works so they can then go away and work on it. They don't tend to care about good practices too much or thinking about software development as a craft. This showed in that a couple of times in the tutorial there were bugs, some that I spotted instantly and others that he had to go back through and try and spot them.

Before I start refactoring any of the code I really need to write some unit test, that way I can confirm that the functionality doesn't change whilst performing the refactoring.

Refactoring

I would like to split out some of this functionality into a few different files/classes as this one python file is pretty bloated. It works okay for a simple tutorial for pygame but I would certainly want to split things out if I wanted to take this any further.

All the functionality in the main game loop is crazy, and certainly doesn't have just one single responsibility.

Python Module

I would want to create a python module from the game so that you can install it and all it's dependencies with pip. I'll also want to update the readme to explain the dependency on PyGame and also how to install it.

Conclusion

I actually had a lot of fun following the tutorial, It's been a while since I've done any game development really and now I know how easy it is to do with PyGame I would be tempted to throw together some simple 2D games with it.

I will probably do the changes I mention above as I always think that If it's a Repo on my GitHub Account, then it's essentially a representation of my work and I'm not currently happy with how it is.

Thanks :)
0 Comments

Python,Flask, SQLAlchemy and virtualenv

13/8/2015

0 Comments

 
I just wanted to put a quick post up about some prototyping I am doing at work. I have been given the task of creating a dummy web application which has taken me into a realm I am not familiar with at all so I thought I would talk about it a little. 

I basically had total control over what technology I used for this application and someone suggested to use Perl as people had used it for other application we have. I really didn't want to use Perl and there is a couple of reasons for this:
  1. If I have to learn a new language I would rather it be one that I like the look of
  2. I would rather learn one that is becoming more popular rather than one that is dying off.
  3. There are a few people in work that are willing to help with this little prototype and they have more expertise with python.
  4. Python has SQLAlchemy which supports both database types we will need to use.


I will now talk a little bit about the other choices I have made in terms of tech: 
I've decided to use Flask as it is a lightweight web framework which will allow me to do exactly what I need. This web application isn't complex so I didn't really want something large and all encompassing.

As the Web application has to use DB's I've decided to use SQLAlchemy as it seems fairly popular, has support for MySQL(The Test DB I am using for this) but also support for DB2(What we will likely deploy it on). 

Finally virtualenv. This is something I've never used before but it seems like it is going to be really useful as deployment to other machines can be done without worry as It won't matter about them having the correct python version or flask version installed. 

All in all it's been great, I've had to learn a lot so far and I'm finally getting the hang of how it all fits together. I've been lucky enough to have another application to use for guidance through this development and so I should have it up and running in no time.
0 Comments

    Archives

    May 2020
    April 2020
    January 2020
    November 2019
    October 2019
    September 2019
    July 2019
    June 2019
    May 2019
    April 2019
    March 2019
    February 2019
    August 2018
    July 2018
    June 2018
    March 2018
    January 2018
    June 2017
    February 2017
    September 2016
    August 2016
    July 2016
    June 2016
    May 2016
    February 2016
    January 2016
    December 2015
    November 2015
    September 2015
    August 2015
    July 2015
    June 2015
    March 2015
    January 2015
    November 2014
    October 2014
    September 2014
    August 2014
    July 2014
    June 2014
    May 2014
    February 2014
    January 2014
    December 2013
    November 2013
    October 2013
    July 2013
    June 2013
    May 2013
    April 2013
    March 2013
    February 2013
    January 2013
    December 2012
    October 2012
    September 2012
    August 2012
    July 2012
    June 2012
    May 2012

    Categories

    All
    2D
    3rd Year Project
    Agile
    Android
    Angular
    Animation
    API
    Apple
    Apps
    Arden
    Async
    Awesomium
    C#
    CI/CD
    Clean Code
    CMake
    Cocos2d-x
    Colour Match
    Compilers
    Cross Compiling
    Cross-Compiling
    Databases
    Design
    Development Tools
    Docker
    Electronics
    Examples
    Flask
    Flask-Login
    Fmod
    Game Development
    Godot
    GUI
    Hackathon
    Hacktoberfest
    Hardware
    Home Life
    IBM
    Inspired Gaming
    Instancing
    Ios
    Javascript
    Jbengine
    Kata
    Level Editor
    Linux
    Microsoft
    Mobile Development
    Monogame
    Moodster
    Motivation
    Networking
    Objective C
    Opengl
    Open Source
    Organisation
    Physics
    Physx
    Pi
    Planning
    Post Mortem
    PyGame
    Python
    Quart
    Quasar
    RakNet
    React
    Road To Eldoarado
    Scripting
    Scrum Master
    Sessions
    Session Timeout
    Social
    Sound
    Space Invaders
    Squash Game
    Squash Game
    Streaming
    TDD
    Team Leading
    Test
    Test Driven Development
    Travis
    Unity
    Unity Development
    VSCode
    Vulkan
    Web Applications
    Worklife
    WSL
    XML
    XNA / C#

    RSS Feed

Powered by Create your own unique website with customizable templates.
  • Home
  • CV
  • University Work
    • Second Year Work >
      • Top-Down Shooter
    • Third Year Work >
      • Terrain Analysis Project >
        • Terrain Analysis Tool
        • Game Demonstration
      • Post Processing
      • Android Application - Sports Centre
  • Projects
    • Unity Development >
      • Lerpz Tutorial
      • Dare to be Digital Entry - "Lit"
      • Unity Game
    • Geometry Instancing
    • Road to Eldorado
    • Level Editor
    • OpenGL Work
    • JBEngine
  • Blog
  • Tutorials
    • Flask Session Timeout