« first day (925 days earlier)      last day (4038 days later) » 

6:01 PM
@IceD .replace(/[A-Z]/g," $&")
damn, I always forget the global flag
 
Hi
Optional arguments in JS: I learned to write myVar = myVar || 32, if 32 is the default value for an optional parameter myVar.
But how about an optional bool which is false by default.
If it is of type undefined, it will be converted to false anyways.. I guess?
 
This one is easy. An optional bool which is true by default, however... :-)
 
Yeah in case it is true by default you still need to take care of it.
 
@amitghosh Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
just use myVar = myVar === false ? true : false;
or something like it
 
6:07 PM
lol
 
@FlorianMargaine yeah, but it's uglier
 
if he needs finer control...
 
In javascript return parameter working fine when I write the function like above (with hardcore data)

When I use some variable then it's not working
 
myVar = (myVar !== false)
it still looks stupid, but at least it's readable.
 
Well I am not the expert here, but if you have a string arg with a default argument not equal to "". One cannot pass "" anymore.
because empty string equals to false
@JanDvorak What is not readable about myVar = myVar || 32;
I assume that || behaves the same as in C.
 
6:10 PM
@Nils it's perfectly readable, but it doesn't preserve falsy values
 
@rlemon Pretty freaking close! For a demo, that's how I'd do it too
 
Well typeof would preserve falsy values.
Ah maybe the === thing does not let "" convert to false?
 
correct :)
!!> false == ""
 
@FlorianMargaine true
 
@JanDvorak so simple. thanks man
 
6:13 PM
function default(x,y) { return x === undefined ? y : x}
 
!!> false === ""
 
@Darkyen Stuck on the screen with the P on it
 
@FlorianMargaine false
 
@Nils === is strict equal
 
@AmaanCheval reload bitch :D
u need java btw
 
6:14 PM
Yeah, I know
It just freezes Chrome up entirely
 
Nobody needs Java.
 
Java certainly is a good choice to freeze up Chrome.
 
I have a javascript function which return data.
The function is

    function getEventData() {

      return { events: [{ "id": 2, "start": new Date(2013, 4, 24, 12, 0), "end": new Date(2013, 4, 24, 11, 0), "title": "test"}] };

}

it's working fine when I write the function like above (with hardcore data)

When I use some variable then it's not working ..like

 function getEventData() {

 $.ajax({
            url: "../PHP/PhpAction.php?f=fetchCalendarEvent",
            async: false,
            success: function (data) {
 
isn't there some canonical answer about asynchronous?
 
Java could be used to perform cross-domain AJAX requests, couldn't it?
 
6:17 PM
it could
 
Probably
 
@FlorianMargaine I believe there is
 
but flash would surely be lighter
 
...
i wanna discuss 1 crazy problem with you guys if you are intrested
its about simulating sand :P
and infact simulating everything for a destructible environment
when i try to simulate sand particles, there are two approaches 1. Use particles 2. Use a fluid [ u saw what happened to the fluid i got played on and it became a plum pudding ]
when i use particles, the complexity even with quad tree is insane.
i wonder if javascript can compute that much data ? in real time or is there a better way of computing behaviour of particles on a higher level ?
 
Pretty sure it can
I've seen simulations with a lot of particles
 
6:22 PM
@Darkyen Well download Nvidia's CUDA SDK and see the particles example this will tell you how many particles are possible in realtime today.
 
hmmm swarmling or firebatling
 
However JS certainly is not the language to do these kind of things.
I think I read a paper where real time CFD and particles are used to calculate sand, but I don't remember the details..
 
One day ...
http://blog.mozilla.org/blog/2013/03/27/mozilla-is-unlocking-the-power-of-the-web-as-a-platform-for-gaming/
 
@Darkyen The question is also what you mean with simulating: If it means "make it look realistic" realtime is for you. If it has to be correct and verifiable by experiment then rather no real time..
 
@FizzyTea Looks cool
 
6:29 PM
@FizzyTea Saw this native code still significantly faster + no way to program something like a GPU efficiently with JS.
 
It's pretty close for a first draft.
 
Also that is not exactly programmed in JS, but C++ compiled to asm.js with is quite different.
How to write cache friendly code in JS? I have like no idea..
:)
 
@drip Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
Not sure how that's different to JS -> asm.js
 
In the way it is programmed?!
 
6:34 PM
@Nils i want just enough realisticness , like dbz world
 
Yeah. C++ -> clang. Then clang through emscripten -> js -> asm.js.
 
not 100% about 40% .. and cuda is not javascript
 
Seems to me you could be more efficient writing it in JS to begin with.
 
@Darkyen what?
 
@AmaanCheval we are talking about 2 million particles son
most i have seen is 10k
 
6:36 PM
@Darkyen Good for you, sir.
 
I know nothing about graphics programming though, so I'm just wondering out loud.
 
@Darkyen As I said I would recommend C++ for such applications, there is a reason why all games are written in C++.
yeah with a fast GPU you might get around a million
But with optimised GPU code.
 
@AmaanCheval eh ?
-_- why u so pissed ?
 
I'm not
 
@Nils yeap... much like 4 cores for simulation and 1 gpu thread just rendering
but i wanna do this in JS
 
6:39 PM
Why?
 
it just doesnt make sense, if people were doing it in 1992 in C / C++ we must be able to do it in JS today
cause i wann make a game in JS where u can destroy the world
 
Well I am not going to argue about programming languages, but you will never get the tight memory control you need using JS.
You could use asm.js by hand but that's ridiculous.
 
hahahaha
i can use native client, that would actually be C++ though
 
@MattBakaitis Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
okay lets make some optimized code... cya i think some more selective quad trees and using newtons law should be helpful.. dunno though
 
@Nils You're not meant to write an entire program in asm.js, just the math-intensive stuff.
 
@Nils be very straight this is going to be 2d my bro
3d will kill any JS vm
nd we will have like 10 fps
because just to fill a 3d space ... of 400 x 400 x 400
64000000 particles will be needed...
 
It ain't sand, but 3d in JS nonetheless: playcanvas.com/demos
 
and coherisivness, friction, gravity and wind and Xcomponent calculation shall give us ...
about a few few hunderd million calculations per frame
 
Yeah probably JS => 2D, native => 3D lol
 
6:48 PM
Will I be forgiven for asking a CSS question here?
Why can I not set the height of a table row using
tr {
height: 0px ease-out;
}
oops, that was supposed to be
tr {
height: 0px;
}
regardless, the height does not change. Even if I tell all the child elements to have height: 0
 
@Darkyen I'm really tired, so my brain may be malfunctioning, but how are you going to have 2 million particles on a 2D plane?
You don't need to calculate for off screen particles
And on screen, the max you can fit is the number of pixels you have available
 
!!> 1300 * 700
 
@JanDvorak 910000
 
!!> 1920 * 1080
^ my resolution
 
@FlorianMargaine 2073600
 
6:53 PM
and 2 millions pixels x)
 
@AmaanCheval yes i do :P
@FlorianMargaine same as mine
 
Ah, right, forgot about the higher resolutions
 
and @AmaanCheval if you want to calculate the whole game terrain
 
But you still don't need 2 million
 
you will :P
 
6:54 PM
It doesn't have to be fullscreen
 
the game view can scroll
 
still doesn't mean you have to calculate off screen pixels...
 
my map is 4096 * 1080 [ sky ]
@FlorianMargaine why ?
 
Sure it can. And what happens when it scrolls?
 
just calculate them when the screen scrolls down to it
 
6:55 PM
More particles go off screen
 
calculate them as in render or the whole physics ?
 
Plus, your entire screen won't be filled with particles.
 
you can keep the physics in js arrays
and only render on screen the necessary pixels
 
right now i am trying to write a selective algo to just calculate particles which actually need to be animated
basically if a pile is formed... and everything has settled down
they dont need to be processesed unless some external force is hitting something in that case only some of them needs to be processed
 

« first day (925 days earlier)      last day (4038 days later) »