Search This Blog

2021/03/22

How to indent text exactly one character width

Set style as below:


padding-left: 1em:

text-indent: 1em;

margin: 0px

2021/02/27

Use timer to auto save game data | Godot Engine

 func _ready():

# Timers don't work unless they are in the tree

var timer = Timer.new()

timer.set_wait_time(1)

timer.connect("timeout", self, "_on_Timer_timeout")

timer.set_autostart(true)

self.add_child(timer)


func _on_Timer_timeout():

# autosave func

save_game()

2021/01/17

牛顿迭代法求根号的值

例:求根号2等于多少。随意猜测为4,用牛顿迭代法

(4+2/4)/2=2.25

(2.25+2/2.25)/2=1.56944...

(1.56944...+2/1.56944...)/2=1.42189...

(1.42189...+2/1.42189...)/2=1.41423...

......