![]() |
Canvas Problem
I'm delving into canvas now, pretty simple switch from creating a map with HTML divs to canvas.
Problem though, I'm using 2 for loops inside one another to increment each tile. here is the code, For some reason I am getting a error. Code:
<!DOCTYPE html> |
Code:
background: url(new/grass.png): << this should be a semi-colonCode:
map[x][y];The main issue is that you are attempting to read an element beyond the last one (<= length): Code:
for(x=0; x <= map.length; x++){BTWW I understand it is preferable to use the following to clear the canvas: Code:
context.clearRect(0, 0, canvas.width, canvas.height); |
you have got three equals in the line
Code:
if(tileTopCount===map[x].length){ |
Quote:
|
what do the lines beginning with # do?
like #myguy ? also sometimes Ive seen lines beginning with $ - is that javascript or something else? |
In CSS, you use a period (.) to indicate "match on class name" and the octothorp (#) to indicate "match on id".
So: Code:
<html>I think it would be worth your while to go back and catch up on HTML and CSS. Oh, and by the way, this question has nothing to do with JavaScript. (Though jQuery uses "." and "#" in the same way as "selectors".) |
Oh, and the stuff with $ is *LIKELY* jQuery. A JavaScript library.
In jQuery, you use Code:
$("#butNotMe")Code:
document.getElementById("butNotMe")But jQuery also allows you to use Code:
$(".funky")Code:
document.getElementsByClassName("funky") |
I skipped CSS and HTML because I don't like them, javascript seems ok ;)
I don't like JQuery either. Why do you call a Hash # an Octothorp ? .. is that to make it sound more complicated and keep yourself in a job? lol |
@Old Pedant octothorpe ;)
|
Hey, octothorp/octothorpe/octotherp was around for many many years before programmers ever started calling it the "hash symbol". It never had been in usage in the USA before you Brits started calling it that.
It was actually called the "pound sign" when I was a kid, meaning weight in pounds (you know, those things you Brits invented, foisted off on us, and then abandoned!). That is, we used to commonly write 37# (pr sometimes #37) meaning 16.8kg. Anyway, I started programming in the 1960s, so octothorp is appropriate for me! http://en.wiktionary.org/wiki/octothorpe ************* So far as I am concerned, JavaScript is useless without completely understanding HTML and CSS. You will keep on asking questions like this because even JavaScript programmers *NEED* to know how the underlying HTML and CSS work to be effective. You are running around with blinders on (or that another Americanism?) if you fail to learn HTML and CSS. |
Quote:
http://en.wiktionary.org/wiki/octothorpe http://en.wikipedia.org/wiki/Number_sign But yeah, octothorpe is probably more common. |
@Old Pedant
I thought you would respond/reposte :D |
What could you even do without HTML and CSS in javascript? I thought the whole point of it was to manipulate HTML elements and their styles. AS far as I know that is.
|
donna1 seems to be only concerned with drawing shapes and stuff on a canvas.
So I suppose if you are not interested in anything else you could get away with just learning one of the drawing libraries for canvas. But man, it sure is self-limiting, isn't it. |
Quote:
|
| All times are GMT +1. The time now is 06:43 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.