- Edited
- Android
Touhou ripoff thing
I need help with score calculator, how do I make it increase a millisecond?
Touhou ripoff thing
I need help with score calculator, how do I make it increase a millisecond?
miztis
yeah but then you can just switch screens and then switch back and get a bajillion score
ackvonhuelio Isn't that the entire point? Time-based score?
Ravage
if you want a time based score, you need a time based game
the touhou ripoff is frame based, not time based
Ravage actually regardless of the browser setInterval is actually kind of fucked as in it won't execute properly if you start giving it lower values which means it's inconsistent making your own setTimeout loop is more practical if your aiming for accuracy if it's just a simple loop then what you said is fine just keep in mind that it will not always be accurate I know from making projects that have been time dependent before so do heed my warning
here's a demo on how that can be done
var Loop = (function() {
function Loop(ms, cb) {
this.ms = ms;
this.cb = cb;
this.main();
}
Loop.prototype.main = function() {
var self = this;
this.id = setTimeout(function() {
self.cb();
self.main();
}, this.ms);
}
Loop.prototype.stop = function() {
clearInterval(this.id);
}
return Loop;
})();
something like this will do though it's only bare bones atm you can add more to it though
Varrience
you can actually get stuff synced to real-time really well if you base all movement and stuff off of millis(),
see the ack wip spinoff of mitzis' game for a demo of a bossfight synced to sound/real-time
https://studio.code.org/projects/gamelab/LpoXWdqlw6D7Ir-h5JsCzsQOcGOxD6gIUjevvtEEdrQ
ackvonhuelio well yea but i imagine they wanted a seperate loop outside of draw that's the point i intend to make that using the Interval as an accurate loop at low speeds will likely fail but using time calculation works within the draw loop too just saying