... a statement like A=B=C=7
doesnt make any sense anyway ...
First of all, it *does* make sense.
In JavaScript, you would write it as
Code:
A = B == C == 7;
And it means
Code:
A = ( ( B == C ) == 7 )
which means that A will always end up being false, because you are comparing a boolean (true/false result of comparing B and C) to an integer. But that doesn't mean the construction is useless. I purposely created a pathological case.
*******************
Quote:
in my language you couldnt have a statement like A=B=C=7
When you get a few years experience, if you really want to create a braindead language that doesn't allow that, you can. Just don't expect anybody to then use it.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
But that's all wrong, because you are using #grass so that style will *ONLY* affect an element which has id="grass". If it was meant to affect MANY elements, it should have been specified as .grass and then the elements would use class="grass".
In any case, when you increment the positions where you draw the images, you only increase by 25 pixels to the right and down.
The increases *MUST* match the sizes of the images you are dropping in there.
When you reset the tilePos you do
Code:
tilePos=-50l
yet in the initialization code you did
Code:
var tilePos=-25;
But both of them needlessly complicate matters.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
So now I have another question, not to do with the programming side but canvas again. How efficient is it for a browser to render a game in canvas seeing every time you make a change, you have to clearthe canvas and then redo everything by calling the same functions. Wouldn't just having the DIV tags an programming their styles through CSS and Javascript be a lot simpler and make the browser faster?
I noticed by right clicking that basically your browser renders everything you did in javascript just a whole image.
Well sure. Esp. if you are creating the game background via some server-side code (PHP/JSP/ASP/etc.) it would make more sense to just generate a bunch of <img> tags inside a <div>. Done correctly, the images would automatically show 10 per row.
The only reason I could see to use canvas like this (and even then I'm not sure it's a better choice then <img>s in a <div>) would be because you are downloading new maps via, say, AJAX and/or you are generating the maps using logic (semi-random??) in JS code.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.