View previous topic :: View next topic |
Author |
Message |
removed_123456 Expert Cheater Reputation: 1
Joined: 09 Sep 2007 Posts: 241
|
Posted: Sat Apr 11, 2009 3:34 am Post subject: Javascript Clock in browser game |
|
|
kk dude uhm lets start here is a code of a javascript clock i want to speed up the clock. the game is a browser name called "Bulletstar"
Code: |
<script type="text/javascript">
var timer = null
function stop() { clearTimeout(timer) }
function start() {
var currenttime = 'April 11, 2009 11:19:26'
var servertijd = new Date(currenttime)
var time = new Date()
var hours = time.getHours()
var minutes = time.getMinutes()
minutes=((minutes < 10) ? "0" : "") + minutes
var seconds = time.getSeconds()
seconds=((seconds < 10) ? "0" : "") + seconds
var clock = hours + ":" + minutes + ":" + seconds
document.getElementById('displayklok').value = clock
timer = setTimeout("start()",1000)
}
</script>
|
Code: |
timer = setTimeout("start()",1000)
|
How can i change this to like 1second = 2 minutes? |
|
Back to top |
|
|
talkerzero Grandmaster Cheater Reputation: 1
Joined: 24 Jul 2008 Posts: 560 Location: California
|
Posted: Sat Apr 11, 2009 7:46 am Post subject: Re: Javascript Clock in browser game |
|
|
bruqaj wrote: | Code: |
timer = setTimeout("start()",1000)
|
How can i change this to like 1second = 2 minutes? |
See the 1000 in "start()",1000)? That means 1000 milliseconds = 1 second. 2 minutes = 120 seconds = 120000 milliseconds. |
|
Back to top |
|
|
NINTENDO Grandmaster Cheater Supreme Reputation: 0
Joined: 02 Nov 2007 Posts: 1371
|
Posted: Sun Apr 12, 2009 11:14 am Post subject: Re: Javascript Clock in browser game |
|
|
talker0 wrote: | bruqaj wrote: | Code: |
timer = setTimeout("start()",1000)
|
How can i change this to like 1second = 2 minutes? |
See the 1000 in "start()",1000)? That means 1000 milliseconds = 1 second. 2 minutes = 120 seconds = 120000 milliseconds. |
Also you dont use timeout when creating a timer, you use interval.
Code: | timer = setInterval("start()",1000); |
_________________
Intel over amd yes. |
|
Back to top |
|
|
removed_123456 Expert Cheater Reputation: 1
Joined: 09 Sep 2007 Posts: 241
|
Posted: Sun Apr 12, 2009 1:23 pm Post subject: Re: Javascript Clock in browser game |
|
|
is it possible to change the timeout with a javascript in the browser? |
|
Back to top |
|
|
NINTENDO Grandmaster Cheater Supreme Reputation: 0
Joined: 02 Nov 2007 Posts: 1371
|
Posted: Tue Apr 14, 2009 5:44 am Post subject: Re: Javascript Clock in browser game |
|
|
bruqaj wrote: | is it possible to change the timeout with a javascript in the browser? |
TimeOut is only executed once. Why would you wanna use TimeOut for a clock? And yes, javascripts are client sided so it would be possible. _________________
Intel over amd yes. |
|
Back to top |
|
|
shhac Expert Cheater Reputation: 0
Joined: 30 Oct 2007 Posts: 108
|
Posted: Tue Apr 14, 2009 8:58 am Post subject: Re: Javascript Clock in browser game |
|
|
ثك&am wrote: | Also you dont use timeout when creating a timer, you use interval.
Code: | timer = setInterval("start()",1000); |
|
If you used interval you'd need to move its position and change the stop function too Code: | <script type="text/javascript">
var timer = null;
function stop() { timer = window.clearInterval(timer) }
function start() {
var currenttime = 'April 11, 2009 11:19:26',
servertijd = new Date(currenttime),
time = new Date(),
hours = time.getHours(),
minutes = time.getMinutes(),
seconds = time.getSeconds();
minutes=((minutes < 10) ? "0" : "") + minutes;
seconds=((seconds < 10) ? "0" : "") + seconds;
var clock = hours + ":" + minutes + ":" + seconds;
document.getElementById('displayklok').value = clock;
}
timer = setInterval("start()",120000);
</script> |
|
|
Back to top |
|
|
hacksign23 Master Cheater Reputation: 0
Joined: 26 Nov 2006 Posts: 404
|
Posted: Thu Apr 16, 2009 12:04 am Post subject: |
|
|
look up firebug. it's for firefox. it lets you change html in real time. _________________
|
|
Back to top |
|
|
|