• Content Count

  • Joined

  • Last visited

About LTNGames

  • Rank
    Advanced Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. As rich said, no right or wrong answer. I generally recommend pure vanilla JS for coding newbies, mainly for a couple reasons. The main reason being tutorials are abundant and second TypeScript is compiled to JavaScript. To me learning why Typescript was made, by using the language it was conjured for, is generally a good idea. Nonetheless I believe the tutorials alone are the main reason, if you need answers you'll find them quicker for vanilla JS than you will with Typescript. If you are already a knowledgeable programmer then really it's just a choice between having types or not. Happy coding!
  2. Looking good, I enjoy the sound effects and pretty art. Good job! lol, actually Flappy Bird is a copy of an even older game and I remember playing it early 2000s before Smartphones were a thing and Adobe Flash ruled the internet with their games.
  3. I'm really glad you answered this question for me, you covered so many different aspects in such a great way. It seems to me that for now, it's best not to use a module system for these types of projects I'm doing, which I have no problem omitting from my plugins. The way I did it before ES6 conversion, I was just wrapping my core functions in an IIFE and exported only 1 main objects which contained the functions I wanted, a classic ES5 module pattern. I think my best solution without bundling my core plugin with all the other plugins that utilize it, is to do it the classic way, at least until there are other solutions or native module support, which may be a few years away lol. A few things about RPG Maker, it exports for desktop, browser, and android, the desktop version is wrapped in nwjs(node-WebKit), probably an outdated version lol. It handles plugins by loading each file in the projects plugin folder and appending them to the index.html file, it's not the smartest way but it works. Almost everything in RPG Maker is in global space, probably the worst idea ever but they don't seem to care that they pollute the shit of the global space. Anyways, thanks a ton for your detailed reply, I definitely understand more about how modules, and bundling work and it's not quite the solution I was hoping for, at least not for my type of projects at the moment. At least now I know how to proceed with the conversion to ES6. If I have any more question in general about bundling and or transpiling I'll be sure to come back and ask but for now I think I'm happy with what I have and the solution I believe will work just fine for my plugins.
  4. Good, glad it works for you. Scoping is the first thing you will battle with when programming in javascript, youll catch on fairly quick though.
  5. You're using a variable to define your player, the variable is local to the function only and not available outside of it, you must declare the player as a property of the prototype in order to access it in the prototypes functions. var game = game || {}; game.Game = function(){}; game.Game.prototype = { preload: function() { console.log('passed'); var direction; var tile; }, create: function() { console.log('reached'); this.add.sprite(0, 0, 'sky'); this.add.sprite(0, 0, 'armor'); this.player = this.add.sprite(0, 0, 'dude');; this.player.animations.add('left', [2, 3], 5, true); this.player.animations.add('right', [4,5], 5, true); this.player.body.gravity.y = 300; this.player.body.bounce.y = 0.2; this.player.collideWorldBounds = true; var platforms =; platforms.enableBody = true; for (var i = 0; i < / 64; i ++) { tile = platforms.create(i * 64, - 64, 'tile1'); tile.scale.setTo(2, 2); } }, update: function() { var playerCollision = this.physics.arcade.collide(this.player, platforms); var cursors = this.input.keyboard.createCursorKeys(); this.player.body.velocity.x = 0; // Left if (cursors.left.isDown) { this.player.body.velocity.x = -150;'left'); direction = 'left'; } // Right else if (cursors.left.isDown) { this.player.body.velocity.x = 150;'right'); direction = 'right'; } // Idle else { this.player.animations.stop() if (direction = 'left') { this.player.frame = 0; } else if (direction = 'right') { this.player.frame = 1; } } // Jumping if (cursors.up.isDown && this.player.body.touching.down && playerCollision) { this.player.body.velocity.y = -350; } //Smashing if (cursors.down.isDown && !this.player.body.touching.down && !playerCollision) { this.player.body.velocity.y = 350; } } };
  6. I'm having a bit of an issue with compiling ES6 code to es5 with import and export syntax. I'm not even sure if it's possible but what I'm trying to do is convert a few of my RPG Maker MV plugins to ES6, I rewrote one plugin in full ES6 with the export keyword to export a few of my objects. Now, the point of this specific plugin is to have common functions all in this one file that I call a core file, that I can later import it's functions and objects into my future plugins and any other ones I decide to rewrite into ES6. The thing is, I did some reading and been told in order for the compiled file to work on the web or in production is to bundle them up with, webpack, browserfy or whatever. The problem is that these files can't be bundled up as it's not an app, it's a series of plugins that the user can decide to install or not. So each of my plugins that I would like to import from this specific core file without bundling them, is this possible? I've tried babel and it only compiles my ES6 into commonJS, systemJs, amd, umd etc which is fine but I haven't a clue how to get them working. So my question is how do I compile to ES6 without bundling? I assume it's possible by including the module library with my core plugin but I'm still unsure and would like to know for sure, before I start reading a hundred different pages explaining how to setup modules with compiled ES6 and trying different solutions etc. Hope someone can help and thanks in advance.
  7. Brackets should automatically detect most methods as long as you have the phaser.js in your project directory, I don't recall having to set up code completion for brackets and I used it for months, one of my favorite editors, unfortunately, it's a little too slow to respond to larger projects.
  8. Hmmm, it;s been a while since I've used phaser but I think it has to do with the fact you're creating the function in global scope which in your case would be the window scope, and when using the keyword 'this' it's searching through the window space for; which would be non-existent there because it's phaser namespace specific. I believe what you would have to do is make that function a prototype of BasicGame.Game so that you can access the normal inheritance of phaser For example, something like this should work for you. BasicGame.Game.prototype.createButtons = function () { }; //game.js create: function () { this.createButtons(); } ehh, just as @Théo Sabattiésaid
  9. For me, I'm used to working with larger files 2000 lines or less(not really all that large, but to some it is) so I like to organized my code in about 3 - 4 files depending on the project. Usually states, sprites, managers and windows (if required) if I have specific mechanics I like to make a plugin which can be used in more than one game so ill do that and keep the logic separate from the game. The managers file can usually used in more than one game as well, as its basically just functions with asset urls and global functions. Other than that it's really all personal taste and how you like working, unless of course your working with a team. So really however you feel comtorable is how you should do it.
  10. Since I've started with JS I have always used === not because I knew much about it but because I've always used a linter, it's a habit now to use triple equals and feels unnatural when I don't use it. Thank you for chiming in and giving me your 2 cents on the subject it gives me peace of mind. Not often that I run into a scenario where double equals is required and I have been programming in JS off and on for at least 8months and if it's ever required, like you said there are better ways to accomplish same results. Thanks again, cheers.
  11. You know, I thought about this myself but JShint & JSLint tell me otherwise, it says to use === when comparing to 0 and at the moment both give me the same outcome. I'm still getting used to JavaScript and I find JSHint helps a lot but in this case, I'm confused.
  12. Wow, so easy almost makes me look bad hahah. Almost 8months I been dabbling in JS with RPG Maker & Phaser and I have never seen the % sign being used until today. Thank you for this very simple solution and you have motivated me to do more research for Javascript. My final function looks like this. I had to add in the time objects second property so it would not update for the entire minute but easy enough. Thanks again, I'll be sure to ask my question in this community for now on. Game_Time.prototype.updateTimeEvents = function () { var currentTime = this.time; if(currentTime.minute % 5 === 0 && currentTime.second === 1){ this.recordEvent(); } };
  13. Okay, to start I'm creating a plugin for RPG Maker MV for my game, don't worry I don't expect many people here to have much knowledge on that engine. My question is not related to MV specifically but to a time system I'm creating. So far I have the whole system in working order, there is one feature I am attempting to get working and my brain is not capable of solving it at the moment lol. So, basically, I am making a feature that allows the player to time travel and I want to set up an update function that will record an event(location & time) every few minutes (set by the developer using the plugin). I have a time object which is always updating to whatever the current game time is, so I essentially can never get the current time without it updating, it's really hard to explain so I'll show some code in hopes to clear some confusion up. Game_Time.prototype.updateTimeEvents = function () { var currentTime = this.time.minute; if(currentTime === (currentTime + 5)){ console.log('Recorded automatic time event'); this.recordEvent(); } }; Here I'm trying to compare the currentTime(in minutes) with itself + 5 minutes but because this is happening in an update function and the time object is always updating this will remain false, forever! lol, This is what I'm having a hard time with, I need to somehow get a copy or a static version of my time object to be able to compare it with but I feel like I've mentally tried so many different ways and none of them work for me. I'm hoping someone here can post some ideas or ways you may achieve what I'm attempting to do, at this point my brain has worked too hard to figure it out, so I'm taking a break and asking here to take my mind off it for a little while. I hope this was not too confusing, if you have any questions let me know, cheers
  14. I use groups for all my windows in my game which is just a group of buttons, text and what not. I found lewster32 has an excellent workaround for the group scaling and I use it in my project. It should be what your looking for. Find it here
  15. Nice, very useful. I will test it out sometime today. Thanks for sharing