csanyk.com

video games, programming, the internet, and stuff

Category: design

GameMaker Marketplace Asset: PNG_2_room

PNG_2_room is a simple, easy to modify demo for how to populate a room with instances according to a color coded image file.

Each pixel in the source image can be color coded to correspond to an object or tile in your game. Use the script room_instance_add_from_png() to populate a room with instances using the image as a key.

For example, this PNG image:

rm_test

…was used to generate this room:room

You can modify the script to use whatever colors you wish to represent whatever objects or tiles in your project.

With this script, instead of using the built-in room editor, now you can use any image editor to create maps for your game more quickly!

You can even allow players of your games to create their own custom maps for your game, using whatever image editor they choose as a resource editor for your game!

A simple demo included in the asset shows how to use the script.

Full documentation at: https://goo.gl/z3du5f

Purchase at the GameMaker: Marketplace.

The Best Laptop Keyboard Yet Devised By Humankind

Laptop ergonomics are always a compromise. If you put in long hours on a laptop, you know how important comfort and usability are to productivity. So getting the best possible ergonomics given the constraints imposed by the design requirements is extremely important.

It seems many hardware design engineers have forgotten this. The quest for thinner, lighter, cheaper seems to have overshadowed comfort and usability, durability and ruggedness. With each passing hardware generation, we see the same refrain: “The new keyboard is not so bad, once you get used to it.” If we have to get used to a “not-so-bad” keyboard with every generation, doesn’t that suggest that they’re getting worse over time?

And yet, the keyboard is the one component of a laptop that you have the least configuration options for. There are no choices, no upgrades; the keyboard is the keyboard, and you get whatever the manufacturer designed. That means it’s all the more critical that manufacturers give their customers the best possible keyboard.

What if manufacturers gave us keyboards that didn’t take “getting used to”, but felt fantastically comfortable from the moment you used them?

Without a doubt, the best keyboard I have ever seen or used on a laptop has been the keyboard of my Lenovo ThinkPad T61p. It’s no secret, and everyone who’s used one knows how good they are and how far short any other laptop keyboard compares. This keyboard is so good that I’ve continued to use my T61p originally purchased in 2007. After my original T61p died this January, I shopped around looking at the new ThinkPads… and after looking at what was available, I went to eBay and bought myself another T61p.

I won’t be able to do that forever. Already, I feel a need for a machine that can support more than 8GB of RAM, and the new Core i7 CPUs are so much faster than my by-no-means inadequate 2.4GHz Core 2 Duo. And the battery life we see with the current generation of “ultrabooks” in 2015 is impressive.

Will we ever see a return to the keyboards of yore? It wish that it was not in doubt. But I have hope. It appears that Lenovo has finally responded to customer feedback, when this spring they brough back the old style trackpads with physical buttons that had disappeared with the 540 generation. And today, it appears that they are actively soliciting fans of the old ThinkPad brand to ask them what features made the old ThinkPad so legendary. And they updated the X1 Carbon with a more standard keyboard layout in response to complaints and criticism over a senseless radical departure from the norm. Perhaps we’ll glimpse perfection again someday.

To be sure, we will not see a return to greatness if we fail to recognize the things that made the best keyboard of all time so great.

Close to perfection

Behold, The T61p keyboard in all its glory.

T61 keyboard - crop

Let’s take a look at what makes this keyboard so great.

The Good

Full-size keys, spaced the correct distance apart. This makes typing for long periods of time less tiresome, especially for people with larger hands.

Scissor Switch technology allows for longer travel for a laptop keyboard, which is more comfortable than “chiclet” keys. It’s not a full height keyboard like you’d find on a desktop class machine, but it’s very close, giving it a good feel and making it more comfortable again for long typing sessions.

The layout of the non-standard keys is ideal.

It’s important to appreciate how critical the placement of these keys is. Let’s look at them in detail.

A full row of Function Keys, F1-F12. In many newer layouts, this row is eliminated and the F-keys are combined with other keys. This makes compound keystrokes impossible if the F-key needs to be pressed at the same time as the key it is combined with. That’s probably pretty rare, but it is still nice to have this row of keys to themselves. I think keyboard designers eliminated this row in order to make room for larger trackpads. I don’t like large trackpads for a few reasons, which we’ll get into in the Trackpad section.

A full row of real F-keys

The arrow key cluster. Most importantly, the arrow keys are all full-sized, and arranged in an inverted “T” formation. Many keyboards save a key by squishing the up and down arrow keys into the space of a single key, putting all four arrow keys in a line, but this space savings comes at a cost of making up and down half sized, and makes controlling games that use the arrow keys way harder.

The other important thing about this cluster is the presence of the “Previous page” and “Next Page” buttons to either side of the up arrow. These are often replaced with “Pg Up and Pg Dn” buttons. I like “previous” and “next” here because it makes navigating web pages with this cluster very fast. I don’t have to move my fingers at all and I can scroll and hit the Back button or Forward button in a web browser. It’s very convenient, and I really miss it whenever I have to use a keyboard that doesn’t have this layout.Arrow Keys + Fwd-Bck buttons = awesome document & browser navigationThe Insert|Delete|Home|End|PgUp|PgDn cluster. I really like these where they are, too. Being at the top right corner of the keyboard makes them simple to find by feel, without having to take my eyes off the screen. The Home/End and PgUp /PgDn pairs go very naturally together for navigating text documents with the keyboard. These navigational shortcuts are a great alternative to scrolling with the mouse wheel, and for moving the cursor when text editing. Insert and Delete change the cursor mode, Home and End can take you to the beginning or end of a line of text, while Ctrl+Home or Ctrl+End will take you to the beginning or end of the entire document. Pg Up and Pg Dn are better for scrolling than the mouse is, moving an entire window height up or down at a single keystroke. Clustering them in this arrangement makes for very intuitive and quick document navigation using the cursor, and enables me to be much more productive when working in text files or reading than if I have to move my hand to the trackpad or mouse.

Insert-Delete-Home-End-PgUp-PgDn = logical layout perfection

Print Screen, Scroll Lock, and Pause/Break. These don’t get used a whole lot by most people. I use Print Screen all the time, to make screen captures, but the other two hardly at all. Putting them up here out of the way works. Having Print Screen at the left edge of this 3-key row makes it easy to find by touch, without having to take my eyes off the screen to look for it.

PrScnSysRq-ScrLkNumLock-PauseBreak

While we’re looking at this group, note the power button (the circular button at left.) While not part of the keyboard, proper, I will remark that I find the power button difficult to find by touch. If I’m fumbling around in the dark, it’s easier to find the ThinkVantage key, which feels more like I’d expect the power button to feel like. So, one thing I could recommend is change the power button, locating it closer to a corner of the keyboard, and give it a shape and feel more befitting a power button.

Keycaps shape and feel

All the keys are just shaped right. These keycaps are close to what old classic IBM Selectric typewriters and Model M keyboards felt like, and those were some of the best keyboards ever manufactured.
The best type of keys for a laptop

The Enter key isn’t L-shaped, which leaves room for the \| key directly above. The \| key doesn’t really have a reason to be larger, but it keeps symmetry with the Tab key on the left side, and helps a touch typist feel this edge of the keyboard. Esc isn’t double-sized, as it is on some later model Lenovo keyboards — I think making it the size of the Ctrl key, slightly larger than the standard key, would make it easier to find by touch. Ctrl is slightly wider than standard, but I like that, although it would be better if Ctrl were in the position occupied by Fn, where it belongs. Backspace is another good key to be larger than standard, as it is used frequently by most, and this makes it easier to find in the top right corner.

Sufficient Key Rollover: a must have

[Updated 4/20/2016]:

Keyboard Rollover is is the ability of a computer keyboard to correctly handle several simultaneous keystrokes. N-Key Rollover (NKRO) is the ideal — it means that the keyboard can handle any number of simultaneously key presses. At a minimum, a good keyboard should have 6KRO.

I’ve mostly used high-end keyboards that have high #KRO or NKRO, and have only recently encountered a keyboard with low KRO. Unfortunately this happens to be my new ThinkPad P50, which is a great laptop in most respects, but it has a paltry 2KRO. If I’m holding down more than two keys simultaneously, a third key press often is not detected (depending on which keys are down). This makes the keyboard hopelessly unsuited to gaming, and as a game developer, this is really not acceptable.

You can test the key rollover of a keyboard by holding down both shift keys simultaneously and then trying to type the alphabet. If any letters don’t type, your keyboard has low rollover. This should never, ever happen on a high end machine. Or any machine, really.

Nitpicks

Fn/Ctrl positions should be swapped

On most keyboards, the Fn key is nested between the Ctrl and Windows keys. On the T61p layout, this is reversed. There’s no reason for it, and it’s one of the most common complaints about the T61 layout. In fact, there are even third party firmware hacks to remap the keys into their preferred positions: Ctrl outside, Fn to the right. In the ideal keyboard layout, Ctrl should go first.

switch Ctrl-Fn positions

Controversial items

10-Key or not 10-Key?

Many widescreen laptops have 10-key numeric keypads these days, much like 104-key extended keyboards on desktop keyboards. This forces the main keyboard off-center with respect to the screen, which means that the users arms and hands will have to skew left of center the majority of the time when typing, which feels awkward. Unless you do a large amount of numeric data entry, a 10-key is not necessary or recommended for a laptop keyboard. Thankfully, at least the trackpad is still centered under the space bar, keeping it directly between the hands on most laptops with extended keyboards that incorporate a 10-key pad. But typing on the QWERTY keyboard, with the hands offset relative to the screen is less comfortable. The extra keys of the 10-key pad also add to the complexity and cost of the keyboard.

Most users don’t need a 10-key pad, and can live without. Unless you’re doing heavy numerical data entry, they don’t add of value. You could always buy a USB 10-key pad as a peripheral and use that if you needed one. Before laptops started sporting 10-key pads on the right of the main keyboard, they used to use the Fn key to use the right half of the keyboard as a sort of slanted 10-key option. I’ve never bothered switching into this mode, and don’t miss a 10-key pad. So, my preference would be for a regular QWERTY keyboard, without a 10-key pad, and the QWERTY keyboard and touchpad centered in the laptop chassis.

Still, some people will want 10-key pads and others will not — and the number who do not is not inconsequential. But the number of people who can’t live without a 10-key pad is much smaller than the number of people who don’t need it. I would prefer not to have a 10-key pad in my ideal laptop. This would be a good item to make a configuration option at time of purchase. Modular, interchangeable keyboard FRUs that have or omit the 10-key pad would be a great solution.

Are backlit keyboards necessary?

Again, some people like them, and some don’t. Illuminated keys can be helpful when typing in low light conditions, but they drain battery and add cost to manufacturing, although probably not significantly, since most laptop keyboards seem to use them these days. Most of them have an option to turn the backlight off and adjust the brightness level, and this seems to be the best choice. It enables everyone to be happy. On laptops which have this feature, I just turn the backlight off, and touch type as always.

Which type of switches is the best?

This is subjective and people can have their own opinions. These days, there are three main types of keyboard: chiclet, dome, and buckling spring. The T61p keyboard had scissor switches, a type of dome switch. These work and feel great — almost as great as buckling spring switches.

I find “chiclet” keys to be fine, I can use a chiclet keyboard without issue, and type fast and with confidence with them, but I still prefer the feel of the scissor switch keys on my T61p. Some people prefer the lower travel of the chiclet key, and manufacturers favor them today because they enable thinner designs. But I really prefer the feel of the full travel key caps, and the scissor switches in the T61p keyboard give a closer approximation of the way full travel keyboards feel.

The biggest disadvantage of the scissor-switch keyboard is that it adds to the overall thickness of the machine, but I strongly believe that thinness is a highly overrated feature. With ultra-thin laptops approaching 0.5 inches, there’s not much room left to go thinner. And there’s plenty of leeway for making a laptop a little thicker to allow for a better keyboard. The T61p is 1.4 inches thick, and I’ve never once felt that it was an issue. I would much rather have a thicker, heavier laptop that is more rugged and will hold up to years of heavy use, and has more room for expansion or battery, than a ultra thin and light laptop.

Really, though, on the switch type, I could go either way. Chiclet keys feel nice enough to be acceptable, but for longer typing sessions I truly like the additional travel and resistance of scissor switches. This is an area where making it a configurable option would be nice. A modular, interchangeable FRU keyboard offering the user their choice of chiclet or scissor switch keys would make everyone happy.

Pointing devices

While we’re at it, let’s look at the pointing devices. First, we have the TrackPoint stick, the red nub. People who use them really love them, and they don’t get in the way of people who don’t. They’re a vital part of the ThinkPad brand and image, and should never be done away with.

Next, we have the touchpad. The touchpad is surrounded top and bottom with physical mouse buttons. these are well designed and robust. Positioning them top and bottom is important because it makes them reachable to both the thumb and fingers, regardless of where the hand is positioned on the keyboard or touchpad, which makes using the buttons quicker. We also see a middle mouse button, which is useful for Linux users.

As for the touchpad itself, it is only 2.25 x 1.5 inches — which is ideal. Newer generation notebook PCs have trended toward larger touchpads, which allows for greater precision with reduced sensitivity, but I really prefer this smaller size. It is not so large that it becomes an easy target for accidental bumps by the palm of the hand. I never accidentally brushed the touchpad on my T61p with the heel or palm of my hand when typing, which means I never accidentally click the mouse cursor away from where I’m typing. I do have this problem on many newer model laptop keyboards, and it is a constant, huge annoyance.

The touchpad is not multi-touch capable, and that would be a good improvement to add to this design. It does have scroll regions at the right and bottom edge, which are configurable.

The UltraNav touchpad driver is excellent, with lots of configuration options to get it to work just how the user prefers.

T61-trackpad

What else?

It’d be great if keyboards were more interchangeable in laptops, across different models and manufacturers. It would take a great effort of the industry to standardize the top half of all laptop chassis to have the same shape and size space for a keyboard. But there’s no reason it couldn’t happen, if manufacturers decided to standardize, or if a manufacturer decided standardize within their own product lines. The computer industry has standardized on other things, so why not a standard to allow laptop keyboards to be more interchangeable between different models and makers? This could spur innovation in improving keyboards, since users would not longer be stuck with whatever the designers engineered for a particular model — users would be free to upgrade and choose the style and layout that they prefer.

I doubt that it will happen on an industry-wide level, that we’ll be able to buy generic commodity keyboards from any maker and put it into any laptop, there’s just too much inertia for it. But it could happen if the industry decided it wanted to. Even if it didn’t want to, manufactures could standardize more within their own model lines, and offer a greater variety of keycap types and layouts to satisfy the preferences of different customers. I expect the main reasons they don’t do so have to do with cost, and to some extent integration and aesthetics issues. But these are not insurmountable issues.

For me, a better keyboard is still well worth paying some premium for. A keyboard that doesn’t feel cramped, has a familiar layout for ALL keys, and a satisfying feel, for me, would be something I’d easily pay another $50-100 for, if it were an option to purchase an upgraded keyboard that was just the way I like it.

Thinking about a human-like AI for playing Scrabble

[I got into playing Words With Friends on Facebook and my mobile phone back in 2012, and started writing a lengthy article on designing an AI to play scrabble-like games in a manner that convincingly simulates a learning human. This weekend, several years later, I’m a spectator at a local Scrabble tournament, and decided to finally finish up my thoughts.]

Designing AI for Scrabble-like games

I’ve been playing the Zynga game Words with Friends with various people for a few weeks, and have gotten progressively better at the game. After looking back and reflecting on the evolution of my play, and the development of my strategy, I became inspired by the idea of a convincingly human-like AI that embodied the various stages of my development as a player.

While actually programming it is a little more effort than I want to put into it, even just thinking about the design for such an AI is interesting.

(more…)

Fibonacci Tartan and Kilt

Some time ago, Youtube channel Numberphile posted a video on a tartan based on the fibonacci sequence.

Inspired by this, I’ve created a fibonacci-based tartan of my own:

Fib7-7

Isn’t it beautiful?

My design is based on the first seven numbers in the Fibonacci sequence: 1, 1, 2, 3, 5, 8, 13. It uses one thread of yellow, then one thread of red, two threads of dark green, three threads of navy blue, five threads of red, eight threads of dark green, and thirteen threads of navy blue. To scale up the size of the sett, I will be multiplying these numbers by seven. I call the tartan, Fibonacci-7.

I just started a crowdfunding campaign to register the tartan with the Scottish Registrar of Tartans, and have a kilt made with it. It will cost an estimated $2250 to have it produced. Once registered, the tartan will become available to textile manufacturers to produce cloth and garments in this tartan.

If you are interested in math or just love a beautiful tartan, please consider donating to the cause, and spread the word. If every visitor to this site donated just $1, we’d have funding within less than one month. So if you’re a regular reader of this site and have found my articles on GameMaker useful, please show your appreciation by donating what you can. Thank you.

min.ttf

I have created a font I call min. It’s the first font that I’ve created. I used bitfontmaker. It was easy and fun, and I liked it. I want to do it more. Minimalist pixel art is something I enjoy, and I wanted to try my hand at the glyphs of a typeface, so I created the most minimalist typeface I could that was still legible. I might have been able to go further but I like the size. Most letters are 3×5 px or smaller in their original drawing.

It’s also an asset package in the GameMaker Marketplace. If it does well I’ll probably create a font pack of fonts that I develop over time, and see how that does. So if you’re a GameMaker user, please download it from there so I can get accurate analytics stats.

Update: I’ve added a second font to the collection, submin.ttf.

Download links

  1. Min Font – Free GameMaker Asset Pack
  2. min.ttf
  3. submin.ttf

Making a Configuration System in Game Maker, part 3: Where’s Part 3?

A while ago, I started a series of articles that I never finished, on creating a configuration system for GameMaker games. I posted Part 2 almost 2 years ago, and had intended to follow up in just a couple weeks with Part 3, but it stalled and never came out.

A few readers have asked, so I figure an explanation is owed.

The series I had started on creating a configuration system has been on hold since the second article. As I got into designing the system, I kept running into problems with making my system platform-independent and universal.

I had intended to write a universal configuration management engine for handling things like monitor resolution switching, master volume, music volume, and sound fx volume, and a customizable set of configuration widgets for whatever your game might need (essentially, a set of generic, reusable buttons, sliders, checkboxes, and other UI controls). Ideally, I had hoped to write a set of scripts that would use GML functions to define rooms and objects that would constitute the configuration system. Ultimately, I wanted to create a GML script config_system_create() that would set up the entire system — rooms, objects, and functionality, so that you could simply import a GEX extension, call one function, and have a full-featured system generated at runtime, without having to spend any time designing and implementing all the resources yourself. But in GM:S, YYG obsoleted the functions that allowed me to define objects at runtime, execute strings as GML code, and a number of other functions relating to how Windows handles video and audio.

My goal was to enable a developer to drop in my finished configuration system as a GameMaker extension, and invoke its default implementation with a single function call, and use other function calls in the extension to build custom features, but use most of the features without modification, beyond turning features on or off, and to also have the capability of adding customized settings specific to their game. I wanted to write my system one time, and have it be re-usable so that I could save myself from having to spend a lot of time re-creating the system in each new project.

Most difficult of all, it requires that I design a system that anticipates every need a game developer might possibly have, for any type of game they might dream up. Doing it one time and never having to touch it again would be great, but it’s probably not realistic.

This was an overly-ambitious goal. I’m laughing at myself a bit, now, thinking about it.

Still, there were a lot of achievable ideas that I had for the tutorial, and a demonstration of how to implement them would be a worthwhile exercise.

It won’t be drop-in, single-function system, and it’ll be specific to the Windows build target, but the design should be adaptable to your project with a little work.

I don’t want to make a promise for when I expect to deliver this, but I will complete the series and a reference implementation before I publish the first article.

Topology of Metropolis in Superman (Atari 2600)

One of my favorite games on the Atari 2600 is Superman (1979), designed by John Dunn, and based on the program code from Adventure by Warren Robinett. This game has stayed with me to this day as one of my favorite games. I started playing it again recently, and began thinking about the different aspects of it that make it such an enjoyable game to play again, even 35 years after its release.

Superman had many innovative features, and I won’t give it a full review here, but the one that I find most interesting is the game map. The world of Superman is much larger than most contemporary games of the era. The way the map is laid out is confusing and non-intuitive, making the game very difficult for a new player, but once you start to gain a sense of how the different screens that make up the city are variously interconnected, it becomes possible to navigate very quickly through a number of methods which can be memorized with some effort and repetition. (more…)

Global Game Jam 2014 postmortem

The Global Game Jam 2014 site doesn’t seem to have a blog capability this year, or if it does I’m stupid and can’t find where I can blog about my progress. So I wrote this entry as the weekend unfolded.

The theme this year was: “We don’t see things as they are, we see things as we are.”

Interesting theme! I like it. A good idea came to mind almost immediately. I thought about a world that changes as the player changes. By picking up items, the player’s attributes change, and as the player’s attributes change, the world’s attributes change as well.

Then the idea came to me to have the player change by looking into mirrors that reflect a distorted view of the player. The more the player looks at the distorted reflection, the more they come to look like the reflection, giving them new powers… but, the world changes to match. (more…)

GameMaker tutorial: Elegant instance_change() in your state machine

In GameMaker, a commonly used technique is to build a system made up of a several objects to represent an entity in your game, such as the player or enemy, in various states, such as idle, dead, shooting, jumping, running, climbing, and so forth. This is what is known as a Finite State Machine pattern.

When the time is right in the game, we change an instance from one state object to another by using the powerful instance_change() function. Instance_change() takes the instance and transforms it into a new type of object. Its Event behaviors will change to those defined by the new object type, but its old properties (object variables) will remain the same as before, allowing the instance to retain its variables with their current values.

The instance_change() function takes two arguments: object, the object the instance will turn into, and perform_events, a boolean which controls whether the new object’s Create event will be performed or not.

Normally, the Create event is where an object initializes its variables and initiates its default behavior. When we’re dealing with a State Machine comprised of a number of objects, this can become problematic, however. Some code in the Create Event is initialization code that we may only want to execute one time, to set up the instance when a brand new instance is created, while other code in the Create event is behavioral and we may need to execute whenever an existing instance reverts back into that state again. Thus, the perform_events argument in the instance_change() function isn’t adequate for this situation — it’s too all or nothing.

For example, let’s say I have a generic object for an enemy, oEnemy. I want some visual variety to this enemy, so I’ve created a few different sprites for it. In the Create Event, I want to randomly choose one of those sprites to be the sprite for this instance. But if the instance changes into another state object, and then reverts back, if I call the Create Event, it will randomly choose a new sprite. I don’t want this, as it ruins the illusion of continuity — I need that instance to retain its sprite. But I do need the Create Event to run, whenever it re-enters this state, because I’m using it to set the instance in motion.

So, how can I elegantly select which lines of code I want to run in the Create Event?

Conditional blocks

This is the least elegant solution, but you could use if to check whether a variable exists or has a value. For example:

if sprite_index == -1 {sprite_index = choose(sprite1, sprite2, sprite3);}

This is inelegant because it adds lots of lines of code that only need to be run one time (when a brand new instance is created) but need to be checked potentially many times (any time that instance changes back into the object state). It also only checks certain, specific things, case by case. As I continue to build the state machine, I may end up introducing more features which require initialization, which would necessitate more checks, further bloating the code. I always want to write the least amount of code needed, both for reasons of performance and maintainability.

Move one-time code to an init state object.

The more elegant solution is to recognize that initialization is its own state, and we need to separate it out from the other states in the state machine. We can create an oEnemy_init object, put our one-time initialization code into it, and then the final step in the Create Event for the init object would be to change the object into the default state.

None of the other states in the state machine should put the instance back into the init state, thereby guaranteeing that the init code only executes once. Now your code is neatly separated, your states objects in your state machine are as simple as can be.

csanyk.com © 2016
%d bloggers like this: