• Content count

  • Joined

  • Last visited

About hashi

  • Rank

Recent Profile Visitors

630 profile views
  1. Is world represented like in classic liero (pixelmap) or geometry? Nice project.
  2. I think it is important to inform in your post if exporting to Android by any solution cost some money or not. Also does construct 2 is free for use? Is it possible to pay only to you for game and no more costs for cocoon.io or using construct 2?
  3. Exporting games to Android devices by Cocoon.io or others cost something? Is it possible to modify levels / add new levels easly by some editor? If not by editor then by typing json? For example in He Likes The Darkness.
  4. I have Class constructor that require options parameter, that parameter is plainobject {}, also it has 0 or more arrays inside and another plainobjects. I create a lot of instances of this Class and these are succesfully pooled already. But I am wondering what to do with this options param like this one: { type: "type", ..., bodies: [ { type: "type" ..., }, ... ], ... } Sometimes options param is hardcoded, sometimes algorithm gets it by net connection in arraybuffer to recreate {} & []; What is worth pooling mechanism in javascript? For sure complex objects with a lot of properties and inner objects. What about these little guys then? {} & [] Is it worth to pool empty plain objects and arrays? With releasing it to pool you would remove all properties in {} and setting length to 0 in array.
  5. All i do in RAF for now is only rendering, not setting positions. I wonder which is better, updating gfx position right after single body position changed. Or after whole physic step (all bodies changed position) with additional outer loop. Which is better design. BTW. hello friend from neighborhood Poland here.
  6. Antriel, you have misunderstood my question. I have already fixed timestep full of accuratness. The question is about better update gfx position right after body changed position or in outer loop(eachObject/Body) in for example requestAnimationFrame.
  7. Assum we use physic engine like box2d or p2.js. And both graphic and physic updating are aprox 60 fps. What is better? 1. Update gfx position right after physic body moved? GameObject.prototype.integrate = function() { this.body.integrate(); //body has changed his position according to physic simulation this.gfx.x = this.body.x; this.gfx.y = this.body.y; } 2. or in separeted loop? requestAnimFrame(() => { world.eachObject((obj) => { obj.gfx.x = obj.body.x; obj.gfx.y = obj.body.y; }); });
  8. I have simple Filter and need to make access in shader to data: - position of sprite / mesh of Stage - textureRegion rectangle info How to do this? var fragSrc = ` precision mediump float; varying vec2 vTextureCoord; uniform sampler2D uSampler; uniform vec2 dimensions; uniform vec4 filterArea; uniform vec4 texRegion; vec2 mapCoord( vec2 coord ) { return coord * filterArea.xy; } vec2 unmapCoord( vec2 coord ) { return coord / filterArea.xy; } void main() { vec2 coord = vTextureCoord; coord = mapCoord(coord) / dimensions; coord = unmapCoord(coord * dimensions); vec4 color = texture2D( uSampler, coord ); gl_FragColor = color; } `.split('\n').reduce( (c, a) => c + a.trim() + '\n' ); module.exports = RepeatRegionFilter = function RepeatRegionFilter() { RepeatRegionFilter.super_.call(this, null, fragSrc); } Util.inherits(RepeatRegionFilter, PIXI.Filter); RepeatRegionFilter.prototype.apply = function(filterManager, input, output) { this.uniforms.dimensions[0] = input.sourceFrame.width; this.uniforms.dimensions[1] = input.sourceFrame.height; filterManager.applyFilter(this, input, output); }
  9. Physic simulation is calculated only by host or by all clients as well? If by all clients/players, then how you deal with non-deterministic math between different browsers (firefox and chrome still can produce different results using Math.cos/sin etc. and box2d using it as well)
  10. There is a bug when you quickly change character in some way you can float up and higher and higher, so then you hit ceil, but your physic leads to teleport to second floor and so on you end up at the top of a cake, you can then go out of map
  11. I've implemented `Timer` class for high accuracy timing (for example for update logic/game-loop, sending ping each 15 seconds by WebRTC etc.) setTimeout/setInterval fires once per second when tab is inactive, so how to gain accuracy timing? We could set up `setTimeout/setInterval` in WebWorker, because in WebWorkers when tab is inactive, `setTimeout/setInterval` still fires with it's own interval/delay. We could then send message `postmessage/onmessage` from WebWorker to Main Thread on each `setTimeout/setInterval` fire calls as a tick. For some time this idea was working and was brilliant, but when I'm looking now (latest chrome version) this isn't working anymore because of `postmessage`, now `postmessage` delivers event with delay when tab is inactive.. Looks like Chrome Dev Team noticed this feautre, and they've fixed it.. but it wasn't a bug? gaah.. or maybe I have something wrong in the code: https://jsfiddle.net/mfzmotb1/16/ Timer = function Timer(callback, interval) { var id = Timer.prototype.__idCounter++; Timer.prototype.__hash[id] = callback; this.started = false; this.package = JSON.stringify({ id: id, interval: interval }); } Timer.prototype.__workerScript = function() { var __hash = {}; onmessage = function(ev) { var data = JSON.parse(ev.data); if ( __hash[data.id] === undefined ) { __hash[data.id] = { id: data.id, lastTime: performance.now(), interval: data.interval, step: 0 } } else delete __hash[data.id]; } function loop(start) { if ( !start ) for ( var id in __hash ) step(__hash[id]); setTimeout(loop, 0); } loop(true); function step(unit) { while ( performance.now() - unit.lastTime >= unit.interval ) { unit.lastTime += unit.interval; unit.step++; var now = Date.now(); console.log("ww", unit.step, "-", now/1000); postMessage(JSON.stringify({id: unit.id, time: now, step: unit.step})); } } } Timer.prototype.__idCounter = 0; Timer.prototype.__hash = {}; Timer.prototype.__worker = new Worker(URL.createObjectURL(new Blob(['('+Timer.prototype.__workerScript.toString()+')()'], {type: 'application/javascript'}))); Timer.prototype.__worker.onmessage = function(ev) { var data = JSON.parse(ev.data); Timer.prototype.__hash[data.id](data.time, data.step); } Timer.prototype.start = function(){ if ( !this.started ) { Timer.prototype.__worker.postMessage(this.package); this.started = true; } } Timer.prototype.stop = function(){ if ( this.started ) { Timer.prototype.__worker.postMessage(this.package); this.started = false; } } var timer = new Timer(function(wwTime, step) { var now = Date.now(); console.log("m_", step, "-", wwTime/1000, now/1000, (now-wwTime)/1000); }, 100); console.log("starting in 2sec, so you have time to switch tabs"); setTimeout(function() { timer.start(); }, 2000); Basically this code produce new class called `Timer`, there is WebWorker based on one function body `Timer.prototype.__workerScript` <- this fn's body happens in WebWorker. One WebWorker handles all instances of Timer, each instance is for one timer. Any ideas how to fix it? Here goes output: Some tips: ww - console.log called from webworker m_ - console.log called from main thread 1,2,3 - number of timer step Tab Active: starting in 2sec ww 1 - 1485111848.697 //webworker tick time in seconds m_ 1 - 1485111848.697 1485111848.707 0.01 //webworker tick time, main thread tick time, diff ww 2 - 1485111848.798 m_ 2 - 1485111848.798 1485111848.799 0.001 ww 3 - 1485111848.898 m_ 3 - 1485111848.898 1485111848.898 0 ... Tab Inactive: starting in 2sec ww 1 - 1485110821.95 //webworker tick time in seconds ww 2 - 1485110822.049 ww 3 - 1485110822.149 m_ 1 - 1485110821.95 1485110822.169 0.219 //webworker tick time, main thread tick time, diff m_ 2 - 1485110822.049 1485110822.17 0.121 m_ 3 - 1485110822.149 1485110822.171 0.022 ... Do you know any ideas for measuring time for html5 gaming without throttle?
  12. hashi

    Garbage Collector vs Pixi.js

    Hello Have an Important question. Is Pixi garbage-collector safe? I've found, for example, kind of terrible pieces of code. I will not show them here, because they are easy to find. Just search for "splice" method in pixi.dev.js. You will find it used for deleting elements from array. But Splice always return an array with deleted element/s. In pixi it isn't grabbed to some var, so Garbage Collector will eat it and after eating enough of unused vars, GC will make a lag in runtime, because of freeing memory. Wonder if there are more of memory-unsafe fragments, is Pixi GC safe? EDIT:Some other example:PIXI.Rope.prototype.updateTransform = function(){ var points = this.points; if(points.length < 1)return; var lastPoint = points[0]; var nextPoint; var perp = {x:0, y:0}; //:O object created every call of functionInstead of perp object it may be two variables, perp_x and perp_y, as you can see in the next lines (that aren't shown) perp is used only for some in-function calculations. EDIT2: Garbage Collector based on snake example: Even better..:
  13. hashi

    position of sprite in shader

    Also is it possible to add new uniforms any time? I'm gonna send array to shader and create uniforms like this: this.uniforms = { "some_array[0]" : {type: "1i", value: 0}, "some_array[1]" : {type: "1i", value: 0} };and later: this.uniforms["some_array[2]"] = {type: "1i", value: 2};and then always update uniform that say about length of this array too. EDIT: Ha! It works!
  14. hashi

    Pass array to filter/shader

    How to pass an array to shader/filter in pixi.js? For example array of textures. This is what I need and guess that pixi.js doesn't support it yet? The answer is here: http://www.html5gamedevs.com/topic/7055-position-of-sprite-in-shader/?p=42687
  15. hashi

    get pixeldata in a webgl canvas

    Try checking color of pixel on canvas: image.onload = function() {var canvas = document.createElement("canvas");canvas.width = image.width;canvas.height = image.height;var context = canvas.getContext("2d");context.drawImage(image, 0, 0);imageData = context.getImageData(mouse_x, mouse_y, 1, 1).data;//do something with imageData}