bjorny

Members
  • Content Count

    3
  • Joined

  • Last visited

About bjorny

  • Rank
    Newbie

Recent Profile Visitors

610 profile views
  1. Hi everyone, I want to make a basic rhythm game in Phaser where the user has to hit specified keys to 'catch' the incoming notes while staying in rythm. So far the main game area roughly looks like this: The idea is that the key must be hit (and the corresponding note played) when the note sprite fully overlaps the key sprite, and the score is calculated based of how close the note sprite is to the top edge of the key sprite. I have an array of percussion loops with various BPMs I made in a DAW which change after each level to increase the difficulty. When the level starts this function is called: beginPlaying: function(l){this.noteCount = 25;this.currentLoop = this.loops[l];this.currentLoop.play();this.maxInterval = this.currentLoop.durationMS/4;this.timer.add(0, this.generateNotes, this);this.timer.start();},generateNotes function goes like this: generateNotes: function(){if(this.noteCount > 0){var num = this.game.rnd.integerInRange(0, 4);var note = this.notes.create(this.noteFlags.getAt(num).x, this.game.height - 20, 'note');this.game.physics.arcade.enable(note);var distance = note.y - this.noteFlags.getAt(num).y;note.body.velocity.y = -(distance/(this.currentLoop.duration/2));this.noteCount--;this.timer.add(this.maxInterval, this.generateNotes, this);}},I'm planning to make it more complicated by spawning notes not only at maxInterval, but so far I'm facing a problem: even though the first few notes seem to land perfectly in rhythm with the currentLoop, later they stop keeping up with the drums and the whole thing goes completely out of sync. I suppose this has something to do with the sound duration in ms and the fact that this.maxInterval is not a whole number. I tried rounding the numbers using Math.round and Math.floor and I also tried alternative methods of calculating note positions, like n.y -= (distance/(this.currentLoop.duration/2))/60;called using this.notes.forEachAlive method from the update function. Right now I'm completely lost (I guess that's the price you pay when you start programming while not being very good at maths ). Is there any way to deal with the audio/velocity sync problem? I would very much appreciate any suggestions Thanks!
  2. Wow, how could I be so ignorant not to think about this) Thanks a lot, lewster32! The grid scenario is also a good point, I will take note of this as well.
  3. Hi everyone, I'm trying to make a simple puzzle game where the player has to move around horizontally and place blocks to build a certain structure (kind of like 2D Minecraft, but this is not the point ). Something like this: (this is only a sketch, of course ) The problem is, I want the player to be able to place blocks only if they wouldn't overlap with each other - I made a separate invisible sprite to serve as a 'bounding box' where the block would be placed if it's not overlapping with the others (the body is highlighted), but I'm having real troubles making the game keep track of whether the bounding box is overlapping the blocks group. I tried several ways, for instance: But then I realised that the value of this.blocking just keeps switching with the speed of light. How do I make the dude place the blocks at the specified distance? I'm sorry if this is a dumb issue, but I really can't figure it out - I also couldn't find anything in the docs or examples about this.