I am making a text based browser game.
and I was hoping to the whole game in PHP MySQL then go back and add JavaScript and Ajax.
But I can't seem to find a way to targeting system is.
targeting system needs to work like this, the player first clicks on target be it Monster another player,and that target status is displayed on the screen
in a text box. Then the player will click action button, it casts a spell or to do in fact, and then that action is applied to the target.
I'm having a real hard time doing this without JavaScript is it even possible to do it in alone?
Any ideas of great appreciated
cheers
targeting in php
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: targeting in php
You will have to use Javascript, because what you are describing is client-side functionality. You will probably find it pretty basic in Javascript (preferably jQuery). You will just set up click events on the objects you want to click on (or more than likely, make one generic click event for the whole class of objects that you can click and then determine which item was clicked within the callback, maybe based on the item name), then in the callback function, set the target to the name of the object clicked, then set AJAX calls on the action buttons (like spells, attacks, etc.) that will send along the target. Then just be sure to double-check in the AJAX-called PHP function that the object clicked makes sense, since client-side code can be spoofed any way the user likes (such as making sure the target is actually on the same screen as the player sending the request).
The indelible lord of tl;dr