Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making Javascript and HTML5 games

Tags:

html

A long time ago (Netscape 4-era), I wrote Javascript-based games: Pong, Minesweeper, and John Conway's Life among them. I'm getting back into it, and want to get my hands even dirtier.

I have a few games in mind:

  • Axis & Allies clone, with rugged maps and complex rules.
  • Tetris clone, possibly with real-time player-vs-player or player-vs-computer mode
  • Breakout clone, with a couple weapons and particle velocities

In all of these, I have only a few objectives:

  • Use JavaScript and HTML 5 - it should run on Chrome, Safari, or maybe an iPad.
  • Start small and simple, then build-up features.
  • Learn something new about game design and implementation.

So my questions are:

  1. How would you implement these games?
  2. Do you have any technology recommendations?
  3. If you've written these games, what was the hardest part?

N.B. I also want to start from first-principles - if you recommend a framework/library, I would appreciate some theory or implementation details behind it. These games are different enough that I should learn something new from each one.

like image 216
Jeff Meatball Yang Avatar asked Jun 11 '10 00:06

Jeff Meatball Yang


People also ask

Do HTML5 games use JavaScript?

The very basic building blocks of a HTML5 game are those of the web: HTML. CSS. JavaScript.

Can I make a game with HTML5?

In short, HTML5 offers the ability to create cross-browser and cross-platform games. It means you'll have to code once and can deploy the game anywhere. It'll not only save you effort but lots of money as well. It's because you won't have to create different games for different platforms.

Can you build games with JavaScript?

Yes! JavaScript is a great language for game development, depending on the type of game you want to create. JavaScript is best for web-based and mobile games. It's also a great language for kids to learn because it's generally easy to understand and has plenty of resources for coders readily available online.

What language are HTML5 games written?

JavaScript: JavaScript is widely known as one of the foundational technologies of web development, powering over 95 percent of websites across the globe. With the adoption of HTML5 for gaming, JavaScript has also become the core pillar of HTML5 game development in terms of programming languages, says GameDevAcademy.


1 Answers

Depends how much you want to start from scratch. To answer your direct questions:

1) How would you implement these games?

A: JavaScript + Canvas. Canvas is the 2D drawing surface from HTML5. Performance is pretty good on desktop machines, not so great on iOS and Android devices (as of the date of this post). If mobile is your utmost concern, you need to use the DOM and CSS3 3D transforms which trigger the GPU on those devices.

2) Do you have any technology recommendations?

A: This is sort of answered by the first question. JavaScript is a must, but I would ignore jQuery. You are targeting HTML5 devices, so no need to compensate for legacy browsers. As you are probably using Canvas, no need to smooth over the DOM interaction, either. There are some higher level libraries which make interacting with Canvas easier, such as Easel.js. WebSockets are useful for bi-directional streaming communication. And Box2D is useful for a physics engine. Local Storage is simple key/value string data for things like level progress, but for anything complex, you'll want WebSQL DB. For large binary assets you'll want to look at the File System API. Finally, don't be afraid of WebGL, as it is extremely fast and useful for 2D games.

3) What is the hardest part?

A: Almost certainly the hardest part is the debugging. WebKit's Developer Tools can make this easier, so don't leave home without them.

like image 86
Seth Ladd Avatar answered Sep 18 '22 19:09

Seth Ladd