HTML5 Multiplayer Browser Game - php

I am having difficulty with one part of my simple HTML5 game. I've decided to make it multiplayer. How do I go about making a change to the position of a div on my screen visible on the other users screen?
It's a two player game, with a simple move left and move right function to move divs. My first thought was to use sessions, but when I got to writing some code, I realised I knew nothing, so I headed over to CSS Tricks (couldn't find anything for my use), headed over to Dave Walsh (nothing listed) and couldn't find anything of use on Google, no matter what search term I put in.
I know this is possible with modern browsers as I've seen it done in a lot of games online now, however I'm baffled as to how it's done.
Any answer with some links would be greatly appreciated.

I think you may be interested in this article. It is an example of making online multiplayer game with NodeJS. It reveals some concepts as well as gives the actual code.

You have 2 possibilities within the simple ones:
1- refresh automatically the page of both users periodically - not very fancy
2- use ajax to query the server of a possible move from the other player
The option 2 would work well if it is a turn-by-turn game. In case of online game, I think you would need much more complex server technology like Node.js for instance.

Related

How to write a retail scheduler

Ive gotten mixed reports as to how to handle this question while reviewing the web so I thought I should ask you all. I am not sure if its possible to even do with JavaScript, PHP, and MySql, but here is what I wanna do.
Im a manager at a small retailer where I have to schedule 20 people each week. Each day we have different hours, some people are part time, others full time, etc.
Can I create a webpage that can handle this? I was thinking of making a employee database with their status as FT or PT etc but did not know what language would be best to use for a full out functioning scheduler. Also, Id like to eventually add the option to enter day off requests into the form so that the scheduler would not allow them to work on those requested days.
The scheduler would have to be automated and of course may require some user tweaking after it generates.
I AM NOT LOOKING for the code for this.... just suggestions and thoughts as to where you would start (what language, format, etc)
Like #gilly3 said, the language you use is really up to your personal preference and what knowledge you already have. Here are some overviews of the ones I think would be acceptable:
Python is probably one of the easier languages to learn, mostly because of the way it's so easy to read.
There are many great ways to learn it. I like this nettuts+ series. The series is about creating dynamic websites with Django, but before it gets to that, it goes through the python language quite thoroughly. There are also may other sites you can go to to learn about python, such as python.org and others.
Python works best with creating local applications, not online ones. However, there are ways to use python in web development.
You would most likely record peoples stats (part-time, full-time...etc.) in a file, either a python file or another file that could be parsed by python (eg. XML or JSON).
For the results, you could have it print something out to the command line/teminal or use the tkinter library. to open a window and display the schedule visually.
PHP would be your best choice if you plan to record peoples stats in a MySQL database, maybe with phpMyAdmin or something like it.
PHP would need to be hosted on a server (Apache, IIS...etc.), but that shouldn't be a problem.
That too is an extremely easy language to learn, due to the vast amount of resources available, php.net is one of the best places I think, but you may find another that you like better.
If you like HTML, CSS and JavaScript, then you could simply create a webpage and have the user open it in their browser.
If you used this option, you would write out the people's stats in a file (probably JSON if you're working with JavaScript or it could be just plain JavaScript), and simply reference it with a <script> tag or and Ajax call.
There are so may resources out there for learning these that I can't even remember my favorites.
JavaScript is probably the best if you want the user to be able to edit the schedule right in the program.
If you like HTML, CSS and JavaScript, but want a desktop application, check out TideSDK
Keep in mind that if you use PHP and MySQL, you will also have the full power of HTML, CSS and JavaScript in your hands. For that reason, I would recommend PHP. It's only drawback is needing a server, but there are many ways to get around that (XAMPP (windows/linux), WAMP (windows), MAMP (mac) and probably others, but those are the most famous.
Sorry if I've left anything out, feel free to edit.

live update a picture

Is there a way to update a picture live and dynamically? Let me explain:
There is an application that uploads a picture in a various amount of time. At the moment, my script just ask every 5seconds for a new picture on the server but thats kinda old school and not a very good solution. So my question: Is it possible to detect a new picture on the server and show it immediately on the page?
The problem with regulary requests (every 5seconds) is that if the picture is loaded after a request it takes like 10seconds to update and thats a bit too long. And to make a request every second is quite a bad idea.
You will need server side push technology (also known as Comet) to do this. The exact implementation is really dependent on the server-side programming language you are using.
Edit:
A quick search on stackoverflow on 'Comet' gives a lot of additional info (also specific to certain programming languages): https://stackoverflow.com/search?q=comet

Tricky website idea (not your average idea, and not a "will you program this for me?" request)

Again, to re-iterate: This is not a request to program anything for me. I am looking for more experienced web developers to tell me if my idea is really doable, as it involves some pretty tough issues (at least, I think so). Please, if this post is to be closed, could I at least get a little advice on where I should be posting instead first?
Imagine: You visit a website (say malonssite.com). You sign in, you get a double-paned window. Left side is chat list(think FB buddy list). Right side is a "browser".
The chat list is populated by other people who have signed into malonssite.com AND are visiting the same page as as you using the "embedded" browser.
Each user has the ability to "allow followers", at which point whatever site they visit, all their followers "follow".
Image sketch:
My abilities:
PHP
MySQL
Javascript (node.js included, but that's more serverish I guess)
I've done long polling and ajax, but this gets complicated. I am thinking something like this might be best done in flash? Or maybe an oldschool Java applet? I am just not sure.
I am pretty confident I can make this thing on my own, I am just not sure what technology to use. I usually hit stumbling blocks in each area, normally along the lines of the same origin policy. I know that JSONP can get around the SOP, however is it powerful enough to do what I want? I am not familiar enough with it.
Sockets in general (websockets, flash sockets, etc) and node.js are pretty new to me, and I think they somehow hold the answer, I am just looking for some verification.
Thanks!
As I see it, you'll just need an iframe with a JScript asking its src and sending it to the server. So basically the user will stay on your own domain, browsing other web sites in the iframe and you will have no cross-origin-request issues.
You could use ape engine for the server side, which is exactly meant for this sort of things.
It is very possible.
Simple? no. But possible.
HTML/CSS/JS will easily take care of the front end layout,that should be elementary.
Node.js is a good option, and would be best suited if you know that traffic will be heavy.
If traffic won't be heavy, i guess php is OK.
And you will also need a backend database...again, depends on how many users you think you'll have. nosql ones would suit well, although oracle just claimed they 'exponentially' improved mySQL performance.
But think about this idea carefully. The concept of allowing users to communicate if they're on the same page is neat - but they'd have to browse a site within your site....furthermore, you have to account when the user presses next/back button in the browser.
perhaps you could make a fork of firefox and implement this as a software
did you mean something like talkita
or any other solution on google search "chat with others on same page"?
some of them also allow followors (subscribers) etc..
have a look, maybe youll get an idea.
please forget about flash and java applets...
i think this is a great idea and i hope you can get it to work.
I would really use NodeJS + (Socket.IO | SockJS) for the server-side and realtime communication, all your SOP problems will be gone.
As for the client side, just take care of cross browsing the javascript and css
For data persistence, some kind of nosql implementation: mongoDB or couchDB for example

Saving peoples progress on flash games onto a site

I know there are sites out there when you log on to their account they can play swf games or otherwise flash games on the site so whenever they go to another computer they can continue their progress without restarting just by logging onto their account.
I would like to know how they do this. So I can added it to my site. I honestly have no clue where to start to learn this. Any help leading me to the right direction. Or if you can give me some code. I would appreciate it more.
Well, you'd need to create a php/mysql based API for developers. Whatever functions you want them to be able to call in flash to save data, you'll need to code in PHP. You'll also probably have to code something to access the API, in the form of Actionscript code.
It's not something really easy that you could just "add to your site", probably the biggest thing you'd have to do is get developers to integrate it to their games. There's (unfortunately!) no magic self-implementing code which a flash developer can add to their game which has a standard serverside library, for saving data.
You'll probably want to take a look at this tutorial for the basics of how to go about implementing this.

Flash MP3 player with javascript controls

While the question may seem fairly basic I seem to be at a loss to actually find anything that fits my needs, which are:
Skinnable (although not 100% required)
Controllable through javascript (start, stop, change track)
Event triggers for custom functions (on track finish mainly)
Actual documentation - rather that 'it can do this, but we wont tell you how'
I've tried many of the free and quite a few demo's of the pay for ones. Wimpy Wasp seemed to be the closest to what I need but there is an obsession there with using a custom Windows app to set it up which is impossible as the files are provided dynamically by the sites users and it doesn't look like they want you to be able to create the code yourself.
I have no problem with a pay-for solution if it addresses my needs, but free would be nice.
Thanks in advance!
JW Flash Player, to the best of my knowledge, fits that description.
As per this question I recommend http://opentape.fm/.

Categories