With regards to PHP
Is it possible to construct a battle system that causes player and environment to act on a timer?
For example, player is instructed to attack every 3 seconds and keeps attacking until enemy is dead.
Each action is updated on some kind of dialogue screen and displaying what is done.
Is this possible with PHP? or is javascript the solution?
Does anyone know how to do this?
Real time attack?
Re: Real time attack?
Do you mean sort of like an autoattack? like player swing enemy swing player swing enemy swing till one is dead? If so I'm working on one right now. I have been getting some help with a bug I'm having with it in the coding section. If you're looking for more of a timed feature I'm probably not the best to help you.
Re: Real time attack?
From my knowledge it kind of is. But it's not so much running in real time - what you'd have is when the page refreshes the code looks at the last time stamp and thinks 'Hey, it's been nine seconds so far, and each attack is done after three seconds, so I'll run three combat rounds quickly right now!'. It's also possible to make the page refresh after X number of seconds, to help show the action 'as it happens'. Currently I'm using a rest code which is kinda similar, as in the guy cannot battle further until X number of seconds have passed, then it changes a value or two - same principle.
What your talking about so far doesn't strictly need real time passing during it.
What your talking about so far doesn't strictly need real time passing during it.
Fight Cycle : My latest Browser game WIP
Driftwurld : My Browser Game WIP
Philosopher Gamer : My Blog
Driftwurld : My Browser Game WIP
Philosopher Gamer : My Blog
- PaxBritannia
- Posts: 680
- Joined: Sun Apr 18, 2010 1:54 pm
Re: Real time attack?
From what I understand, you are asking if you can have:
A page with a sort of animation thing in which the player is set to attack every 3 seconds until the enemy is dead.
The short answer is no you cannot do it in php, you would have to use javascript or another client-side script.
Pax.
A page with a sort of animation thing in which the player is set to attack every 3 seconds until the enemy is dead.
The short answer is no you cannot do it in php, you would have to use javascript or another client-side script.
Pax.
Re: Real time attack?
You could actually do it with PHP. Simply put a timed refresh header in your PHP battle script. And the have the battle script a frame of some sort. However if I were to do it I'd use JavaScript to make the reloading go seamless with Ajax.
Fighting for peace is declaring war on war. If you want peace be peaceful.
Re: Real time attack?
Yes, you are all on the right track.
Timer will count from 0 to 300 (the count will speed through this instead of actually 300 seconds)
A users character is set to attack every 3rd count (3, 6, 9, 12, 15, all the way to 300 if necessary), enemy is set to attack every 12 count (12, 24, 36, etc.)
Each class has its own 'time' to attack.
So I understand javascript may be the solution, I was just wondering if PHP was capable of this.
Thanks for the comments thus far.
Timer will count from 0 to 300 (the count will speed through this instead of actually 300 seconds)
A users character is set to attack every 3rd count (3, 6, 9, 12, 15, all the way to 300 if necessary), enemy is set to attack every 12 count (12, 24, 36, etc.)
Each class has its own 'time' to attack.
So I understand javascript may be the solution, I was just wondering if PHP was capable of this.
Thanks for the comments thus far.
Re: Real time attack?
I'd say php is capable of this, yeah. I mean, if your capable of programming this in another language, you can do it in PHP.
The only thing is the data only changes on a query from a browser. But you have the html refresh command and php time() commands to mess around with for various effects.
The only thing is the data only changes on a query from a browser. But you have the html refresh command and php time() commands to mess around with for various effects.
Fight Cycle : My latest Browser game WIP
Driftwurld : My Browser Game WIP
Philosopher Gamer : My Blog
Driftwurld : My Browser Game WIP
Philosopher Gamer : My Blog
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: Real time attack?
This pretty much sums it up. You can do it in PHP, but to make it more elegant and to create a better user experience, you should use AJAX.Chris wrote:You could actually do it with PHP. Simply put a timed refresh header in your PHP battle script. And the have the battle script a frame of some sort. However if I were to do it I'd use JavaScript to make the reloading go seamless with Ajax.
The indelible lord of tl;dr
Re: Real time attack?
Excellent feedback.
I'll look into developing this battle system in javascript. I WILL be able to convert that to AJAX though, correct?
I'll look into developing this battle system in javascript. I WILL be able to convert that to AJAX though, correct?
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Real time attack?
no conversion needed, Ajax is all JS functions, so you will just pass your current data to those functions