Open unknwnc opened 9 years ago
Yes we are on the same page as far as the game engine goes. I just added new functionality to the game library. Now we have Game.timePerTick
which gives us the time every tick just in case that is needed for something. If not we can do away with it. I also added Game.speedPerSecond(speed)
. With this you pass in the speed you want the object to move per second and it will move it that far per second. I'm interested in your idea about putting in some asset management. Let's definitely do that because that is something we could use in all games.
I think since assets was your idea you should be the one to implement it and I don't want to step on your toes as well. Also I have been itching to do a merge with your code so I can learn how that all works and it's going to be pretty awesome with your code in there.
By the way I apologize about my code I hope it wasn't too convoluted and difficult to understand. I want the code to be easy to read and self explanatory as possible.
I love programming it reminds me of the universe and Jesus. :)
I think the code is ok; It just took me a bit to figure out how the program flowed.
I synced our repositories before starting my work, so my version includes both game.timePerTick
as well as game.speedPerSecond
. You can always check my version at http://unknwnc.github.io/pong/
I know Chrome's Javascript console will let you view variables and objects the scripts is currently using, so you can verify the functionality of the code.
I looked at your latest commits, where you made the fps.update
function private again.
The only thing I want to note is that now, there are two objects named fps
- game.fps
, and a local fps
. I wanted to avoid having two objects named the same thing, so I combined them and made it all public.
Honestly, I don't find anything wrong with having it public, as it does not really add complexity. In fact, it would simplify debugging, since I can then view everything related to fps by accessing one object in the JS console.
What is your logic for making as much private as possible?
I wasn't aware you were wanting to debug using the game object. I never really thought of doing it that way before. That doesn't mean that it's wrong. I guess where I was coming from was creating a game library that only does what someone would use it for. That is the use case I was imagining for the Game.fps
and why I made it update once per second so when someone uses it they can actually read it without it updating once every 17 or so milliseconds. Also it doesn't do the math except one time per second. So it is an optimization at the same time. Hey well I have an idea that may satisfy both of our thoughts on this. Maybe you could create a Game.debug
object and it would have all the details that a developer would want to use to debug.
Sounds like a plan; sounds like something I can try to implement real quick before I get the asset manager... Currently I'm just trying to do some research about how other developers approach the assets thing.
K in the meantime I'm reading about HTML5 mobile games and how people have been doing them. There is some potentially useful meta tags for Apple devices.
As far as the asset loader I was just thinking it would be something simple like 'new Game.image(filePath)' and returns the image.
Then maybe have 'Game.load()' and that would load everything before the loop starts. Maybe you could have it built into 'Game.loop'.
Or you could do 'Game.load(img1, img2, img3, sound1)' then let it decide which is an image and which is sound.
Yeah... I know there are iOS-specific meta tags that allow the site to open as a webapp. I'll open a new issue for it; I think I might try to get it as well, since I've seen it before.
Now that I'm getting into the code some more, I just want to check with you- How are you organizing the code for this project?
In my opinion, the game engine should provide a framework for doing things general to all games, and the game code then tells the engine what that game needs specifically. The game's code shouldn't load assets by itself; it should tell the game engine what it needs, and let the engine take care of it.
So in short, I'm thinking about slowly moving some of the code from the game itself, to the engine. I think this would not only organize the code, but also make your engine a lot more powerful. What are your thoughts on this?