Pergunta

OK, here's what I'm doing. I'm planning a browser game, but I wanted a realtime aspect to it. Basically, the player can roam around a city map and encounter random NPCs and enemies. What I want to know is, is there a way to have a script running constantly, separately from the user's browsing, that would control things like NPC movement (move them once every second or so, etc.)?

So the user would be playing the game (on a certain area of the map) and there would be something analogous to a game client (like WoW) controlling the NPCs, etc, but controlled on the server side. (This is shared hosting, btw. If I need dedicated or whatever, that's an option as well.) I really don't want to have the user's browser send a request every second asking for the locations of all NPCs all across the entire world. I'm just trying to figure out an alternate way to go about doing this, while still having a realtime aspect to it.

If it's just not possible, then that's fine, I have alternate non-realtime plans for gameplay. If anything above is unclear, I will try to elaborate as much as possible.

Foi útil?

Solução

You probably should google for this: 'php daemon howto'

Daemons are programs which reside in memory and could be controlled with signals.

The sad thing is that php is very poor to process asynchronous events, like send some data and wait for an answer while continue operating.

I face this problem when wrote sms-daemon -- the client put sms to queue, daemon sends and waiting for confirmation. But while waiting it should continue to receive another messages from queue.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top