mattstyles

Moderators
  • Content count

    1,486
  • Joined

  • Last visited

  • Days Won

    13

mattstyles last won the day on August 25 2017

mattstyles had the most liked content!

About mattstyles

  • Rank
    Advanced Member

Contact Methods

  • Website URL
    github.com/mattstyles
  • Twitter
    personalurban

Profile Information

  • Gender
    Not Telling
  • Location
    UK

Recent Profile Visitors

5,246 profile views
  1. mattstyles

    Really Basic Setup question

    Ah, I see, without the specific protocol on the remote request it defaults to the protocol you were using, which was presumably 'file://', which, even if you had specified the protocol for the CDN wouldn't have worked anyway. Yeah, localhost has an http protocol so it would then route out to the internet. Good work solving it.
  2. mattstyles

    BabylonJS for ES6

    Modern browsers (and not so modern ones) are almost 100% compliant with the initial es6 specifications, http://kangax.github.io/compat-table/es6/, most are compliant with newer language features as well. Whether they are as performant as the transpiled es5-compliant code is far more shaky ground. Not sure what you mean here, ESLint is for checking certain syntaxes and structures in your source code and informing you of where you contravene a given ruleset. It doesn't do compilation or transpilation. Did you mean another tool? By efficient you should probably clarify that you mean it has a number of sugar methods that make code less verbose (not that verbosity is always a bad thing though). (almost) Everything from ES6 can be transpiled back to es5 so es6 doesn't support anything new, it just has a new syntax making some things a little nicer to write and less error-prone for the developer (the browser doesn't actually care and in many cases the old way is better optimised for the engine, if not for the developer writing it). (I think there are some odd things in the spec like tail call ops which are impossible to shim, but, everything else, including tricky stuff like generators and proxies, _can_ be shimmed, you'd probably never want to write code like that but transpilers can do it just fine).
  3. mattstyles

    canvas drawing to function converter

    This just sounds like you're describing vector graphics. Maybe a search for something like vector to canvas or just vector graphics would throw up some helpful stuff.
  4. mattstyles

    HTML 5 GAME DEVS reputation system

    Almost every app I use has this sort of thing, even with the ability to share your progress or 'compete' against others. Games nicked it from real life and now 'real life' apps have nicked it from games. A lot of the reward addiction stuff comes from gambling, but most comes from getting the best out of employees, particularly those that work in an intrinsically non-motivational environment (some jobs require a lot of 'grind', back in the day this would be done with fear and whips, nowadays we tend to use the carrot more than the stick). Most apps and games nowadays unfortunately use external motivators. These are things like 'play/use for an hour to get rewards' or 'play/use a certain amount of times in a day', they're external because the environment (the game) sets them and you, as a user, are just following along. They aren't particularly effective but they cheap and easy (usually) to implement. Some apps/games go a step further and use the human need for completion against users i.e. if you're on todo item 9 of 10 it'll tend to nag at you to get 9 and 10 finished and squared away. This todo list completion effect is still often implemented as external (win 2 battles today, post 3 times today, learn 3 words today etc etc) but slightly more involved as it uses the incomplete list effect to gain addiction. MMO's are rife for this sort of thing, they'll give you a couple of easy tasks to complete and then some more time-consuming ones when you're already 'invested' in completing that list. Many learning apps (such as language learning apps) do the exact same thing to great effect. Some of the best motivators are internal motivators. Sandbox games that truly are sandbox set out the rules of the world and let you go, they sometimes add reward tiers etc etc but, largely, you, as a user, set your own course of action. There are loads of superb examples in this field but it requires a whole heap more designing than many games go in to (particularly casual gaming, for good reason). Games/apps that leverage internal motivators are usually played by players for a long time (years is common) but its hard to set up world rules that allow for beginner and advanced players to get the same enjoyment, usually they have a steeper learning curve and 'deeper' gameplay. Some learning apps may leverage this type of motivator in some way. Business/lifestyle apps are pretty tricky to get into the internal motivator category as users will already come for a very specific reason, hence, the scope of the app is small and focussed (which is good) but it makes exploration and personal/group goal-setting difficult. Many business/lifestyle apps go down the Weight Watchers style route of group motivation i.e. they can be very aggressive about sharing with a group or competing so that human interaction (rather than app nagging) will keep you engaged and they will reward both the bragger and the supporter in any dynamic.
  5. mattstyles

    simple enemy gameobject in phaser 3

    You might want to look into javascript modules, or es6 modules, or commonJS modules. There are many different articles out there about JS modules. In some ways it ramps up the complexity as you'll need a build system of some sort (modern browsers do all understand es6 modules, but, well, its still tricky) but its easily the cleanest way of modularising a project and the benefits outweigh the costs if you're building anything non-trivial (it is a bit of a ramp up at first, or, at least, it can be, depending on your experience).
  6. mattstyles

    how to call a function as argument ?

    Nah, its not even a scope problem, whatever `myFunction` is in the original post, it wasn't a function. However, I do agree that you don't need to wrap the callback function again, but, you don't even need the `wait` function as it has just become a marginally slower alias. I'm assuming this is all simplified for the purposes of illustration though and that you're actually planning to do more with your wait function (like make it a little easier to cancel it, or extend it, or whatever). Functions in JS can be passed around as first-class citizens, which is an extremely useful language feature. function add (a, b) { return a + b } You can think of the `add` variable as a pointer to a block of code (rather than a pointer to a memory allocation), using newer syntax makes this even more obvious: const add = (a, b) => a + b Where you actually assign the anonymous (lambda) function to the constant variable (ha ha, that proper sounds odd!) `add`. Note: there are subtle differences between the two code snippets above, but you're extremely unlikely to need to worry about it, particularly for pure functions like the ones above. Either way you can pass the `add` function around, including using it as a parameter for other functions. Consider the following: const add = (a, b) => a + b const subtract = (a, b) => a - b const d2 = () => Math.random() < 0.5 const tweak2 = (a, b) => d2() ? add(a, b) : subtract(a, b) Calling the `tweak2` function has a 50/50 chance of either adding or subtracting those numbers, but, imagine we wanted to add other operations: const add = (a, b) => a + b const subtract = (a, b) => a - b const multiply = (a, b) => a * b const divide = (a, b) => a / b const d2 = () => Math.random() < 0.5 const tweak2addsubtract = (a, b) => d2() ? add(a, b) : subtract(a, b) const tweak2addmultiply = (a, b) => d2() ? add(a, b) : multiply(a, b) This is a pretty terse example but you can imagine how this is going to grow. Now imagine you end up changing some of the implementation, would be pretty error-prone. Imagine trying to test all combos, again, a little annoying. However, you could refactor this slightly and use another helper function: const add = (a, b) => a + b const subtract = (a, b) => a - b const multiply = (a, b) => a * b const divide = (a, b) => a / b const d2 = () => Math.random() < 0.5 const tweak2 = (fnA, fnB) => (a, b) => d2() ? fnA(a, b) : fnB(a, b) const addSubtract = tweak2(add, subtract) console.log(addSubtract(10, 2)) // 8 or 12 Now the tweak function can be 'pre-loaded' with functions it uses to operate, which we've passed through. If you're not comfortable with arrow functions then its a little confusing to follow as it uses closure and explicit return to work, but, have a look as this pattern can be generalised to be useful in a wide variety of situations. When you get really good you can do stuff like the following: const isNumber = _ => typeof _ === 'number' const add = (a, b) => a + b const total = compose( reduce(add, 0), filter(isNumber) ) total([1, 2, 'a', 3]) // 6 All functions used here a low-level pieces and trivial to test and re-compose. Unless you're comfortable with passing functions around it's probably a little tricky to see exactly what is going on (there are lots of good places to read up on it though) but you should be able to see that the `total` function can take an array, filter out only the numbers, and then add them all up.
  7. mattstyles

    One more question

    Very little, and nothing that could be construed as PII. Could literally be a single key/value pair in local storage: `consentAll: true`. You must then use that value in subsequent visits to the site to control behaviour (in your case this could be used to turn Admob on or off).
  8. mattstyles

    One more question

    This is an extremely glib statement. FB track users in a myriad of ways, all of which must now be exposed to users, that is extremely beneficial to users of any product. Whether it actually has an effect or not is not yet known, but most companies are tracking how users respond to their tracking preferences (which, in itself, is interesting). The point is that providers are now required to give end users more information about what their product does, this puts these issues in the minds of the end users, which is a good thing as many people are not tech savvy and have little understanding what the implications are for them. Most ignore it completely as they don't understand it, but the point is that many will now start questioning what these things mean for them and that is a wholly good thing. GDPR also covers things like the right to be forgotten (for free) and the subject access request (for free) as well as a host of other things. Whilst annoying for companies and developers most are already compliant with many of the regulations and its a great thing for users. I don't know how it impacts advertising but isn't tracking consent enough? So long as you explain why you are using cookies (or other persistence) and what you are tracking the advertising video bit becomes irrelevant no?
  9. mattstyles

    How do i have a WIlds.io mod ?

    Maybe try asking the author here Or give him a buzz on twitter
  10. mattstyles

    Cannot load new level automatically

    Simplest form of debugging is still throwing in console.logs to ensure that certain code blocks (or lines) are being executed. For example, try adding one in the `showMessageBox` handler where you increment the `currentLevel` variable, you might want one a little earlier too, perhaps at the start of the `endLevel` function to test that your conditionals work and that the code you _think_ is executing actually *is* executing. You can also log at the start of the `startCurrentLevel` function and check what the current level is. All of this can also be achieved by setting breakpoints and stepping through execution (check the docs for how to do this for your preferred browser, all of the modern ones have great tooling for doing this). Most browser let you set a breakpoint on a console log, or you can be heavy handed and place `debugger` in your code, which will trigger your editor to use that instruction as a breakpoint. Plain console logs will probably solve this problem for you (its worth learning how to use debugging tools at some point though).
  11. mattstyles

    When to use a database in a game

    I'm not really saying you do or do not need a database for this type of game, but, if that is all you're worried about then your game (and all of its state) will exist in memory on the server, so long as you can match up a player rejoining (i.e. ensure somehow that the joining player IS the one who just left) you can set their state appropriately, you don't need disk access for that (indeed, the fastest databases are in-memory, most will try to keep as much in memory as possible).
  12. mattstyles

    Convert dpi to pixels in HTML5 games

    dpi isn't a measure of size, so I'm not really sure what you need to do, but, getting the device's pixel density in a browser environment can be done using `window.devicePixelRatio` in all modern browsers. Does that help?
  13. If you're learning, then, yep, do it yourself. However, on the flip side (not you) I find it incredibly arrogant when I hear the advice 'a custom solution will always be best'. (open-source) Modules are often created by excellent developers, usually supplemented by other excellent contributors, tested by loads of other developers using it, subject to years of active development and improvements and solve specific problems with a laser focus. The only advantage a custom solution has is that modules/frameworks usually have to be flexible and generic enough to fulfil a number of use-cases, which compromises their design. 'Besting' all the advantages they bring, however, is no small task, even if your team has greater 'skill' than all those developers working on the off-the-shelf solution, it's potentially years worth of work and incremental improvements which aren't easy (or can be impossible) to replicate.
  14. Very similar to BBTan I've played on mobile (online link here https://www.crazygames.com/game/bbtan-online which is really poor, I just noticed your 99 balls is also on that site)
  15. mattstyles

    mmorpg advice?

    I think we need to be really careful with statements like this. Anything cpu bound and node (being JIT and dynamic) will struggle. Anything io-bound and node performs well. JS (and bare in mind I love JS) is easy to pick up but doesn't help in larger teams or as application complexity grows, and in no way is in 'safe' in the same way other languages are out of the box (C doesn't count here either!). Benchmarks are pretty fraught with danger as they often (despite best efforts) don't model actual use cases. http://attractivechaos.github.io/plb/ This one is incredibly favourable for V8 node (note you can use Chakra or other engines with node if you like) but does show the usual trend of C-like/Java-like/JS/Python/Ruby in terms of average perf (in no way is raw performance a sign of a language's usefulness for most use-cases). https://benchmarksgame-team.pages.debian.net/benchmarksgame/which-programs-are-fastest.html this comparison is much deeper (explore the site, very interesting stuff) but shows the same rough hierarchy as above: C/C-like/Rust Java/Go/Swift then Haskell/OCaml etc ---> there's quite a jump to the next langs JS PHP/Hack/Erlang Ruby/Perl/Python then Lua If you know anything about how these languages work this is no surprise, with the exception of JS which generally performs way better than expected (or, maybe should be expected as it has a monopoly over its execution environment which has seen extensive work i.e. V8, Chakra, SpiderMonkey etc). Note that the first two groupings above are fairly close, the next 3 are all fairly separated in terms of perf, big jumps between each group (the y scale isn't uniform in the graphs in the above link, there is a MASSIVE difference between say, Java and PHP, or, as mentioned here, between C and JS). Note also that TypeScript is an entry in the above linked graphs, this is odd as it has no runtime, there's probably a reason for this (and why its long-tailed) but it might be that JS engines can optimise better based on the transpilation of TS to JS in these test cases. Note also that poorly written C could very well be slower than expertly written Ruby (for example). nginx isn't node. its written in C as its core requirement is performance (and likely other reasons too). https://github.com/nginx/nginx Absolutely nothing will stop you building what you want with PHP. Personally I don't think its a natural fit, neither is Laravel (my knowledge here is limited), but, its a flexible and powerful language and if you're comfortable with it, you'll get it to do what you want. Certainly you'll do it quicker than learning a new language or new patterns/modules/libraries to use that language.