hide on pause, T-SPIN on rotation 5
This commit is contained in:
		
							
								
								
									
										29
									
								
								Main.gd
									
									
									
									
									
								
							
							
						
						
									
										29
									
								
								Main.gd
									
									
									
									
									
								
							| @ -60,9 +60,9 @@ func _ready(): | ||||
| func new_game(): | ||||
| 	$Stats.visible = true | ||||
| 	$Stats.new_game() | ||||
| 	new_piece() | ||||
| 	resume() | ||||
| 	new_level() | ||||
| 	new_piece() | ||||
| 	 | ||||
| func new_level(): | ||||
| 	$Stats.new_level() | ||||
| @ -129,8 +129,10 @@ func process_autoshift_action(): | ||||
| 			$Stats/HBC/VBC1/Score.text = str($Stats.score) | ||||
|  | ||||
| func hard_drop(): | ||||
| 	var score = 0 | ||||
| 	while move(movements["soft_drop"]): | ||||
| 		$Stats.score += 2 | ||||
| 		score += 2 | ||||
| 	$Stats.score += score | ||||
| 	$Stats/HBC/VBC1/Score.text = str($Stats.score) | ||||
| 	lock() | ||||
| 		 | ||||
| @ -204,25 +206,34 @@ func resume(): | ||||
| 	$Stats/Clock.start() | ||||
| 	$MidiPlayer.resume() | ||||
| 	$MidiPlayer.mute_channels(LINE_CLEAR_MIDI_CHANNELS) | ||||
| 	$GridMap.visible = true | ||||
| 	next_piece.visible = true | ||||
| 	current_piece.visible = true | ||||
| 	if held_piece: | ||||
| 		held_piece.visible = true | ||||
| 	flash_print("GO!") | ||||
|  | ||||
| func pause(): | ||||
| func pause(text = "PAUSE"): | ||||
| 	playing = false | ||||
| 	$DropTimer.stop() | ||||
| 	$LockDelay.stop() | ||||
| 	$Stats/Clock.stop() | ||||
| 	$Stats.time = OS.get_system_time_secs() - $Stats.time | ||||
| 	if text == "PAUSE": | ||||
| 		$Stats.time = OS.get_system_time_secs() - $Stats.time | ||||
| 		$GridMap.visible = false | ||||
| 		next_piece.visible = false | ||||
| 		current_piece.visible = false | ||||
| 		if held_piece: | ||||
| 			held_piece.visible = false | ||||
| 	$MidiPlayer.stop() | ||||
| 	flash_print("PAUSE") | ||||
| 	flash_print(text) | ||||
| 		 | ||||
| func game_over(): | ||||
| 	pause() | ||||
| 	flash_print("GAME OVER") | ||||
| 	pause("GAME OVER") | ||||
| 	 | ||||
| func _notification(what): | ||||
| 	if what == MainLoop.NOTIFICATION_WM_FOCUS_OUT: | ||||
| 		pause() | ||||
|     #if what == MainLoop.NOTIFICATION_WM_FOCUS_IN: | ||||
|     #    resume() | ||||
|  | ||||
| func _on_LineCLearTimer_timeout(): | ||||
| 	$MidiPlayer.mute_channels(LINE_CLEAR_MIDI_CHANNELS) | ||||
|  | ||||
| @ -216,7 +216,7 @@ tracks/2/keys = { | ||||
| "values": [ Vector2( 0, 110 ), Vector2( 0, -50 ), Vector2( 0, -60 ), Vector2( 0, -100 ) ] | ||||
| } | ||||
|  | ||||
| [node name="Main" type="WorldEnvironment"] | ||||
| [node name="Main" type="WorldEnvironment" index="0"] | ||||
|  | ||||
| environment = SubResource( 2 ) | ||||
| script = ExtResource( 2 ) | ||||
| @ -381,7 +381,7 @@ file = "res://midi/Tetris - Song A.mid" | ||||
| volume_db = -24 | ||||
| loop = true | ||||
| loop_start = 1.71 | ||||
| soundfont = "res://midi/FluidR3 GM.sf2" | ||||
| soundfont = "res://midi/TimGM6mb.sf2" | ||||
|  | ||||
| [node name="Stats" parent="." index="12" instance=ExtResource( 6 )] | ||||
|  | ||||
|  | ||||
| @ -19,7 +19,7 @@ use_filter = false | ||||
| font_data = ExtResource( 2 ) | ||||
| _sections_unfolded = [ "Font", "Settings" ] | ||||
|  | ||||
| [node name="Stats" type="MarginContainer" index="0"] | ||||
| [node name="Stats" type="MarginContainer"] | ||||
|  | ||||
| anchor_left = 0.0 | ||||
| anchor_top = 0.5 | ||||
|  | ||||
| @ -8,13 +8,8 @@ const T_SLOT = [ | ||||
| ] | ||||
|  | ||||
| func rotate(direction): | ||||
| 	if .rotate(direction): | ||||
| 		detect_t_spin() | ||||
| 		return true | ||||
| 	return false | ||||
| 	 | ||||
| func detect_t_spin(): | ||||
| 	if t_spin != T_SPIN: | ||||
| 	var rotation_point = .rotate(direction) | ||||
| 	if rotation_point and t_spin != T_SPIN: | ||||
| 		var center = to_global(minoes[0].translation) | ||||
| 		var a = not grid_map.is_free_cell(center + T_SLOT[orientation]) | ||||
| 		var b = not grid_map.is_free_cell(center + T_SLOT[(1+orientation)%4]) | ||||
| @ -23,4 +18,8 @@ func detect_t_spin(): | ||||
| 		if a and b and (c or d): | ||||
| 			t_spin = T_SPIN | ||||
| 		elif c and d and (a or b): | ||||
| 			t_spin = MINI_T_SPIN | ||||
| 			if rotation_point == 5: | ||||
| 				t_spin = T_SPIN | ||||
| 			else: | ||||
| 				t_spin = MINI_T_SPIN | ||||
| 	return rotation_point | ||||
| @ -113,14 +113,14 @@ func move(movement): | ||||
| func rotate(direction): | ||||
| 	var rotated_positions = rotated_positions(direction) | ||||
| 	var movements = SUPER_ROTATION_SYSTEM[orientation][direction] | ||||
| 	for movement in movements: | ||||
| 		if grid_map.possible_positions(rotated_positions, movement): | ||||
| 	for i in range(movements.size()): | ||||
| 		if grid_map.possible_positions(rotated_positions, movements[i]): | ||||
| 			orientation -= direction | ||||
| 			orientation %= NB_MINOES | ||||
| 			apply_positions(rotated_positions) | ||||
| 			translate(movement) | ||||
| 			return true | ||||
| 	return false | ||||
| 			translate(movements[i]) | ||||
| 			return i+1 | ||||
| 	return 0 | ||||
| 	 | ||||
| func emit_trail(emit): | ||||
| 	var trail | ||||
|  | ||||
		Reference in New Issue
	
	Block a user