Godot Engine key-value based database

2018 04 22 No Comments

Hello
Here are you simple database for Godot Engine. I got inspired from this answer at godotengine qa.

func SetValue(key, value):
	var data = {key: value}
	var file = File.new()
	if file.open("user://shared_pref.sav", File.WRITE) != 0:
	    print("Error opening file")
	    return
	
	# Save the dictionary as JSON (or whatever you want, JSON is convenient here because it's built-in)
	file.store_line(to_json(data))
	file.close()


func GetValue(key):
	var file = File.new()
	if not file.file_exists("user://shared_pref.sav"):
	    print("No file saved!")
	    return
	
	# Open existing file
	if file.open("user://shared_pref.sav", File.READ) != 0:
	    print("Error opening file")
	    return
	
	# Get the data
	var data = {}
	data = parse_json(file.get_line())
	if data.has(key):
		return data[key]
	else:
		print(key, " [key] not assigned in saved_data")
		return 0

Save above file named Database.gd … To use it import like this:

onready var Database = preload("res://Database.gd").new()

Here you are ready to save values to database:

Database.SetValue("SomeValue", "test")
var foo = Database.GetValue("SomeValue")
print(foo)

Enjoy..

Godot Engine Android testing & publishing

2018 04 21 No Comments

Hey
I am writing these informations as a note. If I forgot the steps, I can look at this page..

Firstly Editor > Manage Export Templates. Download and install, that’s it.

Secondly in Editor > Editor Settings set these values:
– adb (download android studio and set path)
– jarsigner executable (download from version 8 and set jarsigner path)
– debug keystore

Last step is to set window.

Go Project > Project Settings > Display > Window
– Scroll to Strect section
– Set mode 2d(2d because I am working on 2d game)
– Aspect=expand.

So you can test now on your phone and see result.

To run game on your phone, enable usb debugging in your phone and connect usb cable. There will be Android icon next to Play Scene button.

More Godot Engine posts will be came..
<3 Godot Engine Happy coding.

2D Oyun Motorları Listesi [2018]

2016 04 18 3 Comments

2D oyun geliştirmek için piyasada onlarca oyun motoru mevcut. Bu yazıda bu oyun motorları hakkında yorumlarım ve birkaç bilgi yer alıyor. Artık ben de oyun yapmak istiyorum diyorsanız tek yapmanız gereken size çekici gelen bir tanesini seçmek ve hemen işe koyulmak. 🙂

İsterseniz hepsini tek tek deneyip, size en kolay ve kullanışlı olanı da seçebilirsiniz.
(more…)