Search code examples
phpweb-applicationsbackenddata-exchange

php (or better choice?) for sending turn data to a simple webapp game


I have a simple 2d strategy combat game that I wrote in javascript and jQuery. The user controls 3 or 4 characters as they fight monsters (small screen cap here https://i.sstatic.net/dkkXm.jpg).

It is not realtime, it is turn based (player's turn, computers turn) and the game is designed for a phone user, mainly office workers on their morning commute. iPhone user is the main target. Game development is in early stages but currently playable. This is a web app played in browser.

My biggest issue is that if you switch applications (such as answering a phone call) and then switch back the page reloads (therefore the web app reloads) and you lose any progress you have made.

I have tested this as a web app download (using mobile safari Add To Home Screen) but the reload problem persists when switching.

I'm resisting wrapping this and delivering through the Apple app store ... instead I want to create a backend that will save the player's turns. Simple tasks such as

  • javascript function in my web app would send turn data in the form of a string
  • when the web page (and web app) reload, it retrieves the last recorded turn
  • player would need a login

I'm interested in PHP as I've had some experience with it from deconstructing and altering wordpress themes. The only other languages I know are front end (html, css, javascript, jQuery).

Can PHP cover the above tasks in a secure manner or should I be looking at learning an alternate language?

Any guidance is much appreciated and thanks in advance.


Solution

  • Yes. PHP can do what you want, as can really any other server-side language. You would just use ajax calls to send data updates to the backend server.