• Content count

  • Joined

  • Last visited

About Cudabear

  • Rank
    Advanced Member

Recent Profile Visitors

534 profile views
  1. It lists an example under the documentation here.
  2. Thanks matt!
  3. Awesome! Good work on your game too It would be a shame for you not to post it just because you missed the Compo deadline!
  4. @MikeW You can still submit for the Jam, for about 8 more hours.
  5. Yeah! We managed to get just about everything we wanted to get into our game: It's mostly content heavy, involved a lot of scripting and building systems to allow for scripting, and was an interesting experience. We created 10 unique rooms, 3 unique enemy types, a mini boss, a boss (sort of), and 2 endings. It should take less than 10 minutes to beat. You can find the source here as well:
  6. I'd assume it would be fine, provided there's no naming conflicts. Depending what you want to do, you could probably just instantiate a phaser game object inside a controller or directive. If you need this to persist beyond the scope of that controller/directive, maybe you could potentially put it in a service. You could even put it in a RunBlock, and it would be fine. I guess it all depends on what you're trying to do with Angular on top of Phaser.
  7. Here's a good way to do it using two rectangles: You could just use the bounds of the sprite instead of one of the rectangles, then check if intersects exists and has height/width to determine if a part of the sprite is within the target rectangle. Furthermore, you could check to see if intersects has the same bounds as your sprite if you want to see if the sprite is all the way inside the rectangle.
  8. What I typically do is have a game state that corresponds to your main gameplay loop, IE when your user is actually playing the game. Then, I feed this gameplay state a data object that represents the level that the player will be playing on, with information such as where the character spawns, where the goal object(s) spawn, where enemies spawn, gameplay triggers, ect. The main loop can parse out this data and actually calculate the logic on the fly. This way, you create degrees of separation between your gameplay logic and the data that represents your "worlds" and it'll be much easier to add more worlds or change mechanics later. Then, when it comes time to switch to a new world, you just have to restart the state again with a new "world" data object.
  9. Long time Phaser Ludum-Darer here! Going to be my 8th time entering a Phaser game, crazy! Good luck on your game. We'll have to use this thread later to share our creations.
  10. I personally ran into this problem when I first started learning Phaser and I've helped dozens of people through it as well over the years, so it leads me to think there's a gap in the documentation there. However, the examples do clearly show you need to use velocity, so who knows. I think it's just an easy hole to fall in when first using Phaser, when you start with moving positionally and then try to throw in collision you naturally think your positional moving logic will just work. If more tutorials skipped positional moving and just did stuff with velocity/tweens it would probably be less of an issue, but you never know.
  11. A common mistake! Your problem is here: if (player.cursor.left.isDown) { player.image.position.x -= 10; } else if (player.cursor.right.isDown) { player.image.position.x += 10; } else if (player.cursor.up.isDown) { player.image.position.y -= 10; } else if (player.cursor.down.isDown) { player.image.position.y += 10; } } When working with physics, you can't directly move sprites around with their positional values and expect them to collide with other sprites. The reason for this is physics calculations require velocity, and if you directly move things around the velocity of these objects is 0, so no calculation can be done. Change your code to something like this if (player.cursor.left.isDown) { player.image.body.velocity.x = 10; } else if (player.cursor.right.isDown) { player.image.body.velocity.x = 10; } else { player.image.body.velocity.x = 0; } if (player.cursor.up.isDown) { player.image.body.velocity.y = 10; } else if (player.cursor.down.isDown) { player.image.body.velocity.y = 10; } else { player.image.body.velocity.y = 0; } And the collisions should work. Also, position calculated via velocity is weird and might not be the same as moving sprites directly, so you might need to fidgit with the number 10 to something that feels better for your game. Good luck!
  12. I'm not entirely sure you can't, but I'd really suspect that you can't. Those parameters that you pass in (row, column) essentially get directly put as indexes of the double-indexed array that represents the map. Arrays by definition can't have things at negative indices, so there's your answer. The requirement of having a map that grows in all directions is a tough one. You could make the leftmost column 0 and the topmost row 0, and then when the player moves outside of those bounds, you could prepend the new tiles onto the front of the row and column arrays, so you maintain that the topmost and leftmost tiles are index 0. But that might be computationally expensive. Also, because tilemaps must be squares or rectangles, you might have a massive tilemap that represents what's essentially long strips of tiles when players wander off in one direction. In the end, you're going to run in to scalability problems where your server is sending massive amounts of JSON data to your clients to update them on the state of the world. How games that have "infinitely expanding worlds" usually get around this is to have "chunks", or similarly smaller-sized pieces that fit together to look seamless. What I would do here is make your chunks individual tilemaps (of small sets of tiles, maybe 50x50) that are indexed on the server as a double-indexed array. Have the client then request the required number of chunks around them from the server, and load them in to make the game look seamless (using offsets on the individual maps to align them in the world, even though they're technically all have their own 0 indexes in the top left). When the client requests a chunk from the server that hasn't been generated yet, have the server generate a new tilemap for that chunk and send it out, then cache it for other clients to see when they visit the same area. In theory, your server will then need to store this double-indexed array of tilemap JSON files in some kind of database. You'll also need to do some experimentation with how the JSON from tiled looks and replicate it if you want the server to generate it. I hope this helps. Let me know if you have any questions.
  13. Bingo, groups are the key here. Glad you figured it out.
  14. I find this code really confusing, what are you trying to accomplish here? That said, the problem is your "grid" object is basically just a double-indexed array of Phaser sprite objects. If you set a property "x" on the grid object, you are really just adding it to that array. If you want to update the X coordinate of your grid, you'll have to loop through it and update the X coordinate of every single sprite within the double-indexed array. Sort of like how you're creating it.
  15. Yup, you can use multiple physics systems. Just make sure to enable all relevant sprites in each system (no way to collide bodies with AABB system with bodies in Box2D system, or vice versa).