' Have fun with your new project!
' :)
' +++


'
background #013
select screen "back"
?size = 1000.0
scale screen 0, 600 to 1000, 0

?info = 1

'
?dim = 100

goto "restart"

do
	
	?offset + 1
	
	clear screen
	
	?scored + (?score - ?scored) / 5
	
	color 1
	create text (format number (round ?scored)) as "score"
	paint "score" to "ui"
	move "score" to 0, 80, 90
	'turn "score" to 20,0,0
	
	
	trace frame 0, 0 to 1000, 600
	
	color 6
	trace circle 20 to ?px, ?py
	trace fill
	color 99
	trace circle 3 to ?px - 8, ?py - 3
	trace fill
	trace circle 6 to ?px + 8, ?py - 3
	trace fill
	trace frame ?px - 5, ?py + 9 to ?px + 5, ?py + 12
	trace fill
	
	if ?info = 1
		color 1
		trace text "Utilisez la touche ESPACE pour sauter..." center 500, 300
	end
	
	
	?vy - .01
	if ?vy > 0
		?vy * .9
	else
		?vy * 1.05
	end
	
	if ?paul = 0
		?py - ?vy * 2
	end
	
	
	for 1 to ?dim as ?e
		?x = [elem, ?e, x]
		[elem, ?e, x] - ?speed
		
		' passé = score
		if ?over = 0
			if ?x < ?px and [elem, ?e, a] = 1
				[elem, ?e, a] = 0
				?score + ?gain
				?gain * 1.9
				'?score * 1.10
			end
		end
		
		' nouveau ?
		if ?x < -?w and ?delay < 0
			?delay = ?delay_max
			?delay_max * .985
			
			[elem, ?e, x] = ?size
			[elem, ?e, y] = random 200 to 400
			[elem, ?e, h] = ?space
			[elem, ?e, a] = 1
			?space - 2' plus étroit
			?w + 1.5' plus large
		end
		
		?y = [elem, ?e, y]
		?h = [elem, ?e, h]
		
		if [elem, ?e, a] = 1
			color 1 + ?e
		else
			[elem, ?e, h] + 3
			color 51
		end
		trace frame ?x, ?y + ?h to ?x + ?w, 600
		trace fill
		trace frame ?x, 0 to ?x + ?w, ?y - ?h
		trace fill
		
		'if ?x > 100
		if [elem, ?e, a] = 0
			if ?px > ?x and ?px < (?x + ?w)
				if ?py < (?y - ?h)
					goto "gameover"
					'print "+"
				else if ?py > (?y + ?h)
					'print "-"
					goto "gameover"
				end
			end
		end
		
	next
	?delay - 1
	
	update
	
	if ?over = 0
		if ?py < 0 or ?py > 600
			goto "gameover"
		end
		
		if (press "space") = 1
			?paul = 0
			?vy = 5
			if ?info = 1
				' effacer l'explication
				?info = 0
			end
		end
	else
		?r = (frame) * 3
		?px - 5
		'print ?r
		turn "label" to 0, ?r, 0
		
		if (press "enter") = 1
			goto "restart"
		end
	end
	
	
	
loop

'

label "restart"
	
	for 1 to ?dim as ?e
		[elem, ?e, a] = 0
	next
	
	delete "label"
	
	?px = 300
	?py = 500
	
	
	?vy = 0
	
	?w = 20
	
	
	?delay = 0
	?delay_max = 120
	?speed = 3
	
	?paul = 1
	?over = 0
	
	trace size 2
	?score = 0
	?gain = 25
	
	?scored = 0
	?space = 150
return

'

label "gameover"
	if ?over = 0
		?over = 1
		
		color 6
		create text "GAME OVER" as "label"
		move "label" to 0, 0, 30
	end
return
x