views:

116

answers:

5

I intend to make a browser game with jQuery, I would need a canvas object in which I can place many visual elements and animate them to some extend. Is this entirely possible with just jQuery? Some may point to HTML5 canvas but it's specification isn't complete so I'm not too fond of it.

+2  A: 

So you want to have HTML5 canvas without HTML5 canvas? I'm afraid that's not possible.

Jani Hartikainen
I'm not asking for a HTML5 canvas, I'm not even sure if HTML5 canvas is what I need. Perhaps this is possible with javascript?
Khoi
The only way to have bitmap graphics is to use canvas (or Flash or whatever third party technologies also do it) :)
Jani Hartikainen
+1  A: 

If you're going to do a browser game, you don't necessarily need canvas. It actually depends on how you want to represent your objects graphically. If you're going to use sprites, you can make divs or imgs your sprites, and move them around using css absolute positioning, for example.

But no, you can't just go drawing lines on a canvas in any meaningful way. So, to sum up, you can make Pac-Man, but you can't readily make Star Wars.

Dave Markle
+3  A: 

It's very easy to make a canvas object with jQuery. Use

$("<canvas>");

That creates an object of HTMLCanvasElement which you can append to the page. jQuery is a JavaScript library, and to write a canvas based game, you need to code in JavaScript. There may be wrappers for jQuery available but I would recommend you use the right tool for the job instead of jQueryifying everything. Checkout these libraries:

Anurag
Many thanks, I found what I need.
Khoi
Awesome. Cheers!
Anurag
+1 for Raphael; indeed it is SVG not canvas, but I does its job.
mbq
A: 

Actually I think html 5 canvas is exactly what I need. People say it's complex but I found out it's just like other graphic APIs.

Khoi
+1  A: 

The best use of canvas for creating a game-like interface that I've seen actually uses YUI, but in my own projects, I can tell you that this is possible with jquery as well.

See http://ernestdelgado.com/articles/ddwdd/

The interaction here is really only having a canvas where you can drop objects that can be manipulated by the user via dragging, rotating, and resizing. If you're interested more in animating objects, you might want to look at impactJs.org