# gregkarber

Members

27

1. ## [Paid] Phaser developer to help optimize game

Hello, all! I am a writer/director living in Los Angeles. A couple years ago, I started working on a simple procedurally-generated lettuce platformer in Phaser. You play as a head of lettuce trying to climb a mountain to reunite with your tortoise love. Since then, I have repeatedly been sidetracked by other projects and am now returning to it with the hopes of releasing it in the next month or so. You can play a demo of the game at http://gregkarber.com/lettuceclimb (but please do not share). As you can see, for a game that is this simple (about ~2500 lines of code), I have persistent problems with framerate. I believe that I could discern the solution to this problem, but it would take me a lot of time and (frankly) I would rather spend that time working on other projects. I am looking to hire someone to help me optimize this code to improve the framerate. Please feel free to examine the source code in the above link and send me your rates and timeframe, or introduce yourself, or do whatever the next step is. I have never hired a programmer before, so you'll probably have more experience with how to go about this than I do. I would prefer to hire someone who enjoys the game and who could be a collaborator in the future. I have a couple mostly-completed games, and I would be interested in hiring someone for those, too, depending on how well we work together. (All of those would be paid, as well!) Thank you very much!
2. ## Quick question about debugging circle bodies

I am trying to fix a problem with a circular body falling between rectangular bodies, so I was debugging it, and I noticed that my main sprite body looks like below (I have made the sprite itself invisible so that you can see the debug body). It seems that the radius in that image shows the actual boundary of the body, not the circle. Previously, when I've done this, the radius touches the edge of the circle. So, my question is, what is going on in this picture? What do the circle and the radius represent? I know this is a pretty fundamental thing, but I'm lost, so -- going forward -- is there any place/book/text I should use to figure out basic things like this in the future? Thank you very much for any help!
3. ## Sprite Falling Through P2 Sprites

Through more testing, I've come to realize that the main lettuce sprite doesn't fall through the ground sprites, it falls between them. Is there anyway to avoid that?
4. ## Sprite Falling Through P2 Sprites

I'm working on a procedurally-generated mountain climbing game where you play as a head of lettuce. You can play the working demo here. I have a bunch of work to do regarding streamlining the code and the gameplay, but I can't seem to resolve a problem. When the head of lettuce falls from a substantial height, he falls through the black rectangle sprites I use for the ground. This means it falls through platforms. In addition, since the ground is only one physics-enabled sprite deep, if he falls through that, he falls through the world and the game is over. I feel like perhaps tweaking the Contact Materials might help solve this problem, but I can't find sufficient docs to really understand. Can anybody help me with this? I have copy-pasted some of the relevant passages of code below, but the full text is available as an attached text file. (You can also view it here.) Any help (even just directions to pursue) would be enormously helpful! Thank you very much. this.lettuce.body.setMaterial(this.spriteMaterial); this.spriteMaterial = game.physics.p2.createMaterial('spriteMaterial', this.lettuce.body); this.worldMaterial = game.physics.p2.createMaterial('worldMaterial'); this.platformMaterial = game.physics.p2.createMaterial('platformMaterial'); this.smoothMaterial = game.physics.p2.createMaterial('smoothMaterial'); this.smootherMaterial = game.physics.p2.createMaterial('smootherMaterial'); this.lettuce.body.setMaterial(this.spriteMaterial); game.physics.p2.setWorldMaterial(this.worldMaterial, true, true, true, true); var contactMaterial = game.physics.p2.createContactMaterial(this.spriteMaterial, this.platformMaterial); contactMaterial.friction = 7; contactMaterial.restitution = .1; contactMaterial.stiffness = 1e7; contactMaterial.relaxation = 7; contactMaterial.frictionStiffness = 1e7; contactMaterial.frictionRelaxation = 3; contactMaterial.surfaceVelocity = 0; var contactMaterial2 = game.physics.p2.createContactMaterial(this.smoothMaterial, this.platformMaterial); contactMaterial2.friction = 0; contactMaterial2.restitution = 0; contactMaterial2.stiffness = 1e7; contactMaterial2.relaxation = 10; contactMaterial2.frictionStiffness = 1e7; contactMaterial2.frictionRelaxation = 3; contactMaterial2.surfaceVelocity = 0; var contactMaterial3 = game.physics.p2.createContactMaterial(this.smootherMaterial, this.platformMaterial); contactMaterial3.friction = 0; contactMaterial3.restitution = 0; contactMaterial3.stiffness = 0; contactMaterial3.relaxation = 0; contactMaterial3.frictionStiffness = 0; contactMaterial3.frictionRelaxation = 0; contactMaterial3.surfaceVelocity = 0; And the update function, among other things, calls this: friction_manager: function() { // so that ceilings are smooth if (this.checkIfCeiling()) { this.lettuce.body.setMaterial(this.smoothMaterial); } else this.lettuce.body.setMaterial(this.spriteMaterial); }, And this is the function that actually places and sets the platforms: place_block: function(x,y, bodiful) { this.visiblesprites.push((Math.round(x) + ',' + Math.round(y))); x = x*TILE; y = y*TILE; var ground = this.platforms.getFirstDead(); ground.reset(x,y); if (bodiful) { game.physics.p2.enable(ground); ground.body.static = true; ground.body.setMaterial(this.platformMaterial); } else { ground.anchor.setTo(0.5, 0.5); } }, I also wrote this to limit the speed of the lettuce falling, in the hopes that that would fix it, but it didn't, really: if (this.lettuce.body.velocity.y > 2000) this.lettuce.body.velocity.y = 2000; Anyway, if anyone can offer any help, that would be hugely appreciated! main2.txt
5. ## Game lags over time: help with efficiency!

Oh man, the emitter thing. I'm sure that's it. Thank you very much! These were all great ideas, and thank you so much for the kind comments on the game itself. That's wonderful.

7. ## My game works, but I want it to work faster

I think I implemented your suggestion! It still could run a little faster, though... function circleCreate() { var circleSize = Math.random() * 50 + 60; asteroidCircle = game.add.bitmapData(100, 100, "asteroidBit", true); asteroidCircle.circle(50, 50, 50, "#FFFFFF") asteroidGroup = game.add.group(); asteroidGroup.createMultiple(100, asteroidCircle); }function asteroids(x, y) { //console.log("asteroid at " + x + "," + y); var circleSize = Math.random() * .5 + .5; asteroid = asteroidGroup.getFirstDead(); asteroid.reset(x,y); asteroid.anchor.x = .5; asteroid.anchor.y = .5; asteroid.scale.x = circleSize; asteroid.scale.y = circleSize; game.physics.p2.enable(asteroid, false); asteroid.body.clearShapes(); asteroid.body.addCircle(circleSize * 50); asteroid.body.setCollisionGroup(asteroidCollisionGroup); asteroid.body.collides([shipCollisionGroup, asteroidCollisionGroup]); asteroid.body.debug = true; asteroid.body.velocity.x = Math.random() * 50 - 25; asteroid.body.velocity.y = Math.random() * 50 - 25; this.spacerocks.add(asteroid); }
8. ## My game works, but I want it to work faster

And will I need to apply the P2 bodies each time I create one? I'm sorry to keep posting questions.
9. ## My game works, but I want it to work faster

Maybe it would be easier if I just created a circle graphic rather than drawing them with Graphics. I assumed that drawing them would be faster than displaying a .png, but maybe that's wrong.
10. ## My game works, but I want it to work faster

I'm pretty sure I know how to do that for sprites with images: asteroidGroup = game.add.group();asteroidGroup.createMultiple(200, "asteroid");But how do I do it with graphics? Do I need to use Bitmap Data? I haven't used that at all, but I'm studying up on it now. If anybody knows how to do this, it would be an enormous help for me. Thank you so much!

12. ## Can't figure out collide with a .CSV tilemap

My problem was the use of "scale" on the tilemap layer. I should have used setScale.

14. ## Efficient way to generate a random mountain to climb

I couldn't get them to without killing them. I would love for someone to help with that. However, you just helped me figure out a huge thing. I have been loading individual square sprites, but almost 99% of them are columns. So I only loaded physics bodies on the top ones. However, I could massively reduce the number of sprites by making each sprite a column. So thanks!
15. ## P2 Sprites not colliding when .outOfBoundsKill = true;

I tried writing a function that deletes sprites when they exit the camera viewpoint, thinking that outOfBoundsKill was where the problem was, but it still occurs. It seems like sprites summoned using .reset that have already been created and killed don't pull their bodies with them, and even if you enable the body again, nothing happens. **EDIT:** Based on this theory, I fixed it by adding sprite.body.destroy() before I killed each sprite. Is there some way to do that with sprite.outOfBoundsKill = true, but I couldn't figure it out.
16. ## Efficient way to generate a random mountain to climb

Thank you very much! I'm working on an implementation with sprites that are created on the edges and have .outOfBoundsKill = true. However, sprites that are created with this function don't seem to hold onto the physics bodies I'm trying to give them. Can anyone help? I posted a new thread about it here. I have become so frustrated with my own ignorance and inability. Coding's hard, y'all.

19. ## Open Window on Home Screen

I have been working on a casual game and am trying to make it possible for people to tweet and/or Facebook their score. I have accomplished this through the use of window.open and the intent link for Twitter and the sharer link for Facebook. This works absolutely fine on browsers, even on mobile. However, I want to encourage people to add the page to their iOS home screen, and if they do this, neither of these links work (because it's not in a browser, I assume). Is there an alternative way to do this? Or a way for an iOS device to trigger the Twitter and Facebook apps? Thank you very much!
20. ## [phaser] the tortoise trails: a zen game

I am not a coder (by any means), but I managed to cobble together this game based on a tortoise character in these daily koans that I write. You can play the game at koanoftheday.com/trails.
21. ## Help with First HTML5 Game

Okay, more thoroughly useless investigation: I have found that the bottom of your playfield seems to be at about 150, that is, when the green dot is at the bottom of the square, the y location seems to be 150. Not sure if this helps!
22. ## Help with First HTML5 Game

I just tried debugging it, and found that "head.x" did equal 255 when it said that the snake was dead, despite it not looking -- visually -- as if the sneak were at the edge. I also noticed that the snake can go well below the visual boundary before it says that the snake is dead. I am a rank amateur, so this is all I can say right now.
23. ## Audio Static after Many Plays of a Sound Effect [FIXED]

I just re-tested it in Google Chrome, and now it's happening around the 950 step mark (or after about 300 sound-effect cues). I think the increase might have happened since I converted the sound files to lower-fidelity versions. And sometimes now it doesn't get distorted, it just decides to stop playing all-together. Once this happens, no sound effects work. I see some people include end-point parameters in their sound cues. Perhaps doing that will help? I honestly have no experience in audio programming and so do not even know where to begin. Is overlapping causing this kind of corruption? Thank you very much for testing it out! EDIT: Just saw your suggestion! Will do.
24. ## Audio Static after Many Plays of a Sound Effect [FIXED]

Oh, wow. I thought I'd tried it on a few people's computers in a few different browsers. May I ask what browser you're using?
25. ## Audio Static after Many Plays of a Sound Effect [FIXED]

Alright, I guess (from lack of response) that this is either an unsolvable problem or an incredibly easy one. Or my topic was really poorly phrased.