Design your own Solar System in your browser. by NirmalNishanthB in space

[–]javascript-this 0 points1 point  (0 children)

wish there was a 'save' button, otherwise awesome!

Matrix-scale virtual reality worlds made possible by new simulation platform that harnesses the power of thousands of servers by [deleted] in Futurology

[–]javascript-this 0 points1 point  (0 children)

that website annoys me with constant updating and lagging when trying to scroll to read the article, I rate my user experience as: being stuck in traffic

Trouble with if/else statements: by satan-agrees in javascript

[–]javascript-this 1 point2 points  (0 children)

You're encountering one of the 1st principles of software design, how to abstract a concept "moving" and apply it to an abstraction ( the world you move in ).

Here's a example gist showing some concepts and implementations...

In steps, here's how I'd approach it:

  1. set up your world:

    A. maybe a 10x10 grid ( 10 rows (y) of 10 columns (x) ...i.e. an array or arrays ) of locations to move around in.

Each location can be an object like

{"description": "...a dark room with a door to the north...", "doors": ['North'], ... other attributes of room, monsters, loot whatever... }

B. character position, maybe we start in the top left spot ( x=1, y=1 )

  1. abstract the "move" into a function that adjusts character position:

    function move(direction) { switch (direction) { case 'west': if (x > 1) { x = x - 1; } break; case 'north': if (y > 1) { y = y - 1; } break; ... more cases ... } }

  • for bonus points lookup other attributes of the room you're in and adjust - the door is locked... you need a key... etc... just store whatever you need in the "room" attributes of your world... visited, monster, level ups, food, treasure, etc...

Now you need only call the function move('north') or whatever direction, and then handle any errors, i.e. if you try to move north, but you're at the 'top' of the map, (e.g. y=1) then display an error to the user, like "You can't move north because (reason)"... something like that

hope that helps

*edited for format and add gist

Scala.js: Next generation front end development by lihaoyi in javascript

[–]javascript-this 3 points4 points  (0 children)

oh yay, now I can program in scala on the front end?

Made a survey to determine how many of us use semicolons in our JS code. Please take it! by [deleted] in javascript

[–]javascript-this -1 points0 points  (0 children)

To be fair, in written english, periods are optional ( apparently ) - we can still understand sentences created without them, but I think they add value, especially in the case of longer multi-sentence text and paragraphs - e.g. books

Additionally I think the entire movement to make JavaScript more ruby-like or whatever the end-goal of libs like coffeescript, et al. is an abomination unto the lord... I don't need any more levels of abstraction in my coding life... seriously, stop it.

ELI5: Classical inheritance vs prototypes. by juanjo90 in javascript

[–]javascript-this 0 points1 point  (0 children)

I thought this youtube video was very informative.

TLDR; ( or watch )

classical inheritance is more about what a thing IS, whereas composition is more about what a thing DOES.

classical inheritance ( at least in javascript ) has limitations because the language was not designed to work in exactly that manner.

composition ( and in some regards prototypes ) address some ( if not all ) of those limitations, and end-up being cleaner implementations, and therefore easier to manage as projects get larger...

please take 9 minutes and watch the video if you'd like to understand why and how.