initial commit
This commit is contained in:
		
							parent
							
								
									b9f229845c
								
							
						
					
					
						commit
						858eb3a599
					
				
					 48 changed files with 470 additions and 861 deletions
				
			
		
							
								
								
									
										54
									
								
								scripts/createStats.gd
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								scripts/createStats.gd
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,54 @@ | |||
| extends Node | ||||
| 
 | ||||
| var field = preload("res://scenes/menu/inputOutput.tscn") | ||||
| var data:Dictionary | ||||
| 
 | ||||
| func loadJSON(savePath): | ||||
| 	if not FileAccess.file_exists(savePath): | ||||
| 		return false | ||||
| 	var fileAccess = FileAccess.open(savePath, FileAccess.READ) | ||||
| 	var jsonString = fileAccess.get_line() | ||||
| 	fileAccess.close() | ||||
| 
 | ||||
| 	var json = JSON.new() | ||||
| 	var error = json.parse(jsonString) | ||||
| 	if error: | ||||
| 		print("JSON Parse Error: ", json.get_error_message(), " in ", jsonString, " at line ", json.get_error_line()) | ||||
| 		return false | ||||
| 
 | ||||
| 	data = json.data | ||||
| 	return true | ||||
| 
 | ||||
| func _ready(): | ||||
| 	if loadJSON("res://content/stats.json"): | ||||
| 		for i in range(int(data.get("amount"))): | ||||
| 			var fieldInstance = field.instantiate() | ||||
| 			$"ScrollContainer/VBoxContainer".add_child(fieldInstance) | ||||
| 			$"ScrollContainer/VBoxContainer".get_child(i).position = Vector2(16,(16+i*88)) | ||||
| 			$"ScrollContainer/VBoxContainer".get_child(i).placeholder_text = data.get(str(i)) | ||||
| 			$"ScrollContainer/VBoxContainer".get_child(i).custom_minimum_size.y = 40 | ||||
| 
 | ||||
| func saveJSON(savePath):	 | ||||
| 	var saveData = {} | ||||
| 	 | ||||
| 	for i in range(int(data.get("amount"))): | ||||
| 		if i > 0: | ||||
| 			saveData[data.get(str(i))] = $"ScrollContainer/VBoxContainer".get_child(i).text | ||||
| 	 | ||||
| 	var jsonString = JSON.stringify(saveData) | ||||
| 	 | ||||
| 	var fileAccess = FileAccess.open(savePath, FileAccess.WRITE) | ||||
| 	if not fileAccess: | ||||
| 		print("An error happened while saving data: ", FileAccess.get_open_error()) | ||||
| 		return | ||||
| 	 | ||||
| 	fileAccess.store_line(jsonString) | ||||
| 	fileAccess.close() | ||||
| 
 | ||||
| func _on_button_pressed(): | ||||
| 	var savePath = str("user://player_data"+$"ScrollContainer/VBoxContainer".get_child(0).text+".json") | ||||
| 	saveJSON(savePath) | ||||
| 
 | ||||
| func _process(delta): | ||||
| 	if Input.is_action_pressed("escape"): | ||||
| 		get_tree().change_scene_to_file("res://scenes/menu/main.tscn") | ||||
							
								
								
									
										46
									
								
								scripts/getStats.gd
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								scripts/getStats.gd
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,46 @@ | |||
| extends Node | ||||
| 
 | ||||
| var field = preload("res://scenes/menu/inputOutput.tscn") | ||||
| var data:Dictionary | ||||
| var amount | ||||
| 
 | ||||
| func loadJSON(savePath): | ||||
| 	if not FileAccess.file_exists(savePath): | ||||
| 		return false | ||||
| 	var fileAccess = FileAccess.open(savePath, FileAccess.READ) | ||||
| 	var json_string = fileAccess.get_line() | ||||
| 	fileAccess.close() | ||||
| 
 | ||||
| 	var json = JSON.new() | ||||
| 	var error = json.parse(json_string) | ||||
| 	if error: | ||||
| 		print("JSON Parse Error: ", json.get_error_message(), " in ", json_string, " at line ", json.get_error_line()) | ||||
| 		return false | ||||
| 
 | ||||
| 	data = json.data | ||||
| 	return true | ||||
| 
 | ||||
| func _ready(): | ||||
| 	if loadJSON("res://content/stats.json"): | ||||
| 		for i in range(int(data.get("amount"))): | ||||
| 			var fieldInstance = field.instantiate() | ||||
| 			$"ScrollContainer/VBoxContainer".add_child(fieldInstance) | ||||
| 			$"ScrollContainer/VBoxContainer".get_child(i).placeholder_text = data.get(str(i)) | ||||
| 			$"ScrollContainer/VBoxContainer".get_child(i).custom_minimum_size.y = 40 | ||||
| 			if i > 0: | ||||
| 				$"ScrollContainer/VBoxContainer".get_child(i).editable = false | ||||
| 		amount = data.get("amount") | ||||
| 
 | ||||
| func _on_button_pressed(): | ||||
| 	var savePath = str("user://player_data"+$"ScrollContainer/VBoxContainer".get_child(0).text+".json") | ||||
| 	if loadJSON(savePath): | ||||
| 		for i in range(int(amount)-1): | ||||
| 			$"ScrollContainer/VBoxContainer".get_child(i+1).text = data.get(str($"ScrollContainer/VBoxContainer".get_child(i+1).placeholder_text)) | ||||
| 
 | ||||
| func _process(_delta): | ||||
| 	if Input.is_action_pressed("escape"): | ||||
| 		get_tree().change_scene_to_file("res://scenes/menu/main.tscn") | ||||
| 		 | ||||
| func hideGet(): | ||||
| 	$button.visible = false | ||||
| 	$button.disabled = true | ||||
							
								
								
									
										37
									
								
								scripts/mapscript.gd
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								scripts/mapscript.gd
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,37 @@ | |||
| extends Node2D | ||||
| 
 | ||||
| var playerAmount=2 | ||||
| var playerIndex=0 | ||||
| var objectName | ||||
| 
 | ||||
| func _ready(): | ||||
| 	$"../characterViewer".hideGet() | ||||
| 	next() | ||||
| 
 | ||||
| func next(): | ||||
| 	if playerIndex >= playerAmount: | ||||
| 		playerIndex = 0 | ||||
| 	objectName= "player%d" % playerIndex | ||||
| 	print(objectName) | ||||
| 	get_node(objectName).start() | ||||
| 	playerIndex += 1 | ||||
| 
 | ||||
| func stats(): | ||||
| 	visible = false | ||||
| 	$"../characterViewer".visible = true | ||||
| 	get_node(objectName).stop() | ||||
| 	$"../back".disabled = false | ||||
| 	$"../back".visible = true | ||||
| 	$"../characterViewer/ScrollContainer/VBoxContainer".get_child(0).text = str(playerIndex-1) | ||||
| 	$"../characterViewer/ScrollContainer/VBoxContainer".get_child(0).editable = false | ||||
| 	$"../characterViewer"._on_button_pressed() | ||||
| 
 | ||||
| func restart(): | ||||
| 	visible = true | ||||
| 	$"../characterViewer".visible = false | ||||
| 	get_node(objectName).start() | ||||
| 	$"../back".disabled = true | ||||
| 	$"../back".visible = false | ||||
| 
 | ||||
| func _on_back_pressed(): | ||||
| 	restart() | ||||
|  | @ -1,4 +1,14 @@ | |||
| extends Node | ||||
| 
 | ||||
| func _on_pressed(): | ||||
| 	get_tree().change_scene_to_file("res://scenes/test/map.tscn") | ||||
| 
 | ||||
| 
 | ||||
| func _on_button_pressed(): | ||||
| 	get_tree().change_scene_to_file("res://scenes/map/map.tscn") | ||||
| 
 | ||||
| 
 | ||||
| func _on_button_2_pressed(): | ||||
| 	get_tree().change_scene_to_file("res://scenes/menu/view.tscn") | ||||
| 
 | ||||
| 
 | ||||
| func _on_button_3_pressed(): | ||||
| 	get_tree().change_scene_to_file("res://scenes/menu/create.tscn") | ||||
|  |  | |||
|  | @ -1,11 +1,39 @@ | |||
| extends CharacterBody2D | ||||
| 
 | ||||
| @export var speed = 200 | ||||
| var distanceTo = 0 | ||||
| var active = false | ||||
| 
 | ||||
| func get_input(): | ||||
| 	if Input.is_action_pressed("escape"): | ||||
| 		get_tree().change_scene_to_file("res://scenes/menu/main.tscn") | ||||
| 	var input_direction = Input.get_vector("left", "right", "up", "down") | ||||
| 	velocity = input_direction * speed | ||||
| 
 | ||||
| func _physics_process(delta): | ||||
| 	get_input() | ||||
| 	move_and_slide() | ||||
| 	var toCalculate = position | ||||
| 	if active: | ||||
| 		get_input() | ||||
| 		move_and_slide() | ||||
| 	distanceTo += position.distance_to(toCalculate) | ||||
| 	print(distanceTo) | ||||
| 	if distanceTo > 500 and active: | ||||
| 		stop() | ||||
| 		distanceTo = 0 | ||||
| 		get_parent().next() | ||||
| 
 | ||||
| 
 | ||||
| func start(): | ||||
| 	$camera.enabled = true | ||||
| 	active = true | ||||
| 	$stats.disabled = false | ||||
| 	$stats.visible = true | ||||
| 
 | ||||
| func stop(): | ||||
| 	$camera.enabled = false | ||||
| 	active = false | ||||
| 	$stats.disabled = true | ||||
| 	$stats.visible = false | ||||
| 
 | ||||
| func _on_stats_pressed(): | ||||
| 	get_parent().stats() | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Sage The DM
						Sage The DM