Activate your free membership today | Log-in

Monday, February 8th, 2010

Pseudo 3D tricks from old computer games for all your Canvas needs

Category: Canvas, Fun, Games, JavaScript

It is quite interesting to see how technology moves in circles. With canvas being the new fun toy to play with for creating browser-based games we have to find solutions to fake a 3D environment to be really fast (sure there is Canvas 3D but it is overkill for most games). The trick is to dig into the tricks arsenal of old-school game development on machines full of win like the Commodore 64 or Amiga.

Louis Gorenfeld some very detailed explanations on how to fake 3D including some of the formulas used in the days of 8 bit.

He is also working on some demo code which you can help him with by providing some JS/Canvas demos:

Fake 3D

CODE:
  1. current_x = 160 // Half of a 320 width screen
  2. dx = 0 // Curve amount, constant per segment
  3. ddx = 0 // Curve amount, changes per line
  4.  
  5. for each line of the screen from the bottom to the top:
  6.   if line of screen's Z Map position is below segment.position:
  7.     dx = bottom_segment.dx
  8.   else if line of screen's Z Map position is above segment.position:
  9.     dx = segment.dx
  10.   end if
  11.   ddx += dx
  12.   current_x += ddx
  13.   this_line.x = current_x
  14. end for
  15.  
  16. // Move segments
  17. segment_y += constant * speed // Constant makes sure the segment doesn't move too fast
  18. if segment.position <0 // 0 is nearest
  19.   bottom_segment = segment
  20.   segment.position = zmap.length - 1 // Send segment position to farthest distance
  21.   segment.dx = GetNextDxFromTrack() // Fetch next curve amount from track data
  22. end if

Posted by Chris Heilmann at 7:04 am
4 Comments

++++-
4.6 rating from 23 votes

Tuesday, January 5th, 2010

Commodore 64 JavaScript Emulator

Category: Canvas, Fun, Games

c64

Tim de Koning has done what folks do best with their winter holidays.... created something fun :)

With JSC64 he has ported the Flash version to give us an emulator for the Commodore 64 in JavaScript.

Tim's work uses Canvas and he provides a jQuery plugin if you are that way inclined. It is fun to check out the source on GitHub.

Posted by Dion Almaer at 6:06 am
10 Comments

++++-
4.7 rating from 29 votes

Monday, December 7th, 2009

JavaScript Gaining Traction with Game Developers

Category: Games, JavaScript

We received an email from Joesph Huckaby about his new JS-based game rendering engine and I have to admit that when I first read about it, I was a little skeptical about it mainly because I've been disappointed with many that I've seen in the past. As I dug into his site, Effectgames.com, my whole opinion changed as I saw some very robust demos that clearly demonstrated the capabilities of this engine.

effectgames

The games are powered by the "Effect Engine", Joseph's JavaScript/DHTML library that provides the framework for displaying and animating all the graphics, playing all the sounds & music, handling the keyboard & mouse, and sprite collision detection. It can smoothly render multiple layers of parallax scrolling tiles and sprites using pure DHTML. HTML 5 Audio is used where supported (currently Safari on Mac OS X 10.5 only, 10.6 and Firefox coming soon), and 3rd party extensions used elsewhere. All modern browsers and platforms are supported, including IE 6+, Firefox 3+, Safari 3+, Chrome 1+, and Opera 9+.

The team has also created a suite of online tools to allow developers to prepare and design their game online including managing graphics & audio, creating levels for their games and manipulating graphics in real-time using non-destructive filters (scaling, rotation, and a number of other transforms).

Developers can build their games locally on their Macs or PCs, and don't have to upload any code until they are ready to publish. Once ready, developers can compile their code automatically using Google Closure, and receive a unique URL and embed code to share the game on their own site, blog, or anywhere they want.

In looking through the documentation, it looks like the whole API is very well laid out clearly documenting the breadth of methods available and the Getting Started guide is very comprehensive.

I didn't find anything that discussed licensing or a potential pricing model so that's something that you may want to look into before diving into this but from what I've seen, the engine looks very promising.

Posted by Rey Bango at 8:45 am
22 Comments

++++-
4.3 rating from 51 votes

Friday, October 9th, 2009

Fun Friday: Mullets and Space Battles

Category: Fun, Games

The week is almost over, and that means it's Fun Friday! Ajax and HTML5 aren't just for serious business apps ("business in the front, party in the back"):

mullet_party

http://www.flickr.com/photos/heyjohngreen/ / CC BY 2.0
This week we have JS Wars from Jonas Wagner:

jswars2

jswars1

There are a couple of unique things about this game that makes it a good educational resource for developers. First, the code is GPLed so you can easily study it for your own needs. Next, I noticed a new attribute on the canvas tag I had not seen before:
HTML:
  1. &lt;canvas width="640" height="480"
  2.         id="screen" style="border: 1px solid #ddf;"
  3.         moz-opaque="true"&gt;&lt;/canvas&gt;

Notice the moz-opaque attribute. Evidently this showed up in Firefox 3.5 and:

...lets the canvas know whether or not translucency will be a factor.  If the canvas knows there's no translucency, painting performance can be optimized.

Hopefully the other browsers and the HTML5 spec can pick up this useful property.

Another unique aspect of this sample is that many free, open source tools were used to create all the images and sounds. All the graphics were created with the Gimp and Blender, and the sounds were made with csound.

BTW, if you are graphically challenged like me but need resources like this for applications and games I always recommend either grabbing images, video, and illustrations through the Creative Commons search engine, Wikimedia Commons, or iStockPhoto.com (you could grab an Illustrator file from iStockPhoto, for example, and then convert it into SVG using Adobe Illustrator to bring into your fancy web page).

Posted by Brad Neuberg at 6:30 am
8 Comments

++---
2.8 rating from 15 votes

Vanthia

Category: Games

Scott Schiller, favourite DHTML hax0r, pointed us to Vanthia "a browser based Massive Massively Multiplayer Online Role-Playing Game in development."

The game appears to use Mootools for the underlying library, the UI is quite well done and the map uses an isometric, pixel-based style.

Check out the forum.

Posted by Dion Almaer at 12:12 am
10 Comments

++++-
4 rating from 26 votes

Thursday, October 8th, 2009

Play Kings Quest, Space Quest, and More… Using Canvas Tag

Category: Canvas, Games

Martin Kool and Sjoerd Visscher have gotten many of the old Sierra Online games running on the Canvas tag, including many of the Kings Quest series, Space Quest series, and Leisure Suit Larry.

gr

lsl

Martin Kool describes some of the long process it took to get these into the shape they are:

In 2003, I created Good Old Adventures. It was a chat environment set in the Sierra worlds without actual gameplay. All images were manually crafted, copy/pasting from WinAGI Game Development Studio. A time consuming process.

sq
Four years later I wrote a few conversion tools in .NET to extract Sierra's in-game images and objects from the original games, and display them properly on the web. The "only thing" left to do then was to export and understand all in-game logics.

I was able to convert the logic to javascript, but there was one big problem: Sierra's code used GOTO statements, and those could jump anywhere in the code, even inside a nested "if"-statement. It seemed unsolvable in javascript.

I sat down together with Sjoerd Visscher, one of my collegues at Q42, and we came up with a solution. Using a decompilation approach to get rid of nested "if"-statements and putting the whole shebang inside a huge switch/case statement, we could mimic line numbers and GOTO's while maintaining performance. World domination was within reach :-D

code

It was halfway 2008 when I started to work on it, and Sarien.net is the result.

Posted by Brad Neuberg at 6:00 am
10 Comments

++++-
4 rating from 35 votes

Monday, September 28th, 2009

Berts Breakdown

Category: Canvas, Fun, Games

We usually post these on Friday, but who says a little fun on Monday is wrong? Paul Brunt has put together a nifty game using the Canvas tag. It's pretty impressive. He is also using Chrome Frame to have the game work on IE as well.

bert3

Play it now

Posted by Brad Neuberg at 7:00 am
8 Comments

++++-
4.3 rating from 36 votes

Tuesday, September 15th, 2009

First sign of WebGL lands in WebKit

Category: 3D, Games

Jeffrey Rosen has taken a look at a preview of WebGL landing in the WebKit project. The demo above is an example of this work (here in HD):

WebGL is basically an initiative to bring 3D graphics into web browsers natively, without having to download any plugins. This is achieved by adding a few things to HTML5, namely, defining a JavaScript binding to OpenGL ES 2.0 and letting you draw things into a 3D context of the canvas element.

It is interesting to compare this low level API to O3D which is a scene graph API from Google (Google also supports WebGL, via the O3D team also, and sees the APIs as complimentary). They are very different APIs taking drastically different approaches. One gives you a new API but a higher level one that may appeal to JS developers more, whilst the other is very familiar to a certain set of developers and would be easier to port work. Ideally, someone will Processing/jQuery-inize WebGL to give it some nice high level love too.

Fun times with 3D and the Web! Great to see WebKit and Gecko doing great things with WebGL already.

Posted by Dion Almaer at 6:18 am
17 Comments

++++-
4.5 rating from 31 votes

Friday, July 17th, 2009

Fun Friday Platformer

Category: Fun, Games

Fancy a break? Take Mr. Speaker's little JavaScript platformer for a spin.

Have a great weekend, and a quick reminder:

Posted by Dion Almaer at 12:54 pm
9 Comments

++++-
4.6 rating from 17 votes

Friday, May 1st, 2009

Deep Leap: Teasing John Resig

Category: Fun, Games, JavaScript

John has been working on a very fun scrabble typing game called Deep Leap and although he hasn't finished it yet, people found it (John, time to learn about .htaccess ? ;)

Just to tease him a little more and get the word out before it is finished, check it out!

Posted by Dion Almaer at 4:33 pm
9 Comments

++---
2.7 rating from 47 votes

Sunday, April 19th, 2009

Sarien: Multiplayer Game Engine goes Open Source

Category: Games, Showcase

Ben loves to talk about old games such as Dark Castle. I personally love remembering old Sinclair ZX Spectrum games but also fondly remember Leisure Suit Larry.

Wouldn't it be nice if you could play classic old games such as these easily online? Martin Kool thought so, and wanted to create an open source adventure game system, and just released Sarien.net "the portal for reliving the classic Sierra On-Line adventure games. With its focus on instant fun and a unique multiplayer experience, Sarien.net hopes to win new gamers' hearts and promote the adventure game genre."

Features

Completely browser based, runs in IE, FF, Opera, Safari, Chrome

  • Works on the iphone and Wii (both needs fixing at the moment I believe)
  • Games are completely playable using mouse or keyboard input. A lot of effort has been put into the user interface to make it work for the era that we’re in
  • Multiplayer! This was not in the original games, but what you can do now is; when you are playing your own game at your own pace, and are in game X room Y, you’ll see other players in that same game X room Y doing their things
  • You can talk to eachother and replay scenes together
  • All game areas are accessible directly through the address bar, and bookmarkable. Giving players the instant kick of replaying a certain scene
  • While playing, you encounter other npc’s. These add up to your own list of avatars that you can choose to be, not influincing the gameplay but it adds up to the fun (especially in multiplayer)
  • There’s even an extra Studio tool to let you view all game resources, similar to existing tools such as AGI Studio

Check out some of the games and then delve into the resource explorer studio and build your own stuff.

Thanks for doing this Martin! What games would you like to see / create? :)

Posted by Dion Almaer at 10:54 am
8 Comments

++++-
4.7 rating from 38 votes

Friday, April 3rd, 2009

Awesomium: Embed Web content in your 3d worlds and games

Category: Games

Awesomium lets you embed Chromium/WebKit into 3d worlds and games. Check out the video above and half fun looking at the transparent search results and the shadows from the content on the grass.

What could it be used for?

  • Powering an in-game GUI using HTML/JS/CSS
  • Rendering a live web-page to a 3D object and interacting with it
  • As a framework for an advanced, 3D web-browser
  • As an offscreen renderer for snapshots of web-pages
  • For the implementation of in-game advertisting.

Posted by Dion Almaer at 3:33 am
14 Comments

++++-
4.1 rating from 19 votes

Thursday, April 2nd, 2009

Q42 Multiplayer Game Engine Open Sourced

Category: Chat, Games

Martin Kool of Q42 let us know that his company decided to open source the Q42 multiplayer engine which is "a lightweight, generic multi-user solution, allowing developers to create their own browser-based application or game over port 80."

The engine is written in C# on the backend, and of course, JavaScript on the front end.

You can check out the sample chat client that leads you to the following code:

JAVASCRIPT:
  1.  
  2. /// <reference path="Multiplayer.js" />
  3. var ChatClient =
  4. {
  5.   users: {},
  6.   join: function() {   
  7.     ChatClient.name = document.getElementById("name").value;
  8.     document.getElementById("joinForm").style.display = "none";
  9.     document.getElementById("chat").style.display = "block";
  10.     Multiplayer.init("ping.aspx", 2000, ChatClient.handleEvent, { "name": true, "say": false });
  11.     var roomName = document.location.search.replace(/.*?room=(.*)/g, '$1');
  12.     roomName = (roomName == document.location.search) ? 0 : roomName;
  13.     Multiplayer.connect({ "name": ChatClient.name }, roomName);
  14.     ChatClient.writeLog("* " + ChatClient.name + " joined.");
  15.   },
  16.   handleEvent: function(userId, name, value) {
  17.     if (!ChatClient.users[userId]) ChatClient.users[userId] = {};
  18.     var user = ChatClient.users[userId];
  19.     user[name] = value;
  20.     if (name == "disconnect") ChatClient.writeLog("* " + user.name + " disconnected.");
  21.     if (name == "name") ChatClient.writeLog("* " + value + " joined.");
  22.     if (name == "say") ChatClient.writeLog((user.name ? user.name : userId) + ": " + value);
  23.   },
  24.   sendMessage: function() {
  25.     var text = document.getElementById("msg").value;
  26.     if (text.indexOf("room") == 0)
  27.       Multiplayer.send({ "room": text.substr(5) });
  28.     else
  29.       Multiplayer.send({ "say": text });
  30.     ChatClient.writeLog(ChatClient.name + ": " + text);
  31.     document.getElementById("msg").value = "";
  32.   },
  33.   writeLog: function(msg) {
  34.     document.getElementById("log").value += msg + "\n";
  35.     document.getElementById("log").scrollTop = document.getElementById("log").scrollHeight;
  36.   }
  37. };
  38.  

Each user asynchronously pings a url on the central server at a given interval, sending its changes and retrieving changes of other visitors. The retrieved changes are dispatched through the javascript library, so the clientside application may act upon it.

The client consists of a single 5k javascript file, and the server is a single C# class library that can be embedded as source, or as a dll.

Focus of the q42 multiplayer engine was to give developers full control and not come up with any restrictions to the type of application that is being developed.

Features

  • Easy customization and full control. Example project included
  • Easy grouping of users that can see eachother by means of virtual "rooms"
  • Automatic room upscaling when a certain amount of users is reached
  • Automatic cleanup of empty rooms and idle users
  • Persistent user properties (for example: name, x or y position)
  • Nonpersistent user events, such as chat messages
  • Full control over rooms, names, properties, events and its values
  • Moderating features can be implemented easily
  • Optionally allowing multiple users per session, so each browser-tab can represent a new user.

Posted by Dion Almaer at 5:33 am
2 Comments

+++--
3.4 rating from 34 votes

Monday, February 2nd, 2009

Writing a JavaScript Tetris; Lessons learned from a Ruby chap

Category: Examples, Games, JavaScript, Tutorial

We often get games sent our way, and try to keep those posts for Fridays. This one is different though. Thomas Kjeldahl Nilsson didn't just write another Tetris clone in JavaScript, he documented his experience. He posted a series of articles on the various steps, and not only do you learn how to build a nice Tetris game, but you get to see how to develop nice testable code. Thomas comes from the Ruby world and it shows.

Take some time to poke through his series on JavaScript Tetris:

  1. Rationale
  2. Planning
  3. Infrastructure
  4. Graphics & Input
  5. The Life Of A Piece
  6. Lights, Action, Music!
  7. Gameplay
  8. Javascript Tetris Pt 8: Post Mortem & References

Posted by Dion Almaer at 8:18 am
Comment here

++++-
4 rating from 27 votes

Friday, December 12th, 2008

Travians: Sims meets Cultures, with Ajax

Category: Fun, Games

Steve Mattison let us know about a new AJAX game has been released by the makers of that old popular PHP-based village building game Travian. This one is more like Sims meets Cultures, and it is called Travians:

"Travians is a browser game in which you rise to the challenge of
everyday life as a villager. This means more than just specializing in
your occupation, building your own home or deciding whether you enjoy
games more than fighting: The most important thing is communication
within the huge village community. This is the only way to get fun
clubs and strong guilds. Become a Travian and experience a whole new
online world!

Posted by Dion Almaer at 7:44 am
11 Comments

+++--
3.6 rating from 40 votes

Friday, November 21st, 2008

Digg Attack: A Canvas Game

Category: Canvas, Fun, Games

Fun news for a Friday. From Jacob Seidelin--the dude behind JavaScript Super Mario Brothers--comes Digg Attack, an original JavaScript game using <g;canvas> for visuals (and Flash for music).

As an added twist, the game uses Digg to provide a sort of unique twist; enemies in the game are based on stories in the Digg API feed and their ratings.

Posted by Ben Galbraith at 7:00 am
2 Comments

++++-
4.1 rating from 19 votes

Next Page »