noobshit

Members
  • Content Count

    14
  • Joined

  • Last visited

About noobshit

  • Rank
    Member

Recent Profile Visitors

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

  1. noobshit

    P2 Space Shooter Dogfight AI Rotation

    var currentAngle = fightSprites.enemy[i].body.rotation; correctAngle = tempAngle + (3.141/2); difference = correctAngle - currentAngle; lag = 0.3; fightSprites.enemy[i].body.rotation += difference * lag; Maybe it will help.
  2. noobshit

    How to find code for method?

    It has to be mistake in examples. Code will work, because: game.load.image(key, url, overwrite) game.load.image('menu', 'assets/buttons/number-buttons-90x90.png', 270, 180); key = 'menu'; // correct url = 'assets/buttons/number-buttons-90x90.png'; // correct overwrite = 270; // 270 in logical expression is true, no problem... // 180 will be ignored Javascript... thats the reason I'm using Typescript:
  3. noobshit

    game.physics.p2.useElapsedTime = true;

    /** * Internal P2 update loop. * * @method Phaser.Physics.P2#update */ update: function () { // Do nothing if the physics engine was paused before if (this.paused) { return; } if (this.useElapsedTime) { this.world.step(this.game.time.physicsElapsed); } else { this.world.step(this.frameRate); } }, /** * @property {number} frameRate - The frame rate the world will be stepped at. Defaults to 1 / 60, but you can change here. Also see useElapsedTime property. * @default */ this.frameRate = 1 / 60; https://github.com/photonstorm/phaser/blob/v2.5.0/src/physics/p2/World.js#L66 https://github.com/photonstorm/phaser/blob/v2.5.0/src/time/Time.js#L119 /** * The physics update delta, in fractional seconds. * * This should be used as an applicable multiplier by all logic update steps (eg. `preUpdate/postUpdate/update`) * to ensure consistent game timing. Game/logic timing can drift from real-world time if the system * is unable to consistently maintain the desired FPS. * * With fixed-step updates this is normally equivalent to `1.0 / desiredFps`. * * @property {number} physicsElapsed */ this.physicsElapsed = 1 / 60; /** * The physics update delta, in milliseconds - equivalent to `physicsElapsed * 1000`. * * @property {number} physicsElapsedMS */ this.physicsElapsedMS = (1 / 60) * 1000; So basically if this.useElapsedTime is true it uses frameRate == 1/60, if not it uses physicsElapsed == 1/60. No matter what useElapsedTime is set it will use 1/60.
  4. noobshit

    Measure distance in p2

    I'm just learning P2. Yesterday I had similar problem. Green = weapon slots and I was wondering how to spawn bullets from them. getBulletStartingPosition() : Phaser.Point { let x = this.x; let y = this.y; let angle = this.parent.angle; let d = Math.sqrt(x*x + y*y); let angleFromCenter = Utils.degrees(Math.asin(x/d)); let offset = Utils.rotateDistance(angle + angleFromCenter, d ); return new Phaser.Point(this.parent.x + offset.x, this.parent.y + offset.y); } x, y are cords from center of spaceship. angle is angle spaceship is heading Then I calculate distance (d) and angleFromCenter. I think you can use similar approach to solve your problem. // Rectangle = player // Circle = object let x = circle.x - rectangle.x; let y = circle.y - rectangle.y; let angle = rectangle.angle; let distance = Math.sqrt(x*x + y*y); let angleFromCenter = Utils.degrees(Math.asin(x/d)); let angleRelative = angleFromCenter - angle; if ( angleRelative > -45 && 45 > angleRelative && 1000 > distance ) { // in sight } else { // out of sight } static degrees(radians : number) : number { return radians * 180 / Math.PI; } I didn't test this code, but I think it should work.
  5. create() { game.physics.startSystem(Phaser.Physics.P2JS); game.physics.p2.useElapsedTime = true; game.physics.p2.setImpactEvents(true); ... } // On shotgun shell shot game.time.events.add(Phaser.Timer.QUARTER * 3, this.split, this); I expected to get split at constant distance from space but it's depends on framerate. How to make time event in P2 timer? https://noobshit.github.io/ - here is example of problem (cursors to move, space to shoot)
  6. noobshit

    In game tutorial/help

    I'm making single n-back game https://noobshit.github.io/ What is best way to show user how to play? What hotkeys are used? Should I make screenshoots with additional labels/arrows to explain GUI or is there a better way?
  7. noobshit

    N-back game scroll animation makes me sick

    Thanks for help. I'm sure it was a problem. I have huge monitor (30'' = 2560x1600) and on fullscreen shapes moved few cm each frame, it wasn't smooth at all. In fact I was 100% sure I had performance issues. I looked at https://jsfiddle.net/BinaryMoon/a68Qp/ and I'm using now Phaser.Easing.Quadratic.InOut. Now I have to improve few more things and my first game will be done. Thank a lot!
  8. noobshit

    Phaser 2.5.0 Released

    Nice update it fixed my problems which I posted in: Love ya!
  9. https://noobshit.github.io/ I'm trying to make good old n-back game. Plaese use left/right cursors to rewind tape. Even after short playing session I feel sick. Are you feel the same? What is the reason, how to avoid it?
  10. Hey! Could you help me with blinking/flicker issues? Second post has demo code and video. When I try to wrap world coins do flick/blink and user can see them for a split second in old (wrong) location. Do you have tips how to avoid it? 

     

    https://github.com/noobshit/Demo

  11. noobshit

    Sprites flickering/blinking

    var game = new Phaser.Game(512, 512, Phaser.AUTO); var Demo = (function () { function Demo() { } Demo.prototype.preload = function () { game.load.image('player', 'assets/player.png'); game.load.spritesheet('coin', 'assets/coin.png', 44, 40); game.load.image('sky', 'assets/sky.png'); }; Demo.prototype.create = function () { game.world.setBounds(0, 0, 1024, 512); this.sky = game.add.sprite(0, 0, 'sky'); this.player = game.add.sprite(256, 256, 'player'); this.items = game.add.group(); for (var i = 0; i < 50; i++) { var x = game.rnd.integerInRange(0, game.world.width); var y = game.rnd.integerInRange(0, game.world.height); this.items.create(x, y, 'coin'); } this.cursors = game.input.keyboard.createCursorKeys(); game.camera.follow(this.player); }; Demo.prototype.update = function () { var speed = 10; if (this.cursors.left.isDown) { this.player.x -= speed; } else if (this.cursors.right.isDown) { this.player.x += speed; } var padding = game.width / 2; if (this.player.x + padding > game.world.width) { this.player.x = padding; this.items.x -= 2 * padding; } else if (this.player.x - padding < 0) { this.player.x = -padding + game.world.width; this.items.x += 2 * padding; } }; return Demo; }()); game.state.add('Demo', Demo); game.state.start('Demo'); <html> <head> <script src="js/phaser.min.js"></script> </head> <body> <script src="js/demo.js"></script> </body> </html> I'm using phaser 2.4.8. How it looks in chrome... https://vid.me/7kuZ
  12. noobshit

    Sprites flickering/blinking

    I want to create game with unlimited world. I decided to make world wrap to move player and items to new position when player reaches end of world. wrapHorizontal() { let padding = game.width/2; let player = this.intoHell.player; if ( player.x + padding > game.world.width) { this.wrapped.x += 1; this.intoHell.player.x = padding; this.intoHell.background.sky.tilePosition.x += 2*padding; this.intoHell.items.x -= game.world.width - 2*padding; } else if ( player.x - padding < 0 ) { this.wrapped.x -= 1; this.intoHell.player.x = game.world.width - padding; this.intoHell.background.sky.tilePosition.x -= 2*padding; this.intoHell.items.x += game.world.width - 2*padding; } } But it makes items/sky blink. I use this function everytime in update() and I move player using body.velocity from arcade physics system. What can be cause of this behavior? intohell.zip EDIT: https://github.com/noobshit/intohell
  13. noobshit

    Phaser overlap

    I figured out that changing group x, y does affect body.x, y with lag. Is there a way to force body to update?
  14. noobshit

    Phaser overlap

    Hey guys! I wanted to create "can you place building here?". Sometimes I get wrong answer. I create net 10x10 createNet(width, height) { this.net.removeChildren(); for(let i = 0; i < height; i++) { for( let j = 0; j < width; j++) { this.net.create(j*16, i*16, 'net'); } } this.net.forEach( o => o.anchor.set(0.5, 0.5)); this.net.setAll('alpha', '0.5'); } I have callback: game.input.addMoveCallback( (o) => this.updateGrid()); where i try to update color updateGrid() { let x = game.input.activePointer.x ; let y = game.input.activePointer.y; x -= (x-8) % 16; y -= (y-8) % 16; if ( x != this.net.x || y != this.net.y ) { this.net.x = x; this.net.y = y; this.net.forEach(o => this.updateColor(o)); } } updateColor(o) { o.frame = game.physics.arcade.overlap(o, this.obstacles ) ? 1 : 0; } http://pastebin.com/2jME8vbg - here is more code, I also attached full project. I feel right x/y or frame is update too late but I don't know how to prevent it. buildingPlacer.zip