Micard Posted July 22, 2015 Share Posted July 22, 2015 (edited) Hello there! Long story short, I'm just practicing and playing around making this online multiplayer game, mmorpg basically. Hold on there throwing rotten tomatoes at me No-no, it's going well, I'm pretty satisfied with the results. I have a pretty solid knowledge of C++ so it's going pretty easy with PHP, not to mention that I have some experience. Now when that is settled. I have a php-driven client with a mysql database. Okay. Stuff's working, all's great. The thing is, I want to kind of walk away from reloading pages and doing lame checkboxes for specifying hit location and all that. I want to implement some real graphics, animations, etc. The thing is I have a very little experience in JavaScript. I still have some but it's not enough to answer my questions. Here's what I want. In the middle is a "dynamic game window". I do not want to refresh the page every time I click on the character or map button, or for example I want the area to be scrollable (for the map for instance). Same for chat. And I am not sure how to do that using both php and js. I know you could do it all using just js but I don't know it as well as I know php, at least I want to believe I know it well enough for this task. If you great all-knowing masters could give me a piece of advice, I'd really appreciate that. I have some ideas, if you could just direct me. IDEAS: 1) Gamewindow - js. All other stuff - php. PHP page with a js script on it. Wouldn't it be slower than other options? How to implement this interaction between js and php scripts? There's exmaple on the drawing. So if I click on that button a js script would be called. (is it as easy as href='script.js' and I am just a dum-dum?) 2) Both gamewindow and navigation - js. I don't have a clear idea on how to do that, but it certainly has its advantages. 3) Just make the whole thing using js. The problem is I don't know js. Would it actually be better, faster, at some point easier just to learn js? Clearly, it's in many ways better than php but I don't have to learn php from the very beginning, that's the thing. 4) Other suggestions? + this is just a hobby, I dont think I have time to learn something as massive as JS. But maybe I'm wrong and it's not that bad? Maybe you could also recommend either a good piece of literature on the topic you recommend or an article. I really-really don't want to start with a "JS for dummies". I can write scripts, it's just that I can't do anything more complicated than that. Edited July 22, 2015 by Micard Quote Link to comment Share on other sites More sharing options...
scootstah Posted July 22, 2015 Share Posted July 22, 2015 If you don't want to reload the page, you need Javascript. PHP cannot do that. If you want any kind of interaction on the page such as click events, keypress events, etc, then you need Javascript. PHP cannot do that either. The way you bridge them is with AJAX. So, the Javascript controls everything on the page - animations, events, data binding, etc. On special events you will use AJAX to communicate with a PHP script, to pass data back and forth. This definitely has the potential to be very Javascript-heavy, depending on what exactly you want to do with it. Quote Link to comment Share on other sites More sharing options...
Micard Posted July 22, 2015 Author Share Posted July 22, 2015 scootsah, thanks again! Well, I know that much. I'm interested in the efficiency which is a composite of knowledge, time, and so on. My question is what would be a better option here? So just go on with a php+js bundle or rather build it all using mainly js. But here's a thing, I don't know js that well at all. Does it make a huge difference on building stuff using php+js bundle and just js? I can't just say, hey I'm going to go and learn js in a week and make a mmorpg, killer of all mmorpgs in the world. Is there really a point to make it all in js but spending a huge chunk of time learning js thoroughly rather than make it using what I already know and spent little time learn some stuff. So again, is there really a huge difference? Quote Link to comment Share on other sites More sharing options...
scootstah Posted July 22, 2015 Share Posted July 22, 2015 My question is what would be a better option here? Well, what was the role of PHP here? You said you had a "PHP driven client". Does that mean you have a separate server-side service somewhere? Quote Link to comment Share on other sites More sharing options...
Micard Posted July 22, 2015 Author Share Posted July 22, 2015 scootsah, no sir, just a fancy name for the actual gamepage. Quote Link to comment Share on other sites More sharing options...
Micard Posted July 22, 2015 Author Share Posted July 22, 2015 I was just thinking about an old project I had once. Basically it's a bundle of php+flash [AS3]. It's a pain in the butt but I think that will be the best option to be honest. it is extremely inconvenient but it works, so i might just do that since again I have a bit of experience in that. Ugh.. Why don't they make some easier and more handy stuff for this kind of purposes... well, thank you for your replies, scootsah! Much appreciate it! Quote Link to comment Share on other sites More sharing options...
Solution scootstah Posted July 22, 2015 Solution Share Posted July 22, 2015 Flash is dead, man. So PHP is your server-side, and Javascript is your client-side. You will want to rely on PHP to do sensitive things, such as validating health, movement, items, achievements, things like that. Since Javascript is client-side it can't be trusted to do these things, as people can basically modify the code on-the-fly and make it do whatever they want. Therefore, Javascript is responsible for things like calculations, animation, effects, data binding, painting, and stuff like that. Any time it needs to do something important it will use AJAX to talk to the backend (PHP). There are plenty of libraries to help with what you're doing, and there are even game engines written for these technologies. Learning these things doesn't happen overnight; don't be so quick to give up. If you're reasonably competent in other languages you should be able to pick up Javascript in a month or two... it's a fairly easy language. Quote Link to comment Share on other sites More sharing options...
Micard Posted July 22, 2015 Author Share Posted July 22, 2015 Best answers as always. Thanks you again! I'll think about it and might just start actually learning javascript. php I can put aside for a while, learn a bit of js, and then ajax. I guess that makes sense. Thanks dude! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.