<commit_before># Main RottenFlesh entry point
# Everything happens here, beware of watcha doin here mate
#
# @example How to create a new game
#	game = new Rotten.Game({ render: Rotten.Render.CANVAS });
#
class Rotten.Game


	# Constructs a new RottenFlesh game
	#
	# @param {Object} options Game options
	# @option options {String} render Render (default: Rotten.Render.CANVAS)
	# @option options {String} background Background color (default: #000)
	# @option options {Object} canvas You can use a custom canvas to draw in
	#
	constructor: (options) ->

		# Represents all the scenes (or game states) of the game
		@scenes = {}

		# The current played scene
		@currentScene = null

		# The previous used scene (in case you called switchScene)
		@lastScene = null

		# The game background color
		@backgroundColor = options and options.background or "#000"

		# Current game fps
		@fps = 0

		# Last game loop
		@lastLoop = null

		# Custom canvas
		@render = new Rotten.Render options.render||Rotten.Render.CANVAS options.canvas

		# Game assets manager
		@assetManager = new Rotten.AssetLoader()


	# Add a scene to your game (a config screen, a start screen, ...)
	# and set it as default if default scene is null
	#
	# @param {String} name The name of your scene (to retrieve it later)
	# @param {Rotten.Scene} scene Your scene
	#
	addScene: (name, scene) ->
		if scene.update is undefined then console.warn "[Rotten.Game.addScene] You should add an .update() method in your scene to update objects"
		if scene.draw is undefined then console.warn "[Rotten.Game.addScene] You should add a .draw() method in your scene to update objects"

		@scenes[name] = scene
		if @currentScene is null then @currentScene = @scenes[name]


	# Start your game with a scene name. If no scene name is provided,
	start: (sceneName) ->
		if sceneName is not null then @currentScene = @scenes[name]
		if @currentScene is null then return


	# Main game loop : Everything is done here
	requestAnimation: () ->


		#if(that.currentGameState.isStarted){
		#	that.currentGameState.update();

		#	//Clearing
		#	FF.Render.clearRect(0,0,FF.Render.getWidth(),FF.Render.getHeight());

		#	//Setting the background color
		#	FF.Render.setBackgroundColor(that.backgroundColor);

		#	that.currentGameState.draw();
		#}

		if @lastLoop is null
			@lastLoop = new Date().getTime()
			requestAnimationFrame @requestAnimation
			return

		delta = (new Date().getTime() - @lastLoop) / 1000
		@lastLoop = new Date().getTime()
		@fps = (1 / delta).toFixed 1

		console.log fps

		requestAnimationFrame @requestAnimation
<commit_msg>update game constructor options to fit renders<commit_after># Main RottenFlesh entry point
# Everything happens here, beware of watcha doin here mate
#
# @example How to create a new game
#	game = new Rotten.Game({ render: Rotten.Render.CANVAS });
#
class Rotten.Game


	# Constructs a new RottenFlesh game
	#
	# @param {Object} options Game options
	# @option options {String} render Render (default: Rotten.Render.CANVAS)
	# @option options {String} background Background color (default: #000)
	# @option options {Object} canvas You can use a custom canvas to draw in
	#
	constructor: (options) ->

		# Represents all the scenes (or game states) of the game
		@scenes = {}

		# The current played scene
		@currentScene = null

		# The previous used scene (in case you called switchScene)
		@lastScene = null

		# The game background color
		@backgroundColor = if options and options.background then options.background else "#000"

		# Current game fps
		@fps = 0

		# Last game loop
		@lastLoop = null

		# Custom canvas
		@render = if options and options.render is Rotten.Engine.WEBGL2D then Rotten.Renders.WebGL2D else Rotten.Renders.Canvas
		@render = new @render if options and options.canvas then options.canvas else null

		# Game assets manager
		@assetManager = new Rotten.AssetLoader()


	# Add a scene to your game (a config screen, a start screen, ...)
	# and set it as default if default scene is null
	#
	# @param {String} name The name of your scene (to retrieve it later)
	# @param {Rotten.Scene} scene Your scene
	#
	addScene: (name, scene) ->
		if scene.update is undefined then console.warn "[Rotten.Game.addScene] You should add an .update() method in your scene to update objects"
		if scene.draw is undefined then console.warn "[Rotten.Game.addScene] You should add a .draw() method in your scene to draw objects"

		@scenes[name] = scene
		if @currentScene is null then @currentScene = @scenes[name]


	# Start your game with a scene name. If no scene name is provided,
	start: (sceneName) ->
		if sceneName is not null then @currentScene = @scenes[name]
		if @currentScene is null then return

		requestAnimation()


	# Main game loop : Everything is done here
	requestAnimation: () ->


		#if(that.currentGameState.isStarted){
		#	that.currentGameState.update();

		#	//Clearing
		#	FF.Render.clearRect(0,0,FF.Render.getWidth(),FF.Render.getHeight());

		#	//Setting the background color
		#	FF.Render.setBackgroundColor(that.backgroundColor);

		#	that.currentGameState.draw();
		#}

		if @lastLoop is null
			@lastLoop = new Date().getTime()
			requestAnimationFrame @requestAnimation
			return

		delta = (new Date().getTime() - @lastLoop) / 1000
		@lastLoop = new Date().getTime()
		@fps = (1 / delta).toFixed 1

		console.log fps

		requestAnimationFrame @requestAnimation

{'fraction_non_alphanumeric': 0.09959274342835987, 'fraction_numerical': 0.005923731951129212, 'mean_word_length': 3.837063563115488, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '194694', 'n_tokens_mistral': 1779, 'n_tokens_neox': 1618, 'n_words': 609}