New Gfpoken, Ngfp, Npath, Pathological, Pyglet, And Python
TABLE OF CONTENTS
- INTRODUCTION
- THE GOAL
- HOW TO PLAY
- RUNNING THE GAME
- CONFIGURATION
- LOADING AND SAVING GAMES
- SAVED GAMES
- PYTHON, C, ENVIRONMENTS AND DEPENDENCIES
- PROJECT CODE AND BUG REPORTING
- NPATH AND PATHOLOGICAL
INTRODUCTION:
I wanted a project for learning more Python (a programming language) that also involved some sort of graphics since I had not done anything like it before.
Gfpoken is written in C (another much older programming language) and I like playing it from time to time. So looking around I tried out Pyglet (a Python package for doing graphics and other things) and that was fun enough so I dove in and made another version of Gfpoken in Python 3.
Ngfp is New Gfpoken. Ngfp is a marble logic puzzle game.
Just to be clear Gfpoken still exists and also can be played.
Since then I’ve been playing Ngfp and fixing a few bugs or issues I’ve found with it, but on the whole it only got me part ways into learning Python. In the past few months I’ve started yet another project. Another marble game that I have enjoyed playing is called Pathological and that uses a python graphics gaming system called Pygame. Well at first I thought I would rewrite it in Pyglet. Pygame is quite different than Pyglet so that became a bit more than I really was able to do, then I came across the more general issue that I wanted to be able to resize the game grid and tiles if the person running the game was wanting to resize the window. So that has taken me down a different pathway for now.
In the end what I started and am still working on is a more general framework for a tile based games. I’ve called this project Npath. It is also another Python learning project for me. Npath is based upon Ngfp but I’ve removed a lot of the complexity, like there’s no dependency now upon Gtk3. What I also wanted to do was to get away from having two different licenses so I removed the artwork that was under the GPL licenses and done my own, and have been learning about Python classes and using more OOP concepts. There is still a ways to go in this project before it is closer to what I am after, but it is coming along. Details and a link down below starting in Chapter 10.
THE GOAL:
Simple (or not so simple) to solve the puzzle by placing mirrors which can change the direction a marble moves through the grid.
HOW TO PLAY:
Starting a new game brings up an empty guess grid (on the left) which you need to place the mirrors listed and piled on the right. Clicking on a pile will let you pick up a mirror (you do not need to keep the mouse button pressed down to move a mirror) and then move the mouse to some place on the left grid and click to drop it. You can also rotate existing objects (if they can be rotated) on the guess grid by right clicking the mouse on them.
To gain information about where to place the mirrors you left click any white square along the edge of the guess grid to start a marble rolling through the grid. It will give you indications arrows of where the marble goes in and most of the time it will also give an indication arrow of where the marble should come out (some mirrors absorb the marble or some arrangements of mirrors can set up a loop which means there will not be an exit indication arrow). The marble showing on the screen is what interacts with the mirrors you have placed so until you have solved the puzzled the marble may end up in a different location than the exit indication arrow.
You have to use all of the mirrors listed on the right side of the screen. Sometimes you can have a solution which is a functionally identical match and that counts as a winner for this game along with an exact match.
Instructions and help are available in the game (clicking on the ? icon will give a short help screen - pressing F1, ? or H will give a longer help screen).
RUNNING THE GAME:
For Posix/Linux/Unix type systems:
Opening a terminal and using the command “runngfp” should start it.
For Windows type systems:
Opening the command shell and using the command “runngfp” (or perhaps “runngfp.exe”) should start it (but because I do not have a Windows system I have not been able to test this myself to verify things yet).
CONFIGURATION:
You can change the difficulty and size of the game via the Configuration dialog screen.
For Posix/Linux/Unix type systems:
Everything should work. See the About screen (question mark icon) and Help screens for more details.
For Windows type systems:
Not working yet. The game should run and be able to change the configuration but you cannot save or load the configuration (you can edit config.py to change the defaults if you install the source code version of ngfp).
LOADING AND SAVING GAMES:
For Posix/Linux/Unix type systems:
Everything should work. See the About screen (question mark icon) for locations where games are stored.
For Windows type ystems:
I am still working on getting everything set up for Windows but Ngfp should still work as long as you don’t try to load or save a game.
SAVED GAMES:
I have 50 interesting games of not impossible degree of difficulty to try out in:
SG_01
SG_02
SG_03
SG_04
SG_05
SG_06
SG_07
SG_08
SG_09
SG_10
SG_11
SG_12
SG_13
SG_14
SG_15
SG_16
SG_17
SG_18
SG_19
SG_20
SG_21
SG_22
SG_23
SG_24
SG_25
SG_26
SG_27
SG_28
SG_29
SG_30
SG_31
SG_32
SG_33
SG_34
SG_35
SG_36
SG_37
SG_38
SG_39
SG_40
SG_41
SG_42
SG_43
SG_44
SG_45
SG_46
SG_47
SG_48
SG_49
SG_50
PYTHON, C, ENVIRONMENTS AND DEPENDENCIES]:
For Posix/Linux/Unix type systems:
If the binary wheel supplied via pip3 isn’t suitable for your computer architecture you will need a C compiler for getting Ngfp properly installed. Python 3 is also needed if for some reason it is not already installed.
I always recommend setting up a Python virtual environment to help keep projects isolated from the system’s Python setup.
Most Posix systems have Python 3 and a C compiler already installed so you may only need to get Ngfp and the dependencies via using pip3.
I’m unsure of what commands all of the various distributions use to install packages, but for Debian GNU/Linux I use apt install or apt-get install. Once you have the python3 and gcc packages available then pip3 install ngfp should bring in the rest of the needed dependencies.
For Windows type ystems:
I am still working on getting everything set up for Windows but Ngfp should still run. The problems of getting a binary compatible wheel done have not yet been figured out yet either, but if you can make it through installing Python 3 and the Windows C compiler then it should also run.
PROJECT CODE AND BUG REPORTING:
The above is meant to only be a quick summary of how things are as most of the instructions for running the game are included in the game itself. Eventually I will also have the manual page working for a Posix/Linux/Unix type system for more details (it is in the source code version already not sure if it gets installed correctly yet) and also I should get the Windows aspects figured out.
Other goals of this project have been to learn new things like how to use git and how set up a public place for this code at:
You can also get Ngfp directly as a Python module/package from:
I try to keep the TODO file up to date with what is being worked on, but also happy to have help or issues filed via the bug tracker/issues functions or sent to me via e-mail.
NPATH AND PATHOLOGICAL
While Npath is based upon Ngfp it is changing quite a bit and simplifying. I have not yet put it on PyPi so you can follow it via github:
Mainly this is yet another learning project for me trying to get my head more used to OOP concepts and how they’ve been implemented in Python. It is also encouraging me to get deeper into different aspects of Pyglet and OpenGL so I’ve been reading up on those more and trying different things.
In the above git repository you can see how I’ve taken out and changed large parts of Ngfp. None of this is a prime example of Python or OOP concepts, but I am learning and having fun. If you go back and follow along in all of the changes in the various tagged versions from the start it is quite a mess, but I am ending up with just the framework that interests me.
The end goal is a fully dynamic interface where I can change the grid cell size and the grid adapts to the size of the window itself when the user changes it via Mouse dragging or keyboard commands.
For now the separate configuration file and directory were also removed as that added more complexity where all that was really needed was the information saved with a game itself. Also there is only one saved game file being used and if it exists Npath with start up using that file. If it doesn’t exist then Npath with start with a randomly generated board of the default size.
The basic commands are via keyboard or mouse. Start by pressing F1 and that prints out the commands.
As of yet there really isn’t a game of any kind in Npath. It is only a starting point for adding something later. I’d like to get the more general concepts ironed out first.
Now where does Pathological fit into this? It is another marble game I’ve enjoyed playing for years. I thought at first I would adapt it with Pyglet instead of Pygame. I did some work on that, but the two approaches are different enough that I’ve abandoned that for now. I made a few changes to Pathological (mouse wheel scrolling) to make it easier to play.
Eventually we’ll see if I can get Pathological done under Pyglet but in the meantime my changes are at: