No Time To Play

Tag: javascript

Game loops, input and sound in HTML5

by on May.25, 2017, under Miscellaneous

When I first started making games in what wasn’t yet known as HTML5 — not widely, anyway — about the easiest way to make a realtime game was to call a function every, say, 50 milliseconds with setInterval() and hope that would be enough time to process a frame: Javascript engines weren’t all that fast yet either. Worse, native support for video and audio was just being added to browsers, as for input, I didn’t trust myself to handle keyboard events so they would work consistently across browsers, so the mouse it was.

Needless to say, we’ve come a long way. Rhyme not intended.

In the first part of this guide, you’ve seen how to do graphics using the 2D canvas, which provides benefits of expressive power, speed, low memory and simplicity compared to the DOM. But graphics are just one aspect of games, and while other programming interfaces deal with everything in one place, HTML5 is broken up into multiple APIs you can use independently. This time, let me show you what I use to set up a game loop, accept input from the player and play sound. We’re going to focus on realtime games, because they’re conceptually simpler, but also more interesting.

(continue reading…)

2 Comments :, , more...

Brief guide to the 2D canvas in HTML5

by on May.18, 2017, under Gamedev

I started making web games using the 2D canvas API in 2009, early enough that people still went “I can’t believe it’s not Flash”. A year or two later, everybody and their dog was making canvas-based games, so mine weren’t special for long, but oh well. On the plus side, my skills are still entirely relevant eight years down the road — a lucky break in this world where we all have to run as fast as we can just to stay in place.

The canvas API isn’t exactly huge or obscure, and the Mozilla Developer Network covers it well. It can still be daunting to learn from scratch, especially if you don’t yet know what you’re going to need in actual game development.

As it turns out, I only ever use about two dozen fields and methods of the canvas element’s 2D context; you may be able to make do with even fewer. Of course, that’s just for the graphics — setting up a game loop and accepting input is another story.

(continue reading…)

1 Comment :, , more...

Laser Sky progress report

by on Sep.22, 2016, under Gamedev

I wasn’t planning on posting updates today, since real life problems and bad weather conspired to keep me down, but in retrospect the game has progressed noticeably anyway, even if it didn’t feel like that at first.

So, a week ago I announced my new game, a good old shoot’em up called Laser Sky simply because the name was available — as opposed to pretty much anything involving the word “neon”. (Do you know how hard it is to come up with original titles these days? RogueBot for instance is used by a whole bunch of other projects, from a variety of fields. Hopefully nobody sues.)

screenshot-20160922

Anyway, at the time Laser Sky was just beginning to feel like a game, but still lacked variety. So one of the first things to add was power-ups. The first one restores lost energy, or else gives points if you’re topped up — power-ups should never become useless! The second gives you an extra gun (then a third in the tail, which was sorely needed), and after that it erases the heat build-up, that gets significant even though with two guns you fire more slowly. The whole thing took some balancing work, because more guns should be more powerful overall, but still come at a cost. With a bit of special-casing, and otherwise fewer changes than expected, that too worked out great. It requires a change in strategy that just makes sense, and feels satisfying. Not bad for just one addition!

(continue reading…)

1 Comment :, , , , more...

Birth of a shoot’em up

by on Sep.15, 2016, under Gamedev

I don’t remember whether I played They Started It before or after coming up with the concept for Laser Sky. I had been toying with the Pyglet game library, pondering what sort of game it might be suitable for, and a shoot’em up was the most obvious choice. Not that the world needs yet another game about blowing stuff up. But making a sequel to Attack Vector and getting it right for a change is an old dream of mine, and any excuse to learn a promising new technology is a good one. The big problem was choosing a theme. And like the first time around, nothing I came up with seemed to have legs. Even a briefly considered idea for a cute’em up fizzled out (though that’s definitely worth revisiting). Moreover, it began to dawn on me that coding a sprite-scaling engine on top of a 2D library backed by OpenGL was kind of ridiculous. The new game had to be a good old-fashioned scroller… but then it couldn’t be a sequel to Attack Vector.

screenshot-20160914

In the end, the concept for Laser Sky came to me almost fully-formed during a walk in the park. Trouble is, it involved vector graphics, and that precluded the use of an engine optimized for sprites. So, back to HTML5 it was. The first order of business was dusting off the game microframework I developed two years ago for the original RogueBot. (Which of course revealed a bug, duly fixed.) Making a ship move around the screen, and some basic enemies come at it, was easy enough. Then it was time for them to interact.

(continue reading…)

1 Comment :, , , , more...

Weekly Links #47

by on Dec.02, 2014, under Gamedev, News

Hello, everyone. We had a long weekend in Romania, courtesy of December 1st falling on a Monday, and I spent it meeting with friends. In exchange for the newsletter being late, I give you a new version of RogueBot:

Yes, after going in the wrong direction for weeks, I completely redesigned the gameplay, and it’s off to a good start this time. Even with just the absolute basics in place, it feels like a game. It’s frantic. It’s challenging. (If you want an easy game, try Buzz Grid.) It requires both dexterity and planning. And it feels like there’s room for improvement, both on the player’s and the developer’s side.

In other words, a success.

(continue reading…)

Comments Off on Weekly Links #47 :, , , , more...

Weekly Links #40

by on Oct.12, 2014, under Miscellaneous, News

This is the second time in just a few weeks that I almost didn’t have a newsletter, so I’m going to ramble a little more than usual about the couple of topics I do have. First is that the little toy I’ve been working on is nearly ready for release (in fact I’ve been sending review copies already). And yes, I tried using the system look and feel this time, just for kicks. Looks surprisingly good.

voxeldesc-20141011

But what is VoxelDesc, exactly? It’s a voxel painting application, except instead of being mouse-driven as you might expect, everything is done via a command line backed by a powerful scripting language — Javascript for now, because that’s the default in Java 6/7. I came up with the idea after noticing how tedious other voxel editors are: you need to click your mouse, very precisely, a lot of times, in order to make the simplest object. My experience with POV-Ray suggested that a declarative, procedural approach should be a lot more effective.

(continue reading…)

Comments Off on Weekly Links #40 :, , , , , , more...

Weekly Links #31

by on Aug.11, 2014, under Gamedev, News

I’ve no idea when my browser started supporting WebGL. It wasn’t last time I checked, but when was that? Possibly months ago… before the last OS upgrade. Oh well, that must be it.

Anyway, since it’s now working, I again tried playing with Three.js a little. Even without accelerated drivers, Mesa is a lot faster than a rendering engine in pure Javascript, and WebGL allows for some neat tricks such as fog and proper lighting. Not that it helps much.

You can use the good old WASD keys to move around. I was going for a Sentinel vibe, but failed, and cheap tricks couldn’t fill the gap. (Amusingly, using the software renderer comes closer to what I had in mind.) To top it all, I worked just as much on figuring out Three.js as I had previously on setting up various 2.5D engines from scratch. And at least this one had style.

Oh well, on to the real news.
(continue reading…)

Comments Off on Weekly Links #31 :, , more...

Buzz Grid on the desktop

by on Aug.20, 2012, under Gamedev

I’m conflicted about this. On the one hand, I’ve spent the last two articles complaining about the difficulties of writing portable software. On the other hand, I’ve spent five days porting Buzz Grid to PyGame, and it came out better-looking that the original!

This time, however, I was able to keep the gameplay unchanged.

(continue reading…)

Comments Off on Buzz Grid on the desktop :, , , more...

Two Javascript roguelikes

by on Jul.25, 2011, under Review

Back when I first tried making a roguelike, Javascript wasn’t anyone’s first choice of language for a game. In all honesty, that was in the dark ages before Firefox. Nowadays, the various browsers sport much more functionality (and compatibility), so it’s no surprise that more JS roguelikes are being developed. As I’m trying to make one again, I figured it would be a good idea to see what’s out there. Two titles in particular have given me food for thought.

(continue reading…)

Comments Off on Two Javascript roguelikes :, more...

DOM event portability, revisited

by on Jul.19, 2011, under Gamedev

ZAGG mate with keyboard cursor keys

While my recent game Buzz Grid was very well received, virtually everybody complained about having to use WASD instead of the cursor keys. All my attempts to explain that it was a technical limitation fell on deaf ears. That’s natural; people need solutions, not explanations. But until recently, I couldn’t think of any way to add special key support in a portable manner without either:

  • making the code much more complicated or
  • making the game depend on some external library.

(continue reading…)

4 Comments :, , more...

Posts by date

September 2017
M T W T F S S
« Aug    
 123
45678910
11121314151617
18192021222324
252627282930  

Posts by month