Generic Fantasy Writer Bot

My boyfriend and I have something we call the “David Eddings Game”, where we make up the silliest, most generic fantasy book titles. Stuff like “The Dragon’s Quest” or “The Mage’s Folly”.  Its just based on a sequence of “A-Something’s-Something”, so I thought that it would be pretty neat to make a bot that plays this game.

I created a .csv database of fantasy words, then created a script that would make random sentences out of them.

17

I had four classes – word, sentence, database and generator. From sentence I created three instances of word, one for each row in my csv, and combined them into a sentence. In generator, I used sentence but used some of the functions defined in database to check whether the string had already been created and skip if if so.

18

I then created an account and app for my bot on twitter, had my script create the api and then every time it is run, generate a random sentence and tweet it. A lot simpler than I imagined it would be!

2019

16

 

GameMaker 2.0

I spent a couple of hours this Saturday learning some GameMaker 2.0 basics, as I’m going to be involved with helping some young people learn to make games this August.

Importing Assets

The types of 2D assets in game maker are quite nicely broken up – into sprites, tilesheets and objects – much like you see in professional game engines with Unreal’s example of textures, materials and blueprints. It might be a bit unfair not to call GameMaker a professional engine – with games like Hyper Light Drifter being created in it, it really is a powerful 2D game creation tool.

1

The first thing I created was an animating sprite for my character (with some really messy ph art!!).  Game maker is able to take a sequence of separate images and combine them in the sprite editor to create an animation. No need to use texturepacker or other similar sprite sheet creation tools.

4

This led me to a lot of questions – I’ve been in a 3D AAA bubble the last couple of years and the difference as a TA between this and something like mobile 2D (which GM seems perfect for) is very big! For starters, gm has no gpu based texture compression, which is like sacrilege to someone used to large 3D engines!

  • Do we use .png?
  • How do we ensure good texture compression and mipmapping if we have to do it ourselves?
  • With .pngs its important our alpha is most accurate – I know that we can ensure this with DXT/BC compression as the alpha channel is always most accurate, but how do we do this ourselves?
  • What can a mobile gpu handle?
  • How much memory can we realistically work with on mobile?
  • How does GM treat an animating sprite – as many small images or is there texture packing behind the scenes?
  • In fact, with a small 2D game like this, is there any streaming and if not does it load everything at once?
  • What does a 2D animation pipeline look like? I had to save out a lot of pngs from one psd – for sure that one needs scripted! (Being a TA has made me oh so lazy…)

I’ll answer these questions in a separate blog post later!

Objects, Collision and “Drag and Drop” 

To use a sprite within a game, it has to be made into an object or tileset. An object is useful for something that will have scripted behavior, like a character, and a tileset is for creating environment art. The tilesets are like spritesheets, in that you create a number of tiles in your image and then define the size of each tile in the tile editor. You can then place each of these tiles inside your level.

1415

I had some trouble getting collisions working correctly – I wanted to add gravity so that my character could jump. There are two ways to define collisions in gm, the internal physics system and the basic collision system. The physics system prevents updates of object co-ordinates per frame, as it would mess with physics calculations. This meant it was unsuitable for my project, as my characters movement was defined by position += 4 when the left or right arrow is pressed.

6

I set that up using the drag and drop system, which is similar to the node based systems that I use at work. Personally I’m a big fan of these sorts of systems, they’re a great visual introduction to programming principals and can be very powerful in their own right.

Even though I didn’t use it in the end, a couple of tips that I learned about the physics system:

  • 0 Density = Static
  • Objects must have a collision group that matches and is above 0 to collide with each other
  • Check the physics collision shape (which is different from the collision mask) when using this system

1011

Final Outcome

What a mess! Some really strange placeholder art going on here. But I’ve learned the basics and feel like I’ll be able to help the kids ready their assets for import.

gamemaker