Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by squagmire

Having a random problem, can't quite figure out what is causing it. My game is a side-scrolling racer/platformer, and I've been trying to set it up as follows:

On the first detected player movement, a timer starts. From the time they begin moving, the player has 30 seconds to reach the end of each level, otherwise they "die".

I had this working just fine, but as soon as I wrapped everything in the director plugin (cutting and pasting most of the code from the YOSS game example main.js file), everything went haywire. Now, as long as I do not trigger the level timer, the game still works fine, but as soon as I turn it on, every input state seems to "stick", as in, once you press the Jump key, you just keep jumping until the timer runs out. It's obviously unplayable this way. I've moved the timer variable from main.js to player.js and tried various other fixes, but as I don't know what's going wrong in the first place, I don't even know what to try to fix...

1 decade ago by monkeyArms

Any errors in the console? Otherwise I would need to see some code

1 decade ago by squagmire

The portions of my code relevant to the timer in question are as follows:

From main.js:

MyGame = ig.Game.extend({
	levelTimer: new ig.Timer(30),
	goes: false,
	going: false,
        draw: function()
	{	if	(this.goes)
		{	if	(this.going)
			{       // GET levelTimer.delta()
                                // If time left, update clock display
                                // Else If no time left, switch to out-of-time animation and begin death sequence
	                }
			else
			{	this.levelTimer.reset();
				this.going = true;
			}
                }
        }
});

From player.js:

EntityPlayer = ig.Entity.extend({
	update: function() {
		// START THE LEVEL COMPLETION TIMER WHEN THE PLAYER MAKES THEIR FIRST MOVE		
		if	(	!ig.game.goes
			)
		{	if	(	this.vel.y	!=	0	||	this.vel.x	!=	0
				)
			{	ig.game.goes = true;
			}
		}
        }
});

1 decade ago by monkeyArms

that code looks fine, so the error is most likely somewhere else. Usually when an input state 'sticks' it means there was a javascript error which you should be able to debug by looking in your browser's console (available via control+shift+J in Chrome, or firebug on firefox). Any hints there?
Page 1 of 1
« first « previous next › last »