NoSQl or SQL?

NoSQl or SQL?

Da
Image by Gerd Altmann from Pixabay

I’m still continuing C# development but no longer on MonoGame. My needs have now switched to Flutter. If you haven’t come across it, it’s a cross-platform mobile development system from Google and uses their Dart language.  This is a modern language originally created back in 2011 as a potential replacement for JavaScript. That didn’t work out as other browser creators (Microsoft, Apple and Opera) didn’t go for it.

So Dart sort of languished until three years ago when Flutter emerged as an alternative to POA (Plain old Android development in Java/Kotlin). Flutter is the UI technology- interestingly it redraws the screen controls at 60 times per second, a bit like MonoGame. But this is no game.

The UI is programmed in Dart and it has one unique feature: You can make a change and see it live in one second. It’s called Hot Reload and compared to the old Compile, redeploy and run cycle is quite amazing., Also Flutter is cross-platform and has controls for iOS that look like Apple native controls.

Now my big decision is whether to use SQL or NoSQL to store data. The data isn’t exactly ordered like a schema, more like each database record has a variable number of name=value pairs. Which certainly suggests something NoSQLish.

 

So no response to the programming challenge

So no response to the programming challenge

Pen and paper
Image by Karolina Grabowska from Pixabay

A month ago I set a programming challenge but have had no response.  This could be not enough visitors (about 15-20 a day), or the nature of me posting daily on a WordPress blog where entries vanish.

That challenge was to identify the 100,000th number in a sequence of nine digits numbers that start at 1234567879 and finish at 987654321 where each digit only appears once. It’s relatively easy to program.

It’s also not that difficult to do manually if you think of factorials. As each digit appears once there 9! different numbers possible. There are 9 possibilities for the first digit then 8 for the second and so on. 362,880 in total. (I think…).

So of all the numbers in the range the first 8! (40,320) must start with 1, the 2nd 8! with 2, the 3rd 8! with 3. So the 100,000th is going to start with a 3 as it occurs somewhere between the 80,640th and the 120,960th. You can then apply the same logic to work out where the 2nd digit is going to lie and so on. I did it on a piece of paper and it took me about 20 minutes to figure.

You don’t need maths (or math as US readers will be familiar with) to program computers but on occasions it can come in handy. Especially with games and random numbers, combinations and so on.

Consider entering a game jam

Consider entering a game jam

Game jamsMuch as I like creating games, game jams are not really my thing as I like to spend time polishing and making them look good and that’s not really how you want to spend your 24-72 hours.

But clearly they are for others as the GMTK Game Jam in 2020 had over 5,000 entries! Here’s a GitHub staff pick of their favourite top ten entries.

What is a game jam? Well Wikipedia helps out “A game jam is a contest where participants try to make a video game from scratch. Depending on the format, participants might work independently, or in teams. The contest duration usually ranges from 24 to 72 hours. Participants are generally programmers, game designers, artists, writers, and others in game development-related fields.”

There are probably more game jams going on than you imagine. The itch.io website has a list of forthcoming game jams plus links to past ones.

How I track ideas

How I track ideas

About twelve years ago I came across WOAS (= Wiki on a Stick). It was a single HTML file notebook with built in JavaScript and you opened it in a browser. It showed a simple interface and you could switch it into edit mode and start adding in text in markdown format. It was very easy to create links to pages in the document and add new pages.

And it was all saved in the document. Also very easy to find the text. It had one excellent feature which I miss, You could have a page self-encrypt using AES-256. Great for holding passwords etc.

I used WOAS to deign software and had at least one very detailed design with several hundred pages each with links to other pages. Sadly WOAS was eventually killed by the browsers themselves, preventing files writing to disk. It’s not the only example of a single-file Wiki but they all suffered the same problem. I think someone came up with a Java shim that did the file writing but it was never the same.

Now I use WikidPad, it’s written in Python and I think just runbs on Windows, (though you wouldn’t know it) which works like WOAS but internally it uses SQLite to hold the Wiki pages.  You can even use their website WikidPad but you have to register first.  That picture is a screenshot of WikidPad.

An example of a game idea

An example of a game idea

Sometimes I wake up in the middle of the night and my brain is bursting with ideas. I’ve just finished reading Shaman by Kim Stanley Robinson that’s set 30,000 years ago and came up with ideas for a tribes game very loosely based on that (Absolutely nothing to do with the plot of the book!) .  I opened up my iPhone around 3:00 a.m. and these are the notes I wrote down in the Notes app.

I opened my email (Gmail) which picks up notes from my phone automatically, so I have the notes now here in my PC.  They are as I wrote them so they are quite rough.

“Tribe game. All players start with a small village and 50 tribes people.
Can relocate, hunt, plant etc. Can raid other tribes. Can split tribes spread over land. Have children. Found religion. Use animals. New options as tribe progresses. Discover and trade gold, furs. Tribes can move to other places or settle and form villages.
Raids build up resentment between tribes. Enough resentment leads to war. But can reduce resentment by gifts of women, food, furs etc st festivals.
Can do crafts, paint, culture, spirituality, warfare, building. Each has 1-10 levels with names. Orders focus on an area.
Better food means stronger, smarter.
Periodic festivals. Tribes get together and share attributes.
Run for 1,000 years. 100 turns x 10 years. “

And that’s how they go into WikidPad. Then I start fleshing them out into a fuller multi-player game.  Of course I come up with lots of ideas and few will make it into an actual game creation but its always a good idea to keep them. In the future it may yet become a game…

And how was the book? Very good.

How to create an Alphabet bitmap in CSharp

How to create an Alphabet bitmap in CSharp

Letters generated by the programHere’s another short utility. I have been looking for a decent alphabet to look in my next game (called HogWash) . As before, I want to create a sprite sheet with letters. But every alphabet set that I found had issues with kerning. I kid you not, usually but not always with M, W, or even Q.

Even when I put together a sprite sheet manually, the editor didn’t quite get it right and letters didn’t quite fit the grid. So to simplify it, here;’s a 50 line C# program that takes the letters you supply in a string, combined with a font (Liberation Mono- from Red Hat) and a brush (black solid). It does a double loop that I exit with a goto (shock horror!) when it reaches the a terminating * in the string I supplied.

That is the graphic file above that the program below generated. As you can see the letters are far enough apart so no overlapping. Just put in your path where I have for the source and dest consts. You can use this technique for building sprite sheet.

// Author D. Bolton Learncgames.com You are free to use and copy this program as you wish but please leave this line in.
using System;
using System.Drawing;
using System.Drawing.Imaging;

namespace buildfont
{
    class Program
    {
        const int LetterWidth = 100;
        const int LetterHeight = 120;
        const string source = "Your path"
        const string dest = @"YourPath\letters.png";

        static Bitmap allLetters = new Bitmap(LetterWidth * 8,LetterHeight * 5);

        static void Main(string[] args)
        {
            BuildOneImage();
        }

        private static void BuildOneImage()
        {
            var font = new Font("Liberation Mono",95);
            var brush = new SolidBrush(Color.Black);
            var str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ*";
            Console.WriteLine("Creating letters.png");
            var aty = 0.0f;
            using (Graphics g = Graphics.FromImage(allLetters))
            {
                var strindex = 0;
                for (var y = 0; y < 5; y++)
                {
                    var atx = 0.0f;
                    for (int x = 0; x < 6; x++)
                    {
                        string aLetter = str[strindex++].ToString();
                        if (aLetter == "*") goto Done;
                        g.DrawString(aLetter, font, brush, atx, aty);
                        atx += LetterWidth;
                    }
                    aty += LetterHeight;
                }
            }
            Done:
            allLetters.Save(dest, ImageFormat.Png);
        }
    }
}
A spot of market research

A spot of market research

Raspberry-Pi
Image by Benjamin Nelan from Pixabay

This is market research for a side-project I’m working on. I’m developing a server and mobile clients to play multi-player games over WiFi. The server software would cost about $15/£12 and 1$ for the game client on Android/iOS. It will come with 8-10 games including card games such as Texas Holdem, and a board game or two. All games will be single-player as well (well not poker!). If it takes off I’d like to licence popular board games.

There will also be an SDK for creating new games and some financial arrangements for games to be sold through a “Pi bakery” i.e. app store. Games can either be included in the standard package or low cost add-ons.

I’m just trying to assess if there would be demand for it. If you have any comments or thoughts, I’ve posted this on the Raspberry Pi forums. as well.

It is often said that you shouldn’t give away ideas but I’ve decided to anyway. I really need to find out if anybody would buy this. If not then I have a plan B side-project waiting in the wings. But I do like this and I’ve already gone down the implementation route a bit.

Update

Sadly I have decided to ditch this side-project. I didn’t get great response; although there are 31 million Pis out there, getting people together especially with Covid is not easy. So I’m mothballing this for now. There is a B2B commercial possibility but I’ll come back to that in a year or two. Instead I am going onto my next project a mobile MMO.

A graphics editor in C

A graphics editor in C

Screenshot of grafX2 As the picture shows, no one has ever accused me of being artistic! Hey I can’t be good at everything (sometimes it feels like anything but it passes!) and I’ve long ago accepted that I never will be an artist.

But I can get by with graphics as I hope all the pictures on this site show. Either they are screenshots or comes from sites like pixabay.com and unsplash.com. Both are excellent sources of free images.

Sometimes though I have to do a lot of editing. MonoGame requires bitmaps for fonts. So I’ll take a free monospaced font and choose a size and create a sprite sheet from it.

But sometimes the tools I use are less than perfect. I never mastered or bought PhotoShop. Instead I used software like PhotoDraw 2 (from Microsoft in the early 2000s) or before that Macromedia Fireworks. But these are quite old and instead I’ve been looking around for something a bit newer.

There are quite a few open source graphics editors and if you look closely at my er artwork you can see at the bottom that this was taken from one such package called GrafX2. One reason for including it is that it’s coded in C and it reminds me of the granddaddy of drawing packages : Dpaint. As we’re talking over 30 years ago, I don’t know how many will remember it.

Monogame 3.8 is now out

Monogame 3.8 is now out

Monogame 3.8 releasedThese don’t come that often and this one has quite a few changes. You can read all about it on their What New page.  The main changes as far as I am concerned is the .NET Core support, templates in VS 2019 (finally!) and distribution via Nuget.

Interesting though that the Pipeline tool is dead, Long live the Pipeline! It’s now called the MCGB tool. I think it’s more a rebranding than completely new or maybe it is (apologies if that’s the case). And I notice that text is a resource type that you can add BUT on Android, no point in compressing things because apks are compressed anyway. Here’s a big secret, apk files, like Java .jar files are just zip files.  Yes you can view their contents with WinZip!

If you are a 3.7 MonoGame user (as I am), you should probably readthe migrating from 3.7 web page.

 

Geomorphing for the masses

Geomorphing for the masses

Geomorphic village by davesmapper.comThis is very clever. The website Davesmapper.com lets you create different type of geomorphic terrain maps, whether it be dungeons, city or village or even the interior of a spaceship.  You get a choice of tile sets according to what type of terrain you’ve picked. If you are artistic, you can upload your own designs. This mixing and mashing of tile sets can lead to some very odd looking cities with each tile a different style!

The view options controls lets you change how many tiles wide and high your map is, but watch out, the tiles are quite big so go above say 16 x 16 and you start to generate maps that are too big to export.  The village at the top of the post was 2100 x 2100 pixels when exported.

The terrain maps generated are very nice. If you think these look a bit rough, it’s probably my fault. To speed up this website all images are both shrunk to typically 350-450 pixels wide and compressed and some images are possibly not quite as nice looking as their uncompressed originals.

This city below shows you the type of thing with two greenish tiles and a bluish one. You can untick the tile sets that you don’t want.

Geomorphic city from davesmapper.com

Geomorphic means it’s made of tiles that are almost always square and they fit together so that doors or passageways always join up.

Back in my D & D (Dungeons and Dragons, not drunk and disorderly!) dungeon mastering days (about 1979) I use to have a set of physical geomorph tiles. They were great but sadly lost along with my D & D toolbox that had all my figures.

There are some computer games where you might use geomorphic graphics; perhaps a procedurally-generated dungeon crawler.