Sword Engine

Source: devdata.ts

// function to calculate fps
declare const globalThis : {context : CanvasRenderingContext2D}

/**
 * @function calculateFPS
 * @param {number} lasttime 
 * @param {number} currenttime 
 * @returns {number} the result of the calculation
 */
export function calculateFPS(lasttime: number, currenttime: number) {
    let fps = 1000 / (currenttime - lasttime)
    return fps
}



// function to show fps
/**
 * @function showFPS
 * @param {number} fps 
 * @param {string} color
 * draws the fps on the screen 
 */
export function showFPS(fps: number, color: string = "black") {
    globalThis.context.fillStyle = color
    globalThis.context.font = "20px Arial"
    globalThis.context.fillText(`FPS: ${fps}`, 10, 20)
}

Made By Vedik Dev - Himanshu Jangid
sword-engine Copyright © 2021 Himanshu.
Documentation generated by JSDoc 3.6.7 on Tue Nov 30 2021 23:12:55 GMT+0530 (India Standard Time) using the TSDoc template.