Search the Community
Showing results for tags 'random placement'.
Found 1 result
Multiple problems with my phaser-projectHello everyone, at the moment I'm stuck with my phaser-project in a dead end and would really need help with it. About my project: It's a top-down-game, in which the player, who controls an avatar on the game world, has to collect 8 collect-objects in a random selected order and after that, to move to the exit. If the avatar touches the current required collect-object, it disappears and the next one is chosen by the game. If the avatar touches a current not required collect-object or the exit before having collect all the other objects, nothing happens. The game world is 11x11 tiles big with a border of wall-tiles and 16 free standing wall tiles in the middle (bomberman-like). The game objects (player, collect-objects, exit) will be randomly placed on the free tiles in the game world, the movement of the player is tile-based. The tiles and the game objects have a size of 100 x 100 px each. The thematic goal of the game is to repel the attacks of the enemy (walking over the respective symbol) as fast as possible and as least to leave the game world via the exit. Later there should be added an UI with an menu (inclusive an timer and pause-function) under the game world, but it's not a part of my current problems. The example project I use is https://github.com/jansensan/test-phaser-js-tile-based-movement. Main reason is, that the tile-to-tile movement is the best working for my needs. What I had changed sucessful at the moment on it: I was able to remove the NPC from the project and changed the game world to what I wanted, inclusive the pixel-size of the all tiles and game objects. I found a way to bring another single game object (exit) into the game world (but without being able to interact with). All needed placeholder spritesheets, tilemaps and images are finished in correct size. Current target for the project: All game objects are placed on defined positions. The player collects the collect-objects in a set order (1-8) and then goes to the exit. What are my exactly problems and what have I try out yet: 1. Displaying: The game isn't shown completely on the screen (at least not on my 2160 x 1440 monitor). The lower part of the game is missing and only complete visible at 70 % zoom factor. For this problem, I have tried many different things to work with _game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL , but everytime without sucess. I have put it in the game.js inside the initPhaser- as well as in the create-function. I know that it's possible to show the whole game with the wanted stats on my screen, because it worked fine in the pacman/car example from the phaser-website. -SOLVED- 2. I don't know, how to operate with my game objects as groups in my example and place them on defined positions. Reason for this is, that I don't understand some parts of the example completely and in my former projects, I always used references in an object-layer inside of a json-file to define the positions of the game objects. Because of this, I wrote an another Spielobjekte.json [game objects] where all the game objects (except player) are summarized. 3. Interaction of the player with other game objects: I cannot correctly activate the necessary Arcade.Physics and enable physics.arcade on game objects won't work too. I have tried to enable it in the init-function of the player.js and ausgang.js [exit], only got errors in the process. But I need it to work later with game.physics.arcade.overlap to get the interactions beween game objects. The check for the correct order can I later finish with if(Sammelstatus==SammelID) [if(collect status==collectID)]. Distant problems and ideas: 4. Random collect order: My idea is, to put the Ids of the attacks in an array. Then I use emoveRandomItem to take a random value out of it, who is compared when touching an game objects with if(AngriffID== SammelID) [if(attackID==collectID)]. If the array gives null as attackID, the player can use the exit. 5.Random placement of game objects: For this, I would work with safeTile-values I define in map.js and take from the collision-layer in the map.js. The way I want to use is „take 10 random safeTile-values and assign every game object 1 random value“. A personal problem for me is, that I'm not as much experienced with arrays at the moment. Pastebin-links to my files (current status, some has senseless code because of testings). index.html: https://pastebin.com/AH1GdbD8 game.js: https://pastebin.com/VPbaEfRn map.js: https://pastebin.com/JSKtuvDc abstract-image.js: https://pastebin.com/PCjJddi7 abstract-sprite.js: https://pastebin.com/L7Ku8ZZk ausgang.js: https://pastebin.com/8WTN3rUS player.js: https://pastebin.com/hwCSnpZu Sammelobjekte.js: https://pastebin.com/4mjPsfvE image-constants.js: https://pastebin.com/e4wmgxB3 sprite-constants.js: https://pastebin.com/nrEb50Ss map.json: https://pastebin.com/KqGsmFRJ Spielobjekte.json: https://pastebin.com/y05YDPWW Translation note german = english: Hintergrund = background Angriff = attack Abwehr = defend Spielobjekte = game objects Spieler = player Ausgang = exit Sammelobjekte = collect objects Sammelstatus = collect status Thank you for helping me Arnon