Search the Community

Showing results for tags 'code'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Coding and Game Design
  • Frameworks
    • Phaser
    • Pixi.js
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Found 33 results

  1. bubble shooting

    Hi, Anybody here that can sell a bubble shooting game developed in phaser?
  2. MyGameBuilder

    Hello, It has been a while since our last post here! MyGameBuilder was formed through a creative joining between the first versions of MyGameBuilder and MightyEditor. The main purpose of MyGameBuilder is to teach users game development in a collaborative manner, where more experienced developers can help others. If you are completely new to the game development you can: Play games - we have some nice user made games! Play with the actormap engine, which doesn't require any coding experience to make a game. Fork game and alter it to make it your own. Start taking guided lessons to learn programming basics, and even create a Phaser based game on your own, If you get stuck doing any of these things, there is usually somebody online who will be glad to help. After finishing the basic tutorials, there are some game related challenges to start practicing with. Main parts of MyGameBuilder: Graphic Editor - easily create your own pixel art, or import graphics here Actor and ActorMap - are part of the ActorMap engine, which allows you to build game without coding. It's as simple as assigning graphics to an actor, defining the Actor's behavior, and placing Actors on the ActorMaps to interact. Also, if you have used an earlier version of MyGameBuilder, you can import your game into the new version. The Map Editor allows you to build maps for your games. It uses the TileMap format so you can convert your graphics into tiles, and put them on the map.You can also import TileMap in JSON format or load TileMap directly into a Phaser game. The Sound Editor allows users to quickly create sound effects, like a coin pickup or a melee hit. There is also a music editor, which you can use to create background music for your game. Currently you can generate metal or 8 bit music, or import your own mp3 file. With the Code Editor, there is no limit to what you can create. The Code editor has a beginner-friendly code mentor which will show information about keywords used in the programming. Also it has JSdoc support so users can describe functions with JSdoc comments, the code mentor will pick those up and show as help info. Code Editor supports full ES6 JavaScript syntax and will automatically pick-up imported modules and share their info with the code mentor. The latest addition is our Hour of Code project: this is a gaming tutorial used in a worldwide classroom project that has users of any experience level program a dwarf character to complete game goals with basic JavaScript commands. Check it out here: https://v2.mygamebuilder.com/hour-of-code And all of this is completely free! It would be really nice if you could share your game developing experience when you were a beginner: How did you begin? Where did you get all the necessary information to build a game?
  3. How to set hitbox?

    I cannot figure out how to change the hitbox size of my player, the character doesn't fit through a hole in a fence so I want to change the hit box sizes. I already tried this https://phaser.io/examples/v2/arcade-physics/offset-bounding-box but this did not work for me, my screen went black when i did this. // variables for items, walls, etc. var walls; var house; var game = new Phaser.Game(550, 540, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render }); //add house to game function addHouse(image) { house = game.add.physicsGroup(); house.create(-250, -240, 'greenhouse'); house.setAll('body.immovable', true); } // add fences/walls to the game function addWalls(image) { walls = game.add.physicsGroup(); // fences up top walls.create(-90, -200, 'fencefront'); walls.create(5, -200, 'fencefront'); walls.create(100, -200, 'fencefront'); walls.create(195, -200, 'fencefront'); // fences to right walls.create(288, -200, 'fenceright'); walls.create(288, -135, 'fenceright'); walls.create(288, -70, 'fenceright'); walls.create(288, -5, 'fenceright'); // fences at bottom walls.create(-90, 59, 'fencefront'); walls.create(5, 59, 'fencefront'); walls.create(100, 59, 'fencefront'); walls.create(195, 59, 'fencefront'); // fences to left walls.create(-91, -200, 'fenceright'); walls.create(-91, -135, 'fenceright'); walls.create(-91, -70, 'fenceright'); // set the walls to be static walls.setAll('body.immovable', true); } // preload items, walls, players, etc. function preload() { // preload player game.load.spritesheet('player', 'hero.png', 64, 64); // preload houses game.load.image('greenhouse', 'greenhouse.png'); // preload fences game.load.image('fencefront', 'fencefront.png'); game.load.image('fenceleft', 'fenceleft.png'); game.load.image('fenceright', 'fenceright.png'); } // variables for character var cursors; var player; var left; var right; var up; var down; // add what will be in game function create() { game.world.setBounds(-250, -250, 550, 550); // set background color game.stage.backgroundColor = ('#3c6f42'); // add player image and place in screen player = game.add.sprite(-232, -100, 'player', 1); player.smoothed = false; player.scale.set(1); // player will "collide" with certain images like walls and houses player.collideWorldBounds = true; // ANIMATION FOR PLAYER CONTROLS down = player.animations.add('down', [0,1,2,3], 10, true); left = player.animations.add('left', [4,5,6,7], 10, true); right = player.animations.add('right', [8,9,10,11], 10, true); up = player.animations.add('up', [12,13,14,15], 10, true); // enable physics in the game (can't go through walls, gravity, etc.) game.physics.enable(player, Phaser.Physics.ARCADE); game.physics.startSystem(Phaser.Physics.P2JS); game.physics.p2.enable(player); // make sure to add this code to add items/walls/buildings addHouse(); addWalls(); // enable keyboard arrows for controls cursors = game.input.keyboard.createCursorKeys(); // camera will follow the character game.camera.follow(player); } // what happens when player does something function update() { // player will now collide with these images rather than pass over them game.physics.arcade.collide(player, house); game.physics.arcade.collide(player, walls); // PLAYER CONTROLS player.body.velocity.set(0); // player presses left key if (cursors.left.isDown) { player.body.velocity.x = -100; player.play('left'); } // player presses right key else if (cursors.right.isDown) { player.body.velocity.x = 100; player.play('right'); } // player presses up key else if (cursors.up.isDown) { player.body.velocity.y = -100; player.play('up'); } // player presses down key else if (cursors.down.isDown) { player.body.velocity.y = 100; player.play('down'); } // player does not press anything else { player.animations.stop(); } } function render() { }
  4. Hello World, I'm a pixel Artist and Game Designer sharing my work for the #gamedev sake. I just released a Free Public 2D Platform Pixel Art Pack for everyone. Check it out I even made an online Demo made with Phaser so you can see it in action: http://pixelgameart.org/demos/sunny-land/ Download this Pack at my site where I will be posting each month a Public Pixel Art Pack (code included): http://pixelgameart.org/web/portfolio/sunny-land/ Cheers and happy #gamedev
  5. Colorize - puzzle game

    Hi i would like to share with you my last game i made with phaser framework it is cross platform mobile ready game the source code is available on codecanyon codecanyon : https://goo.gl/H2nvea play the game : https://goo.gl/MojVRz video : https://goo.gl/gnl2fq
  6. Merge Generated Sprites: Code Snippet

    This is hastily thrown together code that I created as a solution for an idea that I have. I have texture gen data in objects and I wanted to merge various layers together. Reason being is if I create a number of various objects I wanted them to be placed on buttons later on. I plan on making a some code to replace various parts of the textures so that I can on the fly generate generated textures. This is handy for button and things of that nature which is why I created it. I decided to throw it out there in case anyone needed something like this or wanted to improve on the code. Also here is a working example of it on jsfiddle. Screenshot var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { create: create }); // taken from my code and striped out useless parts var gameScale = 2 var sprite = (function() { 'use strict'; var sprite = { creature: {}, misc: {}, object: {}, structure: {}, tile: {}, vehicle: {}, }; sprite.misc.buttonBackground = { size: [16, 16], data: [ '0000000000000000', '0999999999999990', '0999999999999990', '0999999999999990', '0999999999999990', '0999999999999990', '0999999999999990', '0999999999999990', '0999999999999990', '0999999999999990', '0999999999999990', '0999999999999990', '0999999999999990', '0999999999999990', '0999999999999990', '0000000000000000' ], }; sprite.object.table = { size: [6, 3], thumbOffset: [5, 8], data: [ '666666', '.6..6.', '.6..6.' ], thumbData: [ '666666', '.6..6.', '.6..6.' ], }; sprite.mergeData = function mergeData(bgData, fgData, xOffset, yOffset) { var bgDimensions = sprite.getDimensions(bgData); var fgDimensions = sprite.getDimensions(fgData); var size = sprite.getMaxDimensions(bgDimensions, fgDimensions); var newData = []; _.times(size[1], function(y) { var row = ''; _.times(size[0], function(x) { var s = '.'; if (yOffset || xOffset) { if (y >= yOffset || x >= xOffset) { if (fgData[y - yOffset] && fgData[y - yOffset][x - xOffset]) { s = fgData[y - yOffset][x - xOffset]; } } } else { if (fgData[y] && fgData[y][x]) { s = fgData[y][x]; } } if (s == '.' && bgData[y] && bgData[y][x]) { s = bgData[y][x]; } row += s; }); newData.push(row); }); return newData; }; sprite.makeTexture = function makeTexture(name, data) { console.info('Loading sprite `%s`.', name); return game.create.texture( name, data, gameScale, gameScale ); }; sprite.getDimensions = function getDimensions(spriteData) { if (_.isArray(spriteData)) { var y = spriteData.length; var x = 0; var count = 0; _.each(spriteData, function (row) { if (row.length > x) x = row.length; }); count = x * y; return [x, y, count]; } return false; }; sprite.getMaxDimensions = function getMaxDimensions(a, b) { if (!_.isArray(a) || !_.isArray(b)) return false; var x = Math.max(a[0], b[0]); var y = Math.max(a[1], b[1]); return [x, y]; }; return sprite; })(); function create() { game.stage.backgroundColor = '#2d2d2d'; // manually placed variables from itterated code; var groupKey = 'object'; var structKey = 'table'; var col = 0; var row = 0; var name = groupKey + '_' + structKey; var baseLeft = 100 + ((col * 16) * gameScale) + 2; var baseTop = 100 + ((row * 16) * gameScale) + 2; var bgData = sprite.misc.buttonBackground.data; var fg =sprite[groupKey][structKey]; var fgData = fg.thumbData; var newData; if (_.isUndefined(fg.thumbOffset)) { newData = sprite.mergeData(bgData, fgData); } else { newData = sprite.mergeData(bgData, fgData, fg.thumbOffset[0], fg.thumbOffset[1]); } var btnName = 'btn_' + name; var newTexture = sprite.makeTexture(btnName, newData); var objButton = game.add.sprite( baseLeft, baseTop, btnName); objButton.name = name; objButton.inputEnabled = true; objButton.input.useHandCursor = true; }
  7. Protect your phaser code

    Hello friends. I've a security question. I've done two mini-games for my company. I really enjoyed the chance of using Phaser in my work and not for fun, as I usally do. My boss liked it too, so good news. But he is concern because everybody are able to see the code with the elements inspector. My question is if there's some easy way to hide or protect the code from visitors, in order to avoid that our competititors steal the code for their own pages. Any advice? Thanks a lot!
  8. There is only one of the coins falling and I don't understand why that is. I looked at the code but I can't seem to figure it out.You will have to reload the page if you miss it ( it is the 5th coin from the left). http://phaser.io/examples/v2/tilemaps/create-from-objects
  9. Bug in cyclic movement

    Hi guys! I'm really pissed about my code. I reviewed so many times and I can't find the problem that is causing this bug. So, as you can see in these screenshots below, after a while running the game, the platforms starts acting strange. In the interval of platform 2 and 3, when the movement is from left to right, these platforms overlaps and when the movement is from right to left, the distance between then increase. The first screenshot is about the game start, so the problem didn't occured, yet. In the second screenshot, shows the bug in action and it get worse after a while running the game. well... the objective of these platforms is to do a cyclic movement from left to right and vice-versa, in an infinite loop, where the player will jumps on it catching items and killing enemies. So, I start my code creating the platforms in the Trail class, that holds 4 platforms per row. // trail group of platforms this._trail = this.game.add.group(); // fill the group with platforms for (var i = 0; i < total; i++) { var platform = new MovablePlatform(this.game, sprite, direction, speed); var initX; var finalX; switch (direction) { // move to left case 0: if (i === 0) { initX = this.game.width + platform.width; finalX = - platform.width * total - PLATFORM_GAP; } else { var lastPlatform = this._trail.getAt(i - 1); initX = lastPlatform.initPos.x + lastPlatform.width + PLATFORM_GAP; finalX = lastPlatform.finalPos.x + lastPlatform.width + PLATFORM_GAP; } break; // move to right case 1: if (i === 0) { initX = - platform.width; finalX = this.game.width + platform.width * total + PLATFORM_GAP; } else { var lastPlatform = this._trail.getAt(i - 1); initX = lastPlatform.initPos.x - lastPlatform.width - PLATFORM_GAP; finalX = lastPlatform.finalPos.x - lastPlatform.width - PLATFORM_GAP; } break; } platform.createPath(initX, posY, finalX, posY); this._trail.add(platform); } And in the class MovablePlatform I created the method "move", that starts the platform movement, applying the velocity in x-axis. The update method verify if the x position is equal or grater/lesser than the final position and reset the position, to start the movement again. MovablePlatform.prototype.update = function () { switch (this._direction) { // check negative bounds outside the screen case 0: if (this.x <= this.finalPos.x) { this.reset(); } break; // check positive bounds outside the screen case 1: if (this.x >= this.finalPos.x) { this.reset(); } break; } }; MovablePlatform.prototype.move = function () { switch (this._direction) { // move to left case 0: this.body.velocity.x = -this._speed; break; // move to right case 1: this.body.velocity.x = this._speed; break; } }; That is it! Does anybody know why it happen? And if anyone knows a better method to do cyclic movement, I would like to know and appreciate the sharing! Thanks!
  10. Hi. I have a problem with multiple levels (game states). What can I do when, I don't want to write the same piece of code in each level over and over? I've tried to create a function in separate js file which e.g. will set player sprite, gravity, animations or will create necessary variables etc. And I failed this. Everything what I have got are errors.
  11. I have started the blog in 2013 or so. I recently made more posts with code and am up to 30+ posts and almost all with code. I like to learn how to program 2d games and put the knowledge on the blog. I try to make everything I need to program games like platformers and rpg's ect. I have no idea how many posts I wil make on the blog. My other programming blogs have up to 200 posts most with code per blog so far. Here the link : there is a link on the page to the github page where the code is too. (download all code as a zip) http://html5gameprogrammingstepbystep.blogspot.nl/ I hope it helps people learn game programming.
  12. Sellfy (Phaser)

    Hello! I have started a sellfy in which I will post source code of project that is documented and a great way to learn Phaser, also a great way to support me too! https://sellfy.com/SiLD11 Thank you!
  13. Hi all, Regarding Reddit JSON API, you can get a JSON document by adding /.json to any Reddit URL. This can be used to extract various data from any subreddit making an image viewer/browser for instance. Furthermore, all images and their data scraped from a Reddit JSON could be also used to make some simple games. Here are some ideas: guessing which of two images has a better/worse upvotes scoreguessing a right range of upvotes for an image choosing between 2 or 3 different rangesguessing a title of an image choosing between 2 or 3 different titles as fast as possibleSo I decided to create a game based on some of these ideas in HTML5 using Phaser framework. But first of all, I need a tool for scraping images from a Reddit JSON file and I made it. The application and a short tutorial about its creation with the fully commented source code can be found here: http://www.askforgametask.com/2015/12/07/reddit-image-scraper/ In the next step I will try to make an HTML5 game using database of images generated by this tool.
  14. Hey guys I have designed a theme for Brackets code editor You can install it by searching for "Plasma Light Theme" in Brackets extension manager. Love any feedback
  15. Been coding some games in javascript for about 3 months. So far: an angry birds ugly clone (really crappy, using box2dWeb), a shooter like sonic wings (way smaller, though), and some simple games like pong, breakout and a simple endless runner with no sprites, just using rect and arc to draw. I've been experimenting with ways to plan the code, and realized that I output more and finish things quicker if I don't actually plan anything at all: just sit there and code, and deal with problems as they occur. Do you guys do that way too? I guess maybe because all games I did were small ones this works. Maybe for bigger ones it will be a mess, even though the code I write is usually clean. How do you guys go on about planning all the functions, objects and interactions amongst your games?
  16. How would you go about adding physics int babylon.js? I followed a youtube series by Kris Occhipinti on babylon and got it working but what if you want it to work with imported objects? My code: <script> var canvas = document.getElementById("renderCanvas"); var engine = new BABYLON.Engine(canvas, true); var scene = new BABYLON.Scene(engine); //Physics!!! scene.enablePhysics(); scene.setGravity(new BABYLON.Vector3(0, -10, 0)); var assetsManager = new BABYLON.AssetsManager(scene); var meshTask = assetsManager.addMeshTask("skull task", "", "./", "models/untitled.babylon"); meshTask.setPhysicsState({ impostor: BABYLON.PhysicsEngine.BoxImpostor, mass: 0, friction: 0.5, restitution: 1 }); meshTask.onSuccess = function (task) { task.loadedMeshes[0].position = new BABYLON.Vector3(0, 0, 0); } var Camera = new BABYLON.ArcRotateCamera("Camera", 1, 1, 100, new BABYLON.Vector3(0, 0, 0), scene); scene.activeCamera.attachControl(canvas); assetsManager.onFinish = function (tasks) { engine.runRenderLoop(function () { scene.render(); }); }; assetsManager.load(); window.addEventListener("resize", function () { engine.resize(); }); </script>
  17. How to read the Documentation

    Hello guys, I'm having a bit of trouble applying what I read from the documentation. For instance, I want to use the input keyboard properties of "lastChar" and "lastKey", but I just don't know how to translate that into code. This is what i have tried: this.game.input.keyboard.lastChar; this.game.input.keyboard.lastKey; this.game.input.keyboard.lastKey(); I tried other combinations that didn't work. Do any of you guys know how to apply the code from the docs that are not seen in any of the examples? Thanks guys!
  18. Selling Source Code [GMS]

    Hello all, I'm looking to sell the source code to several of my GameMaker-studio based mobile-web HTML5 games. I won't be posting them publicly, but if you PM me I will answer promptly with the games, prices, and any other information you might need. Thank you
  19. Help with collision

    Hello How do I change the collision group of an object in my game when it collides with a different object Would I have to do this is a function? could you please give an example Thanks
  20. Hello. I searched some of the project templates in Phaser Gituhub but it seems the assets/images are not available for download. Can you please suggest me some link where can I find free to use finished Phaser game that I can convert into Cordova/Android mobile game just for testing purposes? I already started something with cordova and managed to deploy emulator and working environment. But when I run my game I just see the background color of index.html file. I assume the game is out of viewport so I kind of need help to understand what is going on. Also what docs/books can you refer me when speaking about Cordova/Phaser? There is nothing in the phaser docs.
  21. Hello everyone, firstly I am new to Phaser, but I would really like to create a typing/educational game ! (like moon-type : http://www.wordgames.com/moon-type-2.html) I have already created a background and a caracter (the simplest stuff), but I have no idea how to create moving text blocks containing a dictionnary (although I have a .txt file with a list of all existing words), progressive difficulty and a scoring system.. I know, I'm asking a lot, but i really need help, I'm more on the actual look of the game. Please help me ! Thank you in advance.
  22. Phaser Code Completion for Eclipse

    Hello I created a set of Eclipse Editor Templates with the code completions used by the Phaser sandbox (http://phaser.io/sandbox) You can see instructions to install it on Eclipse here: https://bitbucket.org/boniatillo/phasereditortemplates Screenshot:
  23. Hello, I'm trying to get a button in my game to use other functions, and I haven't quite figured out how, other than brute forcing it. // Let's say I have everything preloaded and I'm in my game state filevar main = function(game) { var button1; var button2;};// and my prototype is something likemain.prototype = { create: function() { button1 = this.add.button(0, 0, 'button1', this.button1); button2 = this.add.button(100, 100, 'button2', this.button2); } button1: function() { // I might want to use otherfunc to do stuff while doing other stuff } button2: function() { // this is where I want to use button1's function and do other things } otherfunc: function() { // does more stuff }}Help is greatly appreciated.
  24. Cant change the sprites in flying dog

    Hello, Every time I use texturepacker for a sprite sheet and upload it to the flying dog game it does not work for me and the game freezes I have also tried to upload images individually and add it to the game asset but that doesn't work as well Can someone please help me? thanks
  25. Recently I have been following an ongoing discussion regarding mobile performance and efficiency. One of the recommendations that caught my eye was to avoid classes and prototyping altogether because they can slow down the performance significantly. So far I have structured my code by creating separate class objects in different files by using prototypes. class = function () {}class.prototype.myMethod1 = function () { console.log('myMethod');}class.prototype.myMethod2 = function () { console.log('myMethod2');}In this regard, I am wondering what is the recommended and most efficient way to structure your code? Perhaps the more experienced users can share something from their bag of tricks. Thanks