<commit_before>
CANVAS_WIDTH = 600
CANVAS_PLAY_WIDTH = 400
CANVAS_HEIGHT = 400
CANVAS_HALF_WIDTH = CANVAS_WIDTH/2
CANVAS_HALF_HEIGHT= CANVAS_HEIGHT/2

CANVAS_NAME = 'game_canvas'
SCORE_NAME = 'score'


class AudioStuff
	constructor: ->
		@success_samples = []
		@failure_samples = []
		@game_over_samples = []

		@load_music()
		@load_success_samples()
		@load_failure_samples()
		@load_game_over_sample()

	load_audio_files: (samples_to_load, target) ->
		for name in samples_to_load
			sample = new buzz.sound name,
				formats: [ "ogg", "mp3", "wav" ]
				preload: true
				loop: false
				autoplay: false
			target.push sample


	load_music: ->
		music = new buzz.sound 'da_regex',
			formats: [ "ogg", "mp3", "wav" ]
			preload: true
			loop: false
			autoplay: true
		music.setVolume 50

		# Try to restart when its done
		music.bind 'ended', (e) ->
			music.load().play()
			music.setVolume 50

	load_success_samples: ->
		samples_to_load = ['yeah','super', 'give_me_five', 'alright']
		@load_audio_files samples_to_load, @success_samples

	load_failure_samples: ->
		samples_to_load = ['error', 'that_is_not_correct', 'try_again']
		@load_audio_files samples_to_load, @failure_samples

	load_game_over_sample: ->
		samples_to_load = ['game_over']
		@load_audio_files samples_to_load, @game_over_samples

	play_success: ->
		sample_no = Math.floor Math.random() * @success_samples.length
		@success_samples[sample_no].load().play()

	play_failure: ->
		sample_no = Math.floor Math.random() * @failure_samples.length
		@failure_samples[sample_no].load().play()

	play_game_over: ->
		sample_no = Math.floor Math.random() * @game_over_samples.length
		@game_over_samples[sample_no].load().play()

audio_stuff = new AudioStuff()

padding = 8
font_canvas = document.createElement 'canvas'
font_context = font_canvas.getContext '2d'

string_to_image = (das_text, color) ->
	font_context.font = 'bold 18pt Courier New'
	font_context.textAlign = 'left'
	font_context.fillStyle = 'black'
	metrics = font_context.measureText das_text
	font_canvas.width = metrics.width+padding
	font_canvas.height = 21 + padding

	font_context.rect 0,0,font_canvas.width,font_canvas.height
	font_context.stroke()

	font_context.fillStyle = color
	font_context.font = 'bold 18pt Courier New'
	font_context.textAlign = 'left'
	font_context.fillText das_text, padding/2, font_canvas.height-padding/2-4

	image = new Image()
	# I have to set width and height or it won't work in Safari and Firefox
	image.width = font_canvas.width
	image.height = font_canvas.height
	image.src = font_canvas.toDataURL()
	return image

class Player
	constructor: ->
		@score = 0
		@score_div = document.getElementById SCORE_NAME

	add_score: (more) ->
		@score += more
		@score_div.innerHTML = @score.toString() + ' points'

class Block
	constructor: ->

	add_to_world: (world) ->

		block_width = @img.width
		block_height = @img.height
		x_start_pos = Math.random() * (CANVAS_PLAY_WIDTH - block_width)

		block = Physics.body 'rectangle', 
			width: block_width
			height: block_height
			restitution: 0.95
			mass: 0.1
			x: x_start_pos
			y: -block_height
			view: @img

		rotation = (0.5 - Math.random()) * 0.001
		block.state.angular.acc = rotation
		block.object = this

		world.add block

	score: ->
		if @string.length == 0
			return 125
		else
			return @string.length
<commit_msg>Removed score<commit_after>
CANVAS_WIDTH = 600
CANVAS_PLAY_WIDTH = 400
CANVAS_HEIGHT = 400
CANVAS_HALF_WIDTH = CANVAS_WIDTH/2
CANVAS_HALF_HEIGHT= CANVAS_HEIGHT/2

CANVAS_NAME = 'game_canvas'
SCORE_NAME = 'score'


class AudioStuff
	constructor: ->
		@success_samples = []
		@failure_samples = []
		@game_over_samples = []

		@load_music()
		@load_success_samples()
		@load_failure_samples()
		@load_game_over_sample()

	load_audio_files: (samples_to_load, target) ->
		for name in samples_to_load
			sample = new buzz.sound name,
				formats: [ "ogg", "mp3", "wav" ]
				preload: true
				loop: false
				autoplay: false
			target.push sample


	load_music: ->
		music = new buzz.sound 'da_regex',
			formats: [ "ogg", "mp3", "wav" ]
			preload: true
			loop: false
			autoplay: true
		music.setVolume 50

		# Try to restart when its done
		music.bind 'ended', (e) ->
			music.load().play()
			music.setVolume 50

	load_success_samples: ->
		samples_to_load = ['yeah','super', 'give_me_five', 'alright']
		@load_audio_files samples_to_load, @success_samples

	load_failure_samples: ->
		samples_to_load = ['error', 'that_is_not_correct', 'try_again']
		@load_audio_files samples_to_load, @failure_samples

	load_game_over_sample: ->
		samples_to_load = ['game_over']
		@load_audio_files samples_to_load, @game_over_samples

	play_success: ->
		sample_no = Math.floor Math.random() * @success_samples.length
		@success_samples[sample_no].load().play()

	play_failure: ->
		sample_no = Math.floor Math.random() * @failure_samples.length
		@failure_samples[sample_no].load().play()

	play_game_over: ->
		sample_no = Math.floor Math.random() * @game_over_samples.length
		@game_over_samples[sample_no].load().play()

audio_stuff = new AudioStuff()

padding = 8
font_canvas = document.createElement 'canvas'
font_context = font_canvas.getContext '2d'

string_to_image = (das_text, color) ->
	font_context.font = 'bold 18pt Courier New'
	font_context.textAlign = 'left'
	font_context.fillStyle = 'black'
	metrics = font_context.measureText das_text
	font_canvas.width = metrics.width+padding
	font_canvas.height = 21 + padding

	font_context.rect 0,0,font_canvas.width,font_canvas.height
	font_context.stroke()

	font_context.fillStyle = color
	font_context.font = 'bold 18pt Courier New'
	font_context.textAlign = 'left'
	font_context.fillText das_text, padding/2, font_canvas.height-padding/2-4

	image = new Image()
	# I have to set width and height or it won't work in Safari and Firefox
	image.width = font_canvas.width
	image.height = font_canvas.height
	image.src = font_canvas.toDataURL()
	return image

class Player
	constructor: ->
		@score = 0
		@score_div = document.getElementById SCORE_NAME

	add_score: (more) ->
		@score += more
#		@score_div.innerHTML = @score.toString() + ' points'

class Block
	constructor: ->

	add_to_world: (world) ->

		block_width = @img.width
		block_height = @img.height
		x_start_pos = Math.random() * (CANVAS_PLAY_WIDTH - block_width)

		block = Physics.body 'rectangle', 
			width: block_width
			height: block_height
			restitution: 0.95
			mass: 0.1
			x: x_start_pos
			y: -block_height
			view: @img

		rotation = (0.5 - Math.random()) * 0.001
		block.state.angular.acc = rotation
		block.object = this

		world.add block

	score: ->
		if @string.length == 0
			return 125
		else
			return @string.length

{'fraction_non_alphanumeric': 0.11535591702730935, 'fraction_numerical': 0.0137292941352037, 'mean_word_length': 4.293838862559242, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4955510', 'n_tokens_mistral': 2674, 'n_tokens_neox': 2374, 'n_words': 509}