1+ extends  Node2D 
2+ 
3+ var  Circle  =  preload ("res://objects/Circle.tscn" )
4+ var  font  =  preload ("res://assets/fonts/xolonium_64.tres" )
5+ var  level 
6+ var  last_circle_position 
7+ var  level_markers  =  []
8+ 
9+ func  _ready ():
10+ 	randomize ()
11+ 	last_circle_position  =  $ Camera2D .position 
12+ 	level  =  0 
13+ 	for  i  in  100 :
14+ 		if  i  %  5  ==  0 :
15+ 			level  +=  1 
16+ 			level_markers .append (last_circle_position )
17+ 		spawn_circle ()
18+ 	update ()
19+ 		
20+ func  _process (delta ):
21+ 	if  Input .is_action_pressed ("ui_up" ):
22+ 		$ Camera2D .position .y  -=  15 
23+ 	if  Input .is_action_pressed ("ui_down" ):
24+ 		$ Camera2D .position .y  +=  15 
25+ 	if  Input .is_action_pressed ("ui_left" ):
26+ 		$ Camera2D .position .x  -=  15 
27+ 	if  Input .is_action_pressed ("ui_right" ):
28+ 		$ Camera2D .position .x  +=  15 
29+ 
30+ func  spawn_circle (_position = null ):
31+ 	var  c  =  Circle .instance ()
32+ 	if  ! _position :
33+ 		var  x  =  rand_range (- 150 , 150 )
34+ 		var  y  =  rand_range (- 500 , - 400 )
35+ 		_position  =  last_circle_position  +  Vector2 (x , y )
36+ 	add_child (c )
37+ 	c .init (_position , level )
38+ 	last_circle_position  =  _position 
39+ 
40+ func  _draw ():
41+ 	var  l  =  1 
42+ 	for  pos  in  level_markers :
43+ 		var  s  =  Vector2 (pos .x - 480 , pos .y - 200 )
44+ 		var  e  =  Vector2 (pos .x - 80 , pos .y - 200 )
45+ 		draw_line (s , e , Color (1 , 1 , 1 ), 15 )
46+ 		draw_string (font , s  -  Vector2 (0 , 50 ), str (l ), Color (1 , 1 , 1 ))
47+ 		l  +=  1 
0 commit comments