Jump to content

Search the Community

Showing results for tags 'random'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
  • Frameworks
    • Phaser 3
    • Phaser 2
    • Pixi.js
    • Babylon.js
    • Panda 2
    • melonJS
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

  1. Greetings. I have 5 webpages with games. I want another html5 page to generate 5 random numbers where every number opens one of the game pages. I used to do this on flash with a simple small .swf and embed it in the HTML page. It looks like: variable=random(5); if variable == 1 {open game page 1}; if variable == 2 {open game page 2}; ans so on.. Now I need to do that with clean HTML5, How to do it?
  2. hello, I am very new in Phaser2 and I need help in something. this thing is to do something like enemies' generator. My idea is that in a position it is chosen between 2 enemies to be generated, then spent a second, in the same position become another enemy between the two and this way successively... thank you ❤️:c
  3. Hi guys, how do you place items(sprites) randomly on your world and ensure that they don't overlap with other already excisting items? Do you check every item or are there functions from the physic engines that support you with that? If there are no built in functions I would do it the following way: 1.) create random placement of sprite 2.) check newly placed items against all excisting items in the world 2.1) No overlapping -> GREAT finish! 2.2) If it overlaps repeat step 1. (abort after X cycles to avoid endless loop and performance spikes if you place them while the game runs)
  4. There is a puzzle game at http://www.html5pcode.com/a1ypuzzle.htm The p-code was written in HTML5 JavaScript. The home page is http://html5pcode.com A pattern was made for each puzzle piece. Random numbers were used to make the jagged sides. HTML5 has an image option that allows you to use a pattern like a cookie cutter. The result was an image that could be turned and then placed on the right side of the screen. Random number were used to determine where each piece would be placed. This game is written in a p-code. The p-code is executed by a p-code engine. If you click on PROG
  5. var game = new Phaser.Game(400, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update }); //creating score value and onscreen text var score = 0; var scoreText; //creating random spawning place for diamond var diamondX = game.world.randomX(); var diamondY = game.world.randomY(); function preload() { // preload assets game.load.image('sky', 'assets/img/sky.png'); game.load.image('ground', 'assets/img/platform.png'); game.load.image('star','assets/img/star.png'); game.load.image('diamond', 'assets/img/diamond.png'); game.load.spritesheet('baddie', 'assets/img/dude.png
  6. I would like to create a scoring system in which the coins randomly descended into different places. Sorry if the english is bad (still lurning the language). This is my code. (function () { var game = new Phaser.Game(540, 303, Phaser.AUTO, 'container-game', { preload: preload, create: create, update: update, }); var estrada, player, keys, moedas; function preload() { this.velocidade = 80; // CARREGAMENTO DE IMAGENS game.load.image('background', 'img/background.png'); game.load.spritesheet('boneco', 'i
  7. I am trying to make a platformer mod of the first tutorial platformer, and this is my first time working with phaser. I am attempting to have diamonds spawn from the sky on a timer, that the player may collect. Everything except the spawning of diamonds seems to be working correctly, my code is as follows: <!--The sprites and some of the movement controls for this game come from this tutorial: https://phaser.io/tutorials/making-your-first-phaser-game --> <!doctype html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>Phase
  8. Hello, I'm creating endless style game and I'm planning to reuse already existing sprites instead of creating new ones. My sprites are coming from the top moving towards the bottom of the screen, when they reach bottom I reset their position.y to 0 which brings them back to the top again, but I also wanted them to have random position.x every time they start again from the top, I called this function: obstacles.forEach(function(obstacle){if(obstacle.position.y > this.game.world.height){obstacle.position.y = 0; obstacle.position.x = this.game.rnd.between(0, this.game.world.width);
  9. I have a bit of code that cycles through my TILED file to find any object I declared as an NPC. I am not sure if this is important, but I wanted to mention how it found the location of the sprite. (And it is designed to work with multiple sprites, but the code fails with a single sprite and multiple sprites) result.forEach(function(element){ this.createFromTiledObjectMove(element, this.doors); //alert (this.doors); }, this); The code above works correctly again it is just for reference on how the next part of the code is found. The code below was INTENDED to ha
  10. I'm making an endless runner and need to generate an obstacle every 2-6 seconds for the player to jump over. I have three obstacle sprites, two along the 'ground' and one hanging from the top of the game window. I was thinking about using a group and randomly selecting a key from that group. sprites must enter from the right and move along y until they go of screen on the right then are killed and re-used again. I've been trying multiple methods to active this but with no luck, its all bit over my head, I'm not even sure whats going wrong. So i'm looking for a bit of direction and advice
  11. I'm making an endless runner as my first dive into phaser and I've working on getting the 'obstacles' for my player to jump over. I have 3 obstacles for the player to jump over, 2 on the 'ground' and 1 hanging from the top of the game. My plan is to have one obstacles randomly generated every 2-6 seconds and for them to move towards the player (the player is static except for being able to jump). But I'm not sure how to go about this. Can anyone point me in the right direction? just some sudo code or ideas how you would approach the problem? My repo is https://github.com
  12. Just a random one I thought I'd put out there Anyone find it easier to explain things in code, rather than in words? Is that a sign or poor language skills or good coding skills haha.
  13. Hello, I want to create a game using Phaser. I want to add sprites randomly, but they shouldn't overlap each other. What is the best practice to achieve this. Here is my code, but I saw overlapping sprites sometimes: var obstacles = []; var items = []; function loadMap () { for (i = 0; i < 100; i++) { var obs = game.add.sprite(game.world.randomX, game.world.randomY, 'obstacle'); game.physics.enable(obs, Phaser.Physics.ARCADE); obstacles.push(obs); } } function loadItems () { for (i = 0; i < 36; i++) { var item = game.add.sprite(ga
  14. So how can I set random speed for every object, so the acquired speed will stay? Now I have defined speed as constant, but it also increases the speed of every object. SPEED = 3; this.enemies.forEachAlive(function(enemy){ enemy.body.velocity.x += Math.random(SPEED + (SPEED/2)); }); I tried first with Tanks -example style, where is defined max and min speed, but i didn't work.
  15. Hi! Does anyone know how I might be able to load a different background each time a game is started? I have three different preloaded backgrounds and would like the game to select a random one each time the game begins. I'm a complete newbie to Phaser and any help/tutorials would be hugely appreciated! Can link code if needed. Thanks!
  16. hey guys, I have a bottom-top game where I have the player navigating through objects. However, I am wondering if it is possible to have the game make minor changes to the x coordinate as opposed to me setting the object to specific coordinates? if you guys could provide any help that would be much appreciated!
  17. So I have 3 different characters (using the same sprite at the moment). They are supposed to roam given a predefined path for each. I am using 3 different loops so that they start at different times. I don't want them to start and stop at the same time. Trying to make it as natural as possible and so far I got this http://jsfiddle.net/Batzi/abs191e5/250/ Can someone suggest improvements? I need to make it look as smooth and natural as possible.
  18. Hi! I've been at this for hours. I'm trying to make an endless runner game. The idea is that the player is standing still, but the stage is moving, giving the illusion that the player is moving. I want to generate some obstacles at a random distance from each other. Like so: _____@_____@__@________@__ At some point maybe I'd like to set the minimum space between each obstacle but I'm far from there. Here's what I got for now: create() { spawn = 1000; timer = game.time.events.loop(spawn, this.addObstacle, this);},update() { this.updateTimer();},updateTimer: function() { rand
  19. Hey Everyone, Been working on this for a while, and finally ready to release it into the wild! I've created a 'template' for a Random Dungeon Generator using phaser. Please check it out on my blog, where I also have a live demo of it. Feel free to copy, share, etc the code and ideas, and please let me know if you have any changes or improvements, and I would love to see what games people come up with using it
  20. I found this function really useful except for picking the last element, which is really really hard in comparison with the other elements, because only the number '1' in a random selection between 0 and 1 with double precision floating points can give the last element. Therefore, the probability of obtaining the last element is too low to be useful. var test = [0,1,2,3,4,5,6,7,8,9];for(i = 0; i< 1000000; i++){ rnd = this.game.rnd.weightedPick(test); if(rnd == 9) console.log(rnd);} PS: The way i solved this is by adding a "dummy"(or a placeholder) element in the last place of
  21. Hi guys! I'm trying to develop a road with Phaser (My idea is that a car moves for him). How can I do that when the car is outside is slow? My first test: http://codepen.io/jdnichollsc/pen/YPEeYe Any help is greatly appreciated! Regards, Nicholls
  22. HI, I'm new to phaser framework, I did some tutorials but these were very basic and do not go towards the game I have to make for a course. I was looking for any help which can help me finish it. I just been able to put some images on screen and add a counter by click on them. Word Memory game Level 1 – A group of words(images) appears for 10 seconds, they then disappear and are replace by another group of words, from this new group of words the player has to identify which of these words are from the last. Input is done by clicking and there is a countdown timer of 1:50minutes+10s
  23. Hi, I've been trying to tween my sprite to random x and y co-ordinates in a loop, but after the initial random values are set it just loops between them instead of generating new random values. Anyone know how to solve this problem?? this.add.tween(this.sprite).to( { x: this.rnd.realInRange(-100, 100) }, 1000, Phaser.Easing.Linear.None) .to( { y: this.rnd.realInRange(-100, 100) }, 1000, Phaser.Easing.Linear.None) .loop() .start();
  24. I'm making a vertical scrolling platform game using Phaser, but I can't figure out how to create randomly placed platforms to jump on. This is the code I have so far (removed unneccesary stuff): Platformer.Game = function (game) { this._platforms = null; this._platform = null; this._numberOfPlatforms = 15; this._x = this.x; this._y = this.y; }; Platformer.Game.prototype = { create: function (){ this.physics.startSystem(Phaser.Physics.ARCADE); this.physics.arcade.gravity.y = 200; this._platforms = this.add.group(); Platformer.platform.createPlatform(this); Platformer.platform.createPlatform(t
  25. In my code im trying to have 3 diff colour blocks spawn in various areas on the screen, but one of the three red blocks spawns exactly on top of a blue one every single time. It makes no sense as I am using a math.random and have even used a game.add.text to make sure that the numbers aren't exactly the same yet it keeps happening. The relevant code is in green, thanks for any help. My code: var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update,});var Rx = Math.random () * 800; // ball spawns in a random placevar Ry = M
×
×
  • Create New...