Daily Entry: June 6th, 2017

Tue Jun 6 11:07:41 UTC 2017

Phone interview with AQR went very well.

Further, I have gotten feedback from Mixpanel and should have a phone interview with them soon.

I have done some pullups, done a full stretch routine, and gone for a 7-mile bike ride (not at all in that order).

I have also meditated and caught up on tickler.

Today is the first day of me counting calories again.

Tue Jun 6 11:17:33 UTC 2017

Considering whether or not to dance. Should probably start and then decide to stop whenever I feel like it. Starting is harder than continuing.

Tue Jun 6 12:16:27 UTC 2017

Danced about 4 or 5 dances. This time when I felt like stopping, I skipped the song and found myself dancing more. I accidentally closed the Just Dance game, though, and took that as a sign to stop.

I feel really, really good now.

Tue Jun 6 12:19:34 UTC 2017

Time to work some more on that one tutorial I'm working on. I have all the necessary resources to finish it, and finishing needs to be a skill I cultivate. So let's try and finish the draft by tomorrow and start working on the video a bit tomorrow.

Tue Jun 6 12:44:58 UTC 2017

Made good progress. Editing comes later, I'm just writing it down as it comes now.

Setting Up Wing Personal IDE Pygame Environment

Hello, I'm SilentKat and let me break down the assumptions and goals of this here thing:

  1. You are using a Windows OS (aka Windows 10, 7, 8.1, Vista)
  2. You want to program a game
  3. You're choosing python to program that game
  4. You're willing to use the pygame library to do a lot of the heavy-lifting
  5. You want to make an executable of your code that runs on any Windows machine

If any of these assumptions are wrong this probably isn't the thing for you. I am, however, willing to do an Ubuntu version of this (and the executable in that case will be a binary playable on Linux systems). Let me know if you're interested in that and I can make that a priority. As I do not currently have access to Mac OS stuff, I am currently unable to make any such tutorial for that OS.

Further assumptions:

  1. You want to setup your environment without using the command-line
  2. You do not have python already installed
  3. You want to program in the Wing Personal IDE

If any of these assumptions are wrong, it's not necessarily a deal breaker. If you want to use the command-line, it should be pretty clear what commands to use instead of running the given scripts.

If you already have python installed, and that python is not 3.4 32-bit, then I highly recommend installing python 3.4 32-bit for maximum compatibility purposes. Also, to avoid some issues, make sure when you install python 3.4 that it's the "default" python (click the button that says add it to your PATH when installing).

If, at any point during this setup you hit a snag I don't mention, bring it to my attention and I will help figure out the problem and update this thing. I've hit plenty of snags doing this myself and helping one specific other person. Probably lots of gotchas for this.

Steps:

  1. Install 32-bit Python 3.4.4
    • Note: Remember to click on the box to add Python to your path
  2. Install Wing Personal IDE
  3. (Windows 10 Only) Download the necessary DLLs for backwards compatiblity with older versions of Windows
  4. Setup virtualenv_without_cmdline
  5. Setup pygame_skeleton

Install 32-bit Python 3.4.4

Why 3.4.4? Python 3 has made lots of progress and is a worthwhile pick over the standard Python 2.7. However, the library we'll be using to make an executable out of our game code (PyInstaller) has currently (as of June 6th, 2017) unresolved issues limiting our executable options.

Why 32-bit? So that our executable generator (again, PyInstaller) creates a 32-bit executable that will run on 32-bit systems. It'll also make our generated executable smaller.

So, with that being explained, download the Windows x86 MSI installer for Python 3.4.4 (from the main python site) and install python.

Install Wing Personal IDE

Why Wing Personal IDE?

No reason. This setup should work with any IDE or lack thereof. I am simply playing with the IDE right now and think it's perfectly serviceable for our purposes.

Other worthwhile alternatives:

  • Spyder
  • Eclipse
  • IPython Notebook
  • Powershell and editor of choice
    • Vim
    • Emacs
    • VSCode
    • Atom
    • Sublime Text

You do you.

Wing Personal IDE download link.

Windows 10 Backwards Compatibility

Why?

Windows 10 does voodoo black magic to pretend it has libraries older Windows versions have when really it consolidated all of them into a single library.

Or something.

In any case, this will confuse the picky PyInstaller library we're using and it won't bundle the right libraries into our executable and then that executable will fail to run on Windows systems that don't already have the necessary DLL libraries.

So, how do we get those DLLs? Well, there's a large (over 2 gigs) Windows SDK that provides them or you can download just the necessary files (2KB) here.

virtualenv_without_cmdline

Why virtualenv?

Python has a lot of options out there. There's various active versions of python, and various popular third-party libraries to further extend the language. Different projects have different needs and those needs may conflict with one another. A third-party library may only work properly on specific versions of python (cough PyInstaller cough). So we're going to put our game's various dependencies in one place so that if we want to work on another project, we don't have to worry about stuff we downloaded for this project making things difficult for any other project.

Why these scripts to do virtualenv?

Virtualenv kinda expects the user to run from the commandline. If you've never used the commandline before, this can be daunting and error prone so let's just avoid it and virtualenv via python scripts, which if you don't already know how to do, you'll have to learn if you plan on programming in python.

Note: I fully recommend learning command line. After the learning curve, it is quite powerful. But that's just me, you do you.

Once you've downloaded the zip from that github link given earlier, unzip it somewhere you're willing to put a decent amount of data (the virtualenv_without_cmdline is where we'll be putting our virtualenv, which are basically self-contained python installations).

Then, create a project in Wing IDE and save it to the virtualenv_without_cmdline directory. Then add that directories files to the project.

Open and run the "update_pip.py" file. Python 3.4 is fairly old by now, and the pip that comes with it is also old and can/should be updated.

Open and run the "pip_install_virtualenv.py" file. This will install the virtualenv library on the main python 3.4 area.

Open the "create_virtualenv.py" file. If you don't want your virtualenv to be called "default", change the single occurance of the word "default" in this file to whatever you do want the virtualenv to be called.

If all goes well, you should now have a directory called "default" in virtualenv_without_cmdline.

If you don't want your virtualenv called "default" or whatever you named it. In it there is a directory called Scripts and in that directory there is a python.exe. This is the python.exe you will be pointing at for your pygame project.

pygame_skeleton

Download pygame_skeleton from the link above.

Create a new project in Wing IDE. Point this project's python at the python in your virtualenv directory.

Sanity check: if you have more than one version of python installed something may have gone wrong. Or, if you're like me, something magically went wrong because that's just what happens to you. In either case, Wing IDE will have opened a python shell using the exe you just fed it in that lower-middle window. It should say "Python 3.4.4 (32-bit)" somewhere in there. If it says something else or is just not working, something went wrong.

Let me know and we'll figure out what went wrong and fix it.

Sanity check passed? Good.

Save this project to your pygame_skeleton directory. Add the directories files to the project.

Open and run "pip_install.py". This will take a while. You'll notice there's a list defined in this script called "libs_to_install.py". If there's any library you want to install for use in your game, you can add it to this list. Pip will automatically install the latest version if you don't provide a version. If the library isn't present in pip's normal lookup table, you may need to provide pip a link to the library instead of just its name. "git+https://github.com/pyjs/pyjs.git#egg=pyjs", for example, installs pyjs, a python-to-javascript library which will eventually be utilized in an update to the pygame_skeleton project.

After that's done running, you should have all the libraries you need to make a python game in pygame.

Sanity check: restart your python shell. Try the following commands in that shell:

import pygame import PIL

If those commands don't cause errors, you should be good to go. Go ahead and open "hello_world.py" and run it.

You should see a non-interactive window pop up that is identical to the one below.

Did the "hello_world.py" game work? Cool.

Now try running "build_exe.py". An exe should now be present in a dist directory within pygame_skeleton.

Should look something like:

Running this executable should run the same game as hello_world.py.

If everything is working, let's give a tour of all the stuff that's here and how to change the stuff you're going to want to change.

The tour

"hello_world.py" just has some basic pygame stuff in it. Feel free to modify it to get familiar with pygame if necessary. As time goes on, I'd like to add additional examples of how to do things in pygame to this project. You can also just delete this file.

"build_exe.py" builds the exe based on the specifications in the spec file specified in the python script. There are two spec files that come with this project. One builds the "hello_world.py" into a single-file executable and the other into a single directory that contains a game executable.

Point "build_exe.py" to the kind of executable setup you want to create. There's pros and cons to each. Basically, if you want to save stuff between game sessions, you may want to make it a directory, else might as well be a single-file executable. This isn't a strict rule-of-thumb, but good enough for now if you don't know which you want to do.

The main thing you'll want to change in either spec file is what the "main_file" is. Right now, it's "hello_world.py". You'll want to change that to whatever your main python script is that runs the game. Whatever file you run to play your game is the main_file.

You'll notice that the hello_world.exe created has an icon that looks like:

You'll notice that when you run the game it has the same icon.

These are not the same images.

The image shown in the pygame window is in data/icon.png and the image shown in the exe is data/icon.ico.

Why two icon files?

"ico_from_image.py"

The icon of the executable is set via PyInstaller. The icon in the pygame window is set via pygame code (see "resources.py"). Pygame is particular about its files, and doesn't like the ico files created via the PILLOW library which is what the script "ico_from_image.py" does.

In any case, find/create the image you want to be your game's icon, set is as icon.png in that data directory, and run this script to make an ico version of that image.

This will set all relevant icons as that image.

"resources.py"

Okay, so why is there a resources.py and what is it doing?

There are significant differences in the environment between running your game as a script and running your game as an executable. "resources.py" makes abstracts that away so that you can pretend the environment is the same. Make sure your non-code assets are in the data directory and make sure you grab those assets via the relevant resource methods and things should just work.

Make Your Game

You should have everything you need. There's a lot of stuff not yet covered that I would like to eventually cover, but this should be a decent foundation to get you going.

Happy gaming.

SilentKat

If you have any questions or comments: tweet me @SilentKsionda.

Daily Entry: June 4th, 2017

Sun Jun 4 07:38:12 UTC 2017

All right, let's do some things!

Maybe start with some reflection and thinking.

I brought my bike back with me from Tucson, Stephan. I'm already really glad I did, as the last two days I've done a modest 7-mile ride each day. Really nice getting that fresh air. Running's been good, but I may need new shoes before I do anymore, as I've been feeling some aches in my legs that may lead to long-term damage if I'm not smart about things.

Tomorrow I plan on adding my bike rack on the back tire so I can reattach my pannier and maybe even do regular grocery shopping via bike.

We'll see.

Sun Jun 4 07:42:16 UTC 2017

I should do some chores. To the tickler!

Chores done.

Sun Jun 4 08:02:57 UTC 2017

I have gotten distracted reading up on character design tips.

Sun Jun 4 08:04:49 UTC 2017

Let's start working on that draft again.

Let put its content in a post now and just keep updating that post.

The post is here.

Sun Jun 4 08:26:42 UTC 2017

Fixed the config such that me putting line breaks in my markdown doesn't translate to a line break in the rendered diary post.

Sun Jun 4 08:38:33 UTC 2017

Feeling tired. Swtiching to playing some Zelda.

Sun Jun 4 09:34:40 UTC 2017

Switching to Overwatch quickplay with the wife.

Daily Entry: June 3rd, 2017

Sat Jun 3 05:44:15 UTC 2017

I'm back.

Last post was almost two weeks ago.

I went back to Tucson for a wedding and ended up not logging anything or being productive in any way.

I feel that that is fine.

Upon getting back I needed a bit of time to fall back into things. I think that time is elapsed.

So, I'm back.

I've been thinking, I want to practice a few things everyday:

  • Drawing
  • Programming
  • Gaming
    • Overwatch
    • Super Smash Bros. Melee
  • Dancing
  • Japanese
  • Some sort of musical instrument

Days off for dancing are important. Perhaps they will be for the other things as well.

I think that whilst not having a job, I can totally put in a decent amount of time towards all these things.

In fact, I may be able to do so even with having a job. Drawing, Japanese, and music can be less than an hour each. Maybe twenty minutes, even. Dancing is about 40 minutes. Gaming can be as little as an hour but will probably end up getting more than its fair share. And then programming can be 4 hours of serious work. This could perhaps work with or without a job.

I have noticed since not having a job that actually doing any of these things provides as much resistance as when I had a job. When I actually do it, it's not nearly as tiring as I anticipate. Oftentimes it's quite energizing.

It seems more that I have bad instincts that I need to learn to overcome, and when I do overcome them, I have to be weary of them coming back.

Like, I often feel like making decisions that don't make me happier nor do they energize me to give me the strength or motivation to make me happier or work on hard things. I want to accomplish things, but this feeling convinces me to make no progress.

I have, several times now, learned to overcome this. And have been very happy for it and gotten good at doing the things I identify as needing doing, either for intrinsic purposes or extrinsic ones. But then, each time, new instincts come into play that revert me to old habits, to listening to my always-wrong feelings on what I should be doing in the given moment.

So, the game has gotten a bit more complicated. How do I not revert to my old self.

Am I on the path now? Has my trip to Tucson made me susceptible to avoiding working on projects and practicing skills which I was building up momentum to before the trip?

Today may be a proper "no". Perhaps I have taken a break without it ruining my momentum.

We will see.

Sat Jun 3 05:56:59 UTC 2017

Let's check out my tickler.

Sat Jun 3 06:48:53 UTC 2017

All right, I want to start writing up a draft of my pygame skeleton draft.

Setting Up Wing Personal IDE Pygame Environment

Hello, I'm SilentKat and let me break down the assumptions and goals of this here thing:

  1. You are using a Windows OS (aka Windows 10, 7, 8.1, Vista)
  2. You want to program a game
  3. You're choosing python to program that game
  4. You're willing to use the pygame library to do a lot of the heavy-lifting
  5. You want to make an executable of your code that runs on any Windows machine

If any of these assumptions are wrong this probably isn't the thing for you.

Further assumptions:

  1. You want to setup your environment without using the command-line
  2. You do not have python already installed
  3. You want to program
Sat Jun 3 06:58:44 UTC 2017

Need to restart computer, to be continued.

Sat Jun 3 10:33:06 UTC 2017

Ended up applying to various places (notably Mixpanel.

Getting tired, will continue draft tomorrow.

Daily Entry: May 21th, 2017

Sun May 21 10:09:20 UTC 2017

Been really good about devoting time to projects. Yesterday I went down the rabbit-hole of why the pygame exe files I created on Windows 10 didn't work on my Windows 7 laptop.

I figured it out.

  • Python 3.5 and Python 3.6 is broken for creating single-file executables
  • Old python dependencies api-ms-win-crt-* are now all in one library on windows 10
    • Doesn't package right to play on old windows versions

Most of this information is contained in this PyInstaller issue.

I haven't been devoting any time to a project I was working on with a friend, and yesterday I hashed some stuff out with him and I'm going to try to devote some time to it today.

Sun May 21 10:25:31 UTC 2017

Realized I didn't like the formatting of some diary posts here and so I fixed it. Gotta not do line breaks within paragraphs. I'm used to markdown not doing line breaks for a single line break.

Sun May 21 10:28:14 UTC 2017

Okay, now work on project.

Sun May 21 11:43:00 UTC 2017

Ended up hanging with family.

Daily Entry: May 19th, 2017

Fri May 19 13:08:21 UTC 2017

Most of the code for the pygame_skeleton is done. I'll be pushing it today, and hopefully start making a post about how to setup the skeleton or something.

I'm really out of it today, but I want to build the habit of discipline, so this is good practice for that.

Daily Entry: May 18th, 2017

Thu May 18 07:40:17 UTC 2017

Started the day with meditation, then played a couple hours of Overwatch. Getting ready to work on a tutorial to setup pygame development on Wing.

Thu May 18 08:04:42 UTC 2017

It will be two repos on github, the first one to setup virtualenv stuff and the second to setup pygame with pyinstaller to make the executable.

Daily Entry: May 17th, 2017

Wed May 17 11:26:54 UTC 2017

Been a while, hasn't it, Stephan?

I've been legit busy, which is a better excuse than me being bad.

First things first, I've had my first ever real freelance gig! Just a small gig, agreed to a payment of $50 and gots paid $75 because he liked the work I did a lot. I consider it a first because it's the first time I worked for a stranger for monies.

I don't know this person personally, and it all worked out pretty well.

I also feel like it's going to lead to some momentum as far as personal productivity goes.

Wed May 17 11:36:28 UTC 2017

Anyways, I've had a bit of an epiphany. As a professional programmer, I think a big part of my job description is to be flexible. Flexible in what tools I use, what languages I program in, the style of my programming, and even the algorithms and data-structures I use.

Part of my gig was helping my client setup his environment how he wanted. He wanted to use Wing IDE, so I looked into it and got familiar with it. Even having avoided IDE land for a long time, I got familiar with it pretty quickly and was capable of telling it to do stuff I wanted it to do within a reasonable timeframe.

Wed May 17 11:45:55 UTC 2017

This is something I take for granted, but it's not something that can really be done that fast. All these tools/editors/languages have similarities or predictable contrasts that one must be aware of to look for.

I see how much more I need to learn and often think I can't do that much, but I am actually at the point where I can do a lot of things competently, and pick up certain things quickly. And that's valuable and something I can probably sell for a livable wage once I build a network or foundation of some sort.

Something worth exploring.

Wed May 17 11:50:07 UTC 2017

Anyways, one part of this thinking is that I'd like to learn how to avoid the command line to help those who don't want to deal with it. To setup my client's environment, I had him use powershell. I think I could've done everything from Wing IDE assuming python and wing were already installed.

I am going to explore this hypothesis now.

Wed May 17 12:00:57 UTC 2017

Yes, it is quite possible. Probably would've been easier to go down this path with client.

Daily Entry: May 14th, 2017

Sun May 14 11:30:43 UTC 2017

Haven't meditated yet, started doing things.

Also skipped exercising today for reasons.

Though, maybe I'll still exercise. I didn't eat so much that it'll hurt, I think.

Anyways, been messing with Wing IDE 101 as someone I'll be working with wants to use it.

As I'll be helping this person out, it may be of use to document what I'm doing to set it up to my liking. Thinking this reminded me to start logging here in my diary.

Sun May 14 11:38:33 UTC 2017

So, plan is to log what I've done so far here, and then continue doing things whilst logging them here. Then I can formalize what I've done into a proper post for this person (and whoever else) to read.

Custom key-bindings are available to add via the Wing IDE itself in Wing Pro, but not in the free Wing IDE 101.

However, key-bindings are set via simple key-binding files in the folder where Wing IDE is installed ("C:\Program Files (x86)\Wing IDE 101 6.0" on my computer). This files were editable only by admins, which made editing them in an editor of my choice annoying, so I:

  • Changed the keymap file permissions so that I can edit them as me
  • Added "'Ctrl-L': 'python-shell-clear'" to the end of keymap.normal

I need to constantly clear the python console, Stephan. I need to! For the person I'm working with, setting custom keybindings might be useful information.

It looks like Wing Pro has versioning support for many versioning tools including git which is the only one I'm interested in. Wing 101 has no such support. I think we'll try using means outside the IDE to do versioning. Though, we'll see.

Edit -> Preferences -> Editor -> Auto-Completion

Knowing about the auto-complete functionality and setting it to one's preferences is always smart. I set it to "Always" instead of "Never". Under "Never", you have to explicitly press Ctrl-Space to invoke the auto-completer in both the editor and the shell. In the editor this is fine, but in the shell pressing tab is so ingrained that it actually inputting white-space is a bit annoying. So, I'll try Always and see if the constant pop-up of auto-complete recommendations annoy me in the editor.

Found a potentially useful link: Using Wing with pygame.

Also, for other projects: Using Wing with Django.

Also, for how I found the command for clearing the python shell: Command Reference. python-shell-clear was in Debugger Commands as the python shell in Wing isn't actually the python shell, but a custom shell using debug stuffs for reasons.

I believe that's everything I did so far. I'm going to read that pygame link now.

Sun May 14 11:58:20 UTC 2017

It doesn't have anything relevant to say, unfortunately.

Sun May 14 12:00:47 UTC 2017

Let's start making a game prototype in Wing and see what I feel like I need to figure out and look up whilst doing that.

I'm using virtualenv for pygame! How do I use the virtualenv I'm using in Wing? Using Wing with virtualenv Python. TL;DR, use the virtualenv's python executable as python path in Wing.

Sun May 14 12:15:59 UTC 2017

Is there any good reason to use Wing 101 over also-free Wing Personal? Let's find out by downloading it and poking at it.

Well, there's a lot more stuff on startup. Maybe overwhelming to a beginning programmer.

However, it has key mappings in the IDE. Not something you have to pay for afterall!

Sun May 14 12:33:51 UTC 2017

I will discuss with person over whether he's committed to 101 over Personal.

Neither has the versioning support, though. That's Pro only.

Sun May 14 13:09:43 UTC 2017

Something is causing the virtualenv version of python.exe to open a link to ipython, which happens whenever the shell is restarted in Wing, and it is very annoying. I can't stop it from happening, either.

Sun May 14 13:23:05 UTC 2017

It took me about 15 minutes to realize it was my pythonrc doing it, because pyreadline wasn't installed in that virtualenv.

I may have sworn at past me for using copy-pasta there.

Sun May 14 14:04:41 UTC 2017

Am using this example of setting up the python shell now. This doesn't affect Wing IDE stuff, I don't think, it just won't open up a web browser when it can't import the things.

Also, some other annoyances popped up that aren't worth investigating but I wasted time doing that anyways.

Sun May 14 14:53:03 UTC 2017

Let's start making a pygame prototype!

Sun May 14 18:14:01 UTC 2017

I had an excuse to take a picture of my standing "desk" and figured I'd post it here.