![]() |
Html5 Canvas Game Drawing
I am trying to create an Asteroids type game using JavaScript along with html5's canvas element for drawing. I have searched around and have looked at examples but I can't figure out what is wrong with my rendering that I do in the game loop that is run every frame. The problem appears to be only that the canvas is not cleared at the beginning of each frame but I feel there might be something wrong also. The code used and shown below only works in Firefox but not Google Chrome or Safari.
Here is a picture of what it renders in Chrome: http://img233.imageshack.us/img233/6132/problemf.png What is is supposed to look like and is in Firefox: http://img215.imageshack.us/img215/7...oblemright.png Here is my set up for drawing on the canvas: Code:
var canvas = null;Code:
function step() {Code:
function Asteroid_draw() { |
I kinda winged it. You could post all your code for real solution.
Sorry I renamed your c2d variable. I really like calling it ctx short for context Code:
<script> |
It worked! Thank you TinyScript so much!
I guess the clearing wasn't causing the problem because any one I choose now works. My code now is: Code:
c2d.save(); |
| All times are GMT +1. The time now is 12:09 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.