Instancing is a must in Arian scout
(2D top-down game)
Making large games with lots of quests is process of constant code adding. This is also a possibility for automation like scene instancing. I decided to use Godot 3.1 free game engine with GD Script to make GD Script (similar to Python) scene for instance. Parameters of scene can be changed and this will save me a lot of programming time.
For example, I will show you a real function for button creation. With this, I can easily set a new button with text, design, and position with only one function call line with parameters for button create function.
func button_create(btn_text,pos,btn_no):
# Button creation process
btn = Button.new()
btn.rect_position=Vector2(0,pos)
btn.rect_size=Vector2(190,24)
btn.text=btn_text
btn.add_font_override("font",load("res://fonts/architect-s-daughter/ArchitectsDaughter32.tres"))
btn.get("custom_fonts/font").set_size(font_size)
btn.get("custom_fonts/font").set_outline_size(outline_size)
btn.get("custom_fonts/font").set_outline_color(Color.blue)
btn.get("custom_fonts/font").extra_spacing_char=char_spacing
btn.add_color_override("font_color",font_color)
btn.add_color_override("font_color_hover",Color.green)
btn.connect("mouse_entered",self,"On_hover_"+str(btn_no))
btn.connect("mouse_exited",self,"On_hover_out_"+str(btn_no))
btn.connect("button_down",self,"On_click_"+str(btn_no))
btn.visible=false
buttons.append(btn)
.add_child(buttons[btn_no])
If you ask me where did I learn it, many places, but mostly from "GD Script" book. It was 0.99$ one time and now it is 2.99$. Sometimes you need to pay a little for knowledge because I usually learn from free videos about.
Link for "GD Script" Godot 3.1 game engine script e-book:
https://www.amazon.com/dp/B07VR8TVWC
Instancing save me a lot of time, and now I can continue with efficient game developing of the Arian Scout game.
You can also see how buttons look like in a game (images below), part of code and parameters list. With this coding, I simply put some parameters and have new buttons for game options.
0 comments