Godot Game Engine


Categories: Development Tags: Game Development Godot Android Development


This is a repository for little bits and pieces.

List Comprehensions

Something like Python’s list comprehensions really comes in handy when doing Array comparisons. Godot does not, and probably will not, ever have this, but I found Groups were a handy way to organize and find things.

func get_group_members_in_array(array,group_name):
	var children = []
	for item in array:
		if item.is_in_group(str(group_name)):
	return children


I’m trying to get better about taking pictures of my apps as they progress. Enumeratuions

func _input(event):
	if event is InputEventKey and event.pressed:
		if event.scancode == KEY_PRINT:
			var datetime = OS.get_datetime()
			var readable_date = str(datetime["month"]) + str(datetime["day"]) + str(datetime["year"]) + " - " + str(datetime["hour"]) + str(datetime["minute"]) + str(datetime["second"])
			var image = get_viewport().get_texture().get_data()
			print("Screenshot taken: " + str(datetime))

Saving and Loading Game Data

var game_data = "user://gamename.save"

func load_game(): var save_game = File.new() if not save_game.file_exists(game_data): print("No game save data.") table = { "scores": [] } return # Error! We don’t have a save to load. print("Loading game data.") save_game.open(game_data, File.READ) table = save_game.get_var() save_game.close()

func save_game(): var save_game = File.new() save_game.open(game_data, File.WRITE) save_game.store_var(Global.table) print("Saved game data.") save_game.close()

This data is saved under C:\Users\yourname\AppData\Roaming\Godot\app_userdata\yourgame