zachio / pong

Pong - Forever Alone Addition. This is an HTML5 game that is like pong except single player.
0 stars 0 forks source link

game engine revisions #5

Closed unknwnc closed 9 years ago

unknwnc commented 9 years ago

I noticed your game library uses setInterval for the main loop. I changed it to use requestAnimationFrame, an HTML5 feature that syncs javascript with screen refreshes. This theoretically allows the game to use less CPU, and provides a more stable frame rate (It's now steady around 30FPS for me).

More about requestAnimationFrame: https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame

unknwnc commented 9 years ago

I've also made some modifications to the game engine. I did my best to streamline some of the code- got rid of some unnecessary functions, removed some duplicated code. I made some edits to the fps object as well. Everything related to fps is now stored in the fps object, and I made minor optimizations...

zachio commented 9 years ago

For some reason it doesn't allow me to do the merge pull request. It says I must use the command line to resolve conflicts before continuing.

zachio commented 9 years ago

I can copy and paste this.loop function so it will use animation request

unknwnc commented 9 years ago

You can compare the files to see the changes I made... I made several changes through the game engine, and a small change in main.js. The change in main.js has to do with how I changed the game.fps object, so game.fps is an object and the current framerate is stored in game.fps.current.

unknwnc commented 9 years ago

I believe it can't automatically merge because we both modified the same file, so GitHub doesn't know which version to keep. Are you familiar with using GitHub on the command line?

unknwnc commented 9 years ago

Here is an article about resolving merge conflicts: https://help.github.com/articles/resolving-a-merge-conflict-from-the-command-line/

unknwnc commented 9 years ago

I'll wait until you can resolve my pull request before doing anything; Then we can both make sure we're using the same code, and we're working on different things.

zachio commented 9 years ago

Try this. Pull down the latest version of the code and reconcile your code with mine then resubmit it. Do you think that will fix it.

unknwnc commented 9 years ago

I can give it a shot. Try reading that article on resolving conflicts, though, in case this happens again...

zachio commented 9 years ago

This article made more sense to me. http://blog.michelemattioni.me/2013/01/29/what-do-i-do-when-my-pull-request-does-not-merge-automatically-in-master/

unknwnc commented 9 years ago

If it makes sense, can you pull it?

zachio commented 9 years ago

It says I should create another branch to test the code.

unknwnc commented 9 years ago

Yeah, I realized that too... Looks like neither of us should be developing on gh-pages.

unknwnc commented 9 years ago

I looked closely at your commits, and I think I found the place where it's having an issue... It looks like you copy my game.loop function, and I remove a comment, it will be able to merge automatically.

zachio commented 9 years ago

I created a branch called feature. Not sure how I add your code or reconcile it.

zachio commented 9 years ago

I added the animation request frame code to the main branch cause I couldn't figure out how to merge it. I guess our files are too different to merge. The difference is probably found in fps. You made everything that had to do with fps public by adding this to it. And I had the stuff that didn't need to be public private.

zachio commented 9 years ago

Here is a good video on pull requests

https://www.youtube.com/watch?v=FQsBmnZvBdc

zachio commented 9 years ago

You also don't have the fps updating the display every second. That makes it easier to read the fps display.