Kacper Pietrzak

  • Content count

  • Joined

  • Last visited

About Kacper Pietrzak

  • Rank
  • Birthday 07/05/1999

Contact Methods

  • Website URL

Profile Information

  • Gender
  • Location
  • Interests
    Running, volleyball, JavaScript and games development :)

Recent Profile Visitors

721 profile views
  1. How does blendModes work in Phaser.Graphics compared to Sprites

    @samme Setting in only on sprite works just fine, but I cannot afford generatingTextue from Phaser.Graphics every frame. Setting it only on Phaser.Graphics and not applying it to sprite but just displaying results in white color not giving a nice transparent flashlight shape, but is not visible at all. Making it darker than pure white results in what you see one the left side of the picture. So, this behaviour is still kind of mystery for me.
  2. Hey guys, Recently I've noticed some strange behaviour while using blendModes on Phaser.Graphics. I am creating a flashlight by drawing dark rectangle and lighter calculated shape of light from flashlight, I draw that on Phaser.Graphics object. Then I apply this object as a texture to sprite to see the difference between rendered outcomes. this.shadowTexture = this.player.game.add.graphics( 0, 0 ); this.shadowTexture.blendMode = Phaser.blendModes.MULTIPLY; this.sprite = this.player.game.add.sprite( 200, 0, this.shadowTexture.generateTexture() ); this.sprite.blendMode = Phaser.blendModes.MULTIPLY; update(){ // draw on shadowTexture ... this.sprite.texture = this.shadowTexture.generateTexture(); // just for test purposes } this code results in such situation: As you can see, blendMode used in Phaser.Graphics resulted with darker flashlight and the one used in Phaser.Sprite in lighter. Am I getting this all totally wrong ? Or is this some kind of a bug ? What I would like to achieve is the effect that I get using Sprite just by using Phaser.Graphics. Please, help guys, I am a bit confused here Thanks
  3. How to make gameover + try again

    You can simply create a Phaser.Text object, set its visible property to false and set it to true on game end. There are of course some things to take care of, dependent on your project such as blocking player's input. You can do exactly the same with Phaser.Button that says Try Again. And just in onclick callback of the button reset whole scene.
  4. Applying multiple masks to single sprite

    Question is pretty straightforward, how can I apply multiple masks to one sprite. Let's say I have a sprite and I want it to be displayed only in particular places. In my case I want zombies to be visible only in light, having only flashlight it's pretty easy to implement since there is only one source of light and I can do something like that: this.zombies.setAll('mask', this.flashlightGraphics); But what do I do when I want to apply multiple masks, is there a way to combine graphics objects ? Thanks
  5. I am sorry, but I couldn't get your solution working, even game.js file that you attached doesn't seem to work for me I cannot tell the difference between the gameplay from original file and the one that you've send me. Also there are couple mistakes in code snippets that you've send, could you please send me only Flaslight.js file that works for you ? And again thanks for your time, I really appreciate
  6. The thing is, the way that I'm handling dynamic lighting is creating mask that cuts off the shape of light from flashlight that is precisely calculated, so any effect that makes this light bigger, like glow filter, is useless for now. because it gets cut off, have to think about it
  7. Hey everyone! I've implemented simple dynamic lightning in my project, but what I'm missing is soft light edges effect. This what it looks like now: https://youtu.be/M-idTMGYvsw I use sprites' masks to achieve that, code looks somewhat like this: updateShowingLayer() { + this.showMaskGraphics.clear(); + this.showMaskGraphics.lineStyle( 2, 0xffffff, 1 ); + this.showMaskGraphics.beginFill( 0x00000000 ); + this.showMaskGraphics.moveTo( this.player.x, this.player.y ); + + for ( let i = 0; i < NUMBER_OF_RAYS; i++ ) { + const rayAngle = mouseAngle - ( LIGHT_ANGLE / 2 ) + ( LIGHT_ANGLE / NUMBER_OF_RAYS ) * i; + let lastX = this.player.x; + let lastY = this.player.y; + for ( let j = 1; j <= RAY_LENGTH; j++ ) { + const landingX = Math.round( this.player.x - ( 2 * j ) * Math.cos( rayAngle ) ); + const landingY = Math.round( this.player.y - ( 2 * j ) * Math.sin( rayAngle ) ); + if ( !this.isTileBlocking( landingX, landingY ) ) { + lastX = landingX; + lastY = landingY; + } else { + break; + } + } + this.showMaskGraphics.lineTo( lastX, lastY ); + } + this.showMaskGraphics.lineTo( this.player.x, this.player.y ); + this.showMaskGraphics.endFill(); } } And then I just set masks in corresponding sprites to `this.showMaskGraphics` The full code is available here: https://github.com/PiGames/Project-Nostradamus/blob/dynamic-lightning/src/objects/Flashlight.js Does anyone have an idea how to make this light soft ? Thanks
  8. [Phaser] Feed The Bob

    @Umz Thanks, nice to hear that!
  9. [Phaser] Feed The Bob

    @RubbleGames Thanks for the feedback! The point is that you don't have to read the wiki, most of the players already know some basics like chicken === proteins, and you can learn through playing itself. Wiki is just a place where you can find detailed info, but it is not necessary to play and have fun
  10. [Phaser] Feed The Bob

    Thanks! Donuts in reasonable quantity aren't that bad The game has its problems with carbohydrates, in real life you eat them with almost every meal. But we thought that it's more attractive for a player to tap on a donut or an apple than on potatoes or rice
  11. [Phaser] Feed The Bob

    Hi Everyone, My team - PiGames have recently finished Feed The Bob, a simple game about keeping proper nutrition style. The idea for the game came from a hackathon, which goal was to help solving the problem of civillization diseases. Live version here: pigam.es/Feed-The-Bob/ Game is available for licensing, for more info, contact me: kacpietrzak@gmail.com I'd love to here your feedback about this game! We are still learning how to make great games, so every honest feedback will be very appreciated.
  12. Finally It works! Thank you very much for your time