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 Joncom

I noticed there's a FPS displaying in the debug panel...

I was just curious if there was a function to bring this into my game?

1 decade ago by Graphikos

Have to dig way back for that.. empika's debug plugin should help you out.

https://github.com/empika/ImpactJS-Plugins/blob/master/debug_display.js

1 decade ago by Joncom

Thanks!

1 decade ago by empika

Thanks Graphikos, glad my plugin can still be of some use :)

Instructions of how to use the plugin are here Joncom https://github.com/empika/ImpactJS-Plugins/blob/master/Readme.markdown

1 decade ago by Joncom

Quote from empika
Thanks Graphikos, glad my plugin can still be of some use :)

Instructions of how to use the plugin are here Joncom https://github.com/empika/ImpactJS-Plugins/blob/master/Readme.markdown

Cheers man, I love it! I was just curious though... in your readme, under "Debug Display", in the draw function, what is the following line line used for:

var x = ig.system.width/2, y = ig.system.height/2;

1 decade ago by empika

var x = ig.system.width/2, y = ig.system.height/2;

This gets the mid-point of the game screen, looks like it has no actual affect on the debug plugin though ;)

1 decade ago by Joncom

Quote from empika
var x = ig.system.width/2, y = ig.system.height/2;

This gets the mid-point of the game screen, looks like it has no actual affect on the debug plugin though ;)

Haha. K :)

1 decade ago by paulh

Having some problems getting this to display :-(

in this section:


// this.debugDisplay.draw(info, display_fps, display_average, average_time, interval_count)
                // info, array:                         this will display each array element on a new line
                // display_fps, bool:               pass in true or false to either show the FPS or not. defaults to true
                // display_average, bool:   pass in true or false to either show the average FPS over a period of time or not. 
                //                                                  defaults to false
                // average_time, integer:   amount of of time between samples. defaults to 10000 (10 seconds)
                // interval_count, integer: amount of samples to take over time. defaults to 500
                this.debugDisplay.draw(["my", "info", "here"], true, true, 10000, 100);


Lets say i just wanted to display fps, how would i do that (ive tried a number of things) with various errors like info is not defined to Cannot call method 'draw' of undefined ..

EDIT:


this.debugDisplay.draw(["my", "info", "here"], true, true, 10000, 100);


what goes in my, info, here and if i remove that array (and info from the draw) why is FPS still not defined :-(

1 decade ago by paulh

tried in main too,


ig.module( 
	'game.states.free' 
)
.requires(
	'impact.game',
	'game.plugins.debugdisplay'
	
)
.defines(function(){

		Free = ig.Game.extend({
		font: new ig.Font( 'media/04b03.font.png' ),
		Backgroundimg: new ig.Image( 'media/game_backdrop_1.png' ),
		gravity: 300, // All entities are affected by this
		clearColor:null, //'rgba(200,200,200,1)',
	
	init: function() {
		
		//debug display
		this.DebugDisplay = new DebugDisplay( this.font )
		//end debug display
		
		ig.game.maintimer = new ig.Timer(5);
		//console.log("height",ig.system.height,"width",ig.system.width);


	},
    
	update: function(){

		 if(ig.game.maintimer.delta() >= 0){ //when timer hits zero
			ig.system.setGame(GameOver); //change the game state
			console.log ("end",ig.game.maintimer.delta()); //show the end time
			alerted(); //provs that timers in setgames are avialbel elsewere.
			
			}
		this.parent();
			  },
		  
draw: function() {  
		  	
		this.Backgroundimg.draw( 0, 0 );
		this.parent();
		
		//debug display
		var x = ig.system.width/2, y = ig.system.height/2;
		
                 //this.debugDisplay.draw( info, display_fps, display_average, average_time, interval_count);
                // info, array:                         this will display each array element on a new line
                // display_fps, bool:               pass in true or false to either show the FPS or not. defaults to true
                // display_average, bool:   pass in true or false to either show the average FPS over a period of time or not. 
                                                                 // defaults to false
                // average_time, integer:   amount of of time between samples. defaults to 10000 (10 seconds)
                // interval_count, integer: amount of samples to take over time. defaults to 500
                this.debugDisplay.draw(["my", "info", "here"], true, true, 10000, 100);
                
                //
		},
	    	
	});
});
	

1 decade ago by paulh

http://impactjs.com/forums/help/display-frame-rate

draw: function() {
this.parent();

// display frame rate
var now = (new Date()).getTime();
var delta = now - this.framerateNow;
this.framerateNow = (new Date()).getTime();
this.font.draw( Math.floor(1000/(delta)) + 'fps', 2, 2 );
}
Page 1 of 1
« first « previous next › last »