Adding initial prototype 2

This commit is contained in:
Segey Lapin
2019-07-19 19:52:43 +03:00
parent 72c909b7a6
commit 3583b86130
16 changed files with 34473 additions and 0 deletions

266
proto2/ai/ball_game_ai.gd Normal file
View File

@@ -0,0 +1,266 @@
extends Node
class_name BallGameAI
var _ball: PackedScene
var _cheers = {}
var _game_area: Rect2
var _teams = {}
var _main
var _state = STATE_INIT
var _ball_instance
var _cheer_locations = {}
var _team_start = {}
var _ball_carrier = null
var _ball_team = -1
var ch2team: Dictionary = {}
var gate2team = {}
var _gates = {}
var _scores = {}
enum {STATE_INIT, STATE_START, STATE_RUNNING, STATE_FINISH}
func _ready():
_game_area = Rect2()
func set_ball(ball: PackedScene):
_ball = ball
func add_player(team: int, pl: Dictionary):
if !_teams.has(team):
_teams[team] = [pl]
else:
_teams[team].push_back(pl)
assert pl != null
ch2team[pl.scene] = team
func add_cheer(team: int, ch: Dictionary):
if !_cheers.has(team):
_cheers[team] = [ch]
else:
_cheers[team].push_back(ch)
assert ch != null
ch2team[ch.scene] = team
func add_cheer_game_location(team: int, loc: Vector2):
if !_cheer_locations.has(team):
_cheer_locations[team] = [loc]
else:
_cheer_locations[team].push_back(loc)
_game_area = _game_area.expand(loc)
func set_team_start(team: int, v: Vector2):
_team_start[team] = v
_game_area = _game_area.expand(v)
func set_team_gate(team: int, gate: Area2D):
_gates[team] = gate
gate2team[gate] = team
gate.connect("body_entered", self, "check_goal", [gate])
_game_area = _game_area.expand(gate.global_position)
func set_main(n):
_main = n
func start_game():
var ball = _ball.instance()
_main.add_child(ball)
ball.global_position = world.master_node.global_position + Vector2(randf() - 0.5, randf() - 0.5) * 20.0
ball.add_to_group("ball")
_state = STATE_START
for t in _teams.keys():
for ch in _teams[t]:
ch.scene.walkto(_team_start[t])
var loc = 0
for t in _cheers.keys():
for ch in _cheers[t]:
ch.scene.walkto(_cheer_locations[t][loc % _cheer_locations[t].size()])
loc += 1
_ball_instance = ball
for t in _teams.keys():
_scores[t] = 0
func stop_game():
for k in get_tree().get_nodes_in_group("ball"):
k.queue_free()
_state = STATE_INIT
var max_score = -1
var winner_team = -1
for k in _scores.keys():
if _scores[k] > max_score:
max_score = _scores[k]
winner_team = k
if winner_team >= 0:
for e in _teams[winner_team]:
world.increase_xp(e, min(e.xp * 2, min(100 * e.level, 1000)))
for e in _cheers[winner_team]:
world.increase_xp(e, min(e.xp * 2, min(200 * e.level, 2000)))
var base_speed = 300.0
func striker(ch: Dictionary, delta: float) -> Vector2:
var velocity: Vector2 = Vector2()
var dir = Vector2()
if _ball_carrier == null:
dir = _ball_instance.global_position - ch.scene.global_position
else:
dir = _ball_carrier.scene.global_position - ch.scene.global_position
velocity = dir.normalized() * base_speed * ch.speed
return velocity
func avoid(ch: Dictionary, delta: float) -> Vector2:
var velocity: Vector2 = Vector2()
var vel_plus = Vector2()
var team = ch2team[ch.scene]
var ch_pos = ch.scene.global_position
for t in _teams.keys():
if t == team:
continue
for other in _teams[t]:
var opos = other.scene.global_position
var lvec = ch_pos - opos
vel_plus += lvec
velocity = vel_plus.normalized() * base_speed * ch.speed * (1.0 + ch.agression)
return velocity
func attack_gate(ch: Dictionary, delta: float) -> Vector2:
var velocity: Vector2 = Vector2()
var team = ch2team[ch.scene]
var dir = _gates[team ^ 1].global_position - ch.scene.global_position
if dir.length() > 80:
velocity = dir.normalized() * base_speed * ch.speed * (1.0 + ch.agression)
elif dir.length() > 40:
velocity = dir.normalized() * base_speed * ch.speed * 0.6 * (1.0 + ch.agression)
elif dir.length() > 25:
velocity = dir.normalized() * base_speed * ch.speed * 0.25 * (1.0 + ch.agression)
return velocity
var catch_delay = 0.0
func catch_ball(pl):
_ball_instance.kinematic = true
_ball_instance.new_parent = pl.scene
_ball_instance.update = true
_ball_instance.impulse = Vector2()
_ball_carrier = pl
var max_imp = 500.0
func drop_ball(pl):
assert _main != null
_ball_instance.kinematic = false
_ball_instance.new_parent = _main
_ball_instance.update = true
_ball_instance.impulse = _ball_carrier.scene.velocity * _ball_instance.mass * (1.5 + randf() * 10.0)
if _ball_instance.impulse.length() > max_imp:
_ball_instance.impulse = _ball_instance.impulse.normalized() * max_imp
_ball_carrier = null
func check_goal(body, gate):
print("check")
if _state == STATE_RUNNING:
var team = gate2team[gate]
if body is RigidBody2D:
if body == _ball_instance:
_scores[team] += 1
elif body is KinematicBody2D && _ball_carrier != null:
print("check2")
if body == _ball_carrier.scene:
world.increase_xp(_ball_carrier, 150)
_scores[team] += 1
catch_delay += 3.0
drop_ball(_ball_carrier)
print(_scores)
func colliding(delta):
var close_distance2 = 450.0
var chars = {}
for t in _teams.keys():
for e in _teams[t]:
chars[e.scene] = e
for t in _cheers.keys():
for e in _cheers[t]:
chars[e.scene] = e
for p in chars.keys():
var pos1 = chars[p].scene.global_position
var v1 = chars[p].scene.velocity
var strength = chars[p].strength
if chars[p] == _ball_carrier:
strength *= 5.0
for m in chars.keys():
if p == m:
continue
var pos2 = chars[m].scene.global_position
var dist = pos1.distance_squared_to(pos2)
var v2 = chars[m].scene.velocity
if dist < close_distance2:
if v1.dot(v2) < 0:
if strength > chars[m].strength:
chars[p].scene.velocity = chars[p].scene.velocity.linear_interpolate((v1 + v2) * 0.5, delta)
chars[m].scene.velocity = chars[p].scene.velocity.linear_interpolate((v1 + v2) * 0.5, delta)
else:
chars[p].scene.velocity = Vector2()
elif v1.dot(v2) >= 0:
if v1.length() > v2.length():
if strength > chars[m].strength:
chars[p].scene.velocity = chars[p].scene.velocity.linear_interpolate((v1 + v2) * 0.5, delta)
chars[m].scene.velocity = chars[p].scene.velocity.linear_interpolate((v1 + v2) * 0.5, delta)
var start_delay = 15.0
func _process(delta):
match(_state):
STATE_INIT:
pass
STATE_START:
var ok_to_run = true
for c in _teams.keys():
for pl in _teams[c]:
var ppos = pl.scene.global_position
var bpos = _team_start[c]
if ppos.distance_to(bpos) < 40:
pl.scene.state = pl.scene.STATE_CONTROL
elif ppos.distance_to(bpos) > 60 && pl.scene.state != pl.scene.STATE_CONTROL:
ok_to_run = false
if ok_to_run:
_state = STATE_RUNNING
for c in _teams.keys():
for pl in _teams[c]:
pl.scene.state = pl.scene.STATE_CONTROL
else:
if start_delay < 0.0:
for c in _teams.keys():
for pl in _teams[c]:
var ppos = pl.scene.global_position
var bpos = _team_start[c]
if ppos.distance_to(bpos) > 60 && pl.scene.state != pl.scene.STATE_CONTROL:
pl.scene.global_position = _team_start[c]
for c in _cheers.keys():
for pl in _cheers[c]:
var ppos = pl.scene.global_position
var bpos = pl.scene.destination
if ppos.distance_to(bpos) > 60 && pl.scene.state != pl.scene.STATE_CONTROL:
pl.scene.global_position = _team_start[c]
else:
start_delay -= delta
STATE_RUNNING:
for c in _teams.keys():
for pl in _teams[c]:
assert pl.scene != null
if !_ball_carrier || (pl != _ball_carrier && _ball_team != c):
var velocity = striker(pl, delta)
velocity = pl.scene.velocity.linear_interpolate(velocity, 0.3 * delta)
# velocity = pl.scene.move_and_slide(velocity)
pl.scene.velocity = velocity
elif _ball_carrier && _ball_carrier == pl:
var velocity = avoid(pl, delta) * 0.3 + attack_gate(pl, delta) * 0.7
velocity = pl.scene.velocity.linear_interpolate(velocity, 0.6 * delta)
# velocity = pl.scene.move_and_slide(velocity)
pl.scene.velocity = velocity
if _ball_carrier == null && pl.scene.global_position.distance_squared_to(_ball_instance.global_position) < 350 * (1.0 + pl.agression):
if catch_delay <= 0.0:
catch_ball(pl)
_ball_team = c
world.increase_xp(pl, 50)
elif _ball_carrier && pl != _ball_carrier && pl.scene.global_position.distance_squared_to(_ball_carrier.scene.global_position) < 350 * (1.0 + pl.agression):
if pl.strength * (1.0 + pl.agression) > _ball_carrier.strength * 1.2 * (1.0 + _ball_carrier.agression):
world.increase_xp(pl, 50)
drop_ball(_ball_carrier)
catch_delay += 5.0
colliding(delta)
for c in _teams.keys():
for pl in _teams[c]:
pl.scene.velocity = pl.scene.move_and_slide(pl.scene.velocity + Vector2(randf() - 0.5, randf() - 0.5) * 3.0)
if !_game_area.has_point(_ball_instance.global_position):
if !_ball_carrier:
_ball_instance.queue_free()
_ball_instance = _ball.instance()
_main.add_child(_ball_instance)
_ball_instance.global_position = world.master_node.global_position + Vector2(randf() - 0.5, randf() - 0.5) * 20.0
_ball_instance.add_to_group("ball")
catch_delay += 10.0
else:
drop_ball(_ball_carrier)
catch_delay += 7.0
if catch_delay > 0.0:
catch_delay -= delta

2
proto2/assets/.gdignore Normal file
View File

@@ -0,0 +1,2 @@
#

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

147
proto2/autoloads/world.gd Normal file
View File

@@ -0,0 +1,147 @@
extends Node
signal room_event
signal next_day
signal next_period
signal level_up
var money: int = 2000
var master_node
var current_room
var team = {}
var cheer_team = {}
var room_events = {}
var line = {}
var training = false
func room_event(ev: String):
if current_room:
if room_events.has(current_room.name):
if room_events[current_room.name].has(ev):
var evdata = room_events[current_room.name][ev]
evdata.obj.call_deferred(evdata.fname, evdata.name)
func register_room_event(roomobj, evname, fname):
if !room_events.has(roomobj.name):
room_events[roomobj.name] = {}
room_events[roomobj.name][evname] = {"obj": roomobj, "name": evname, "fname": fname}
func _ready():
connect("room_event", self, "room_event")
func new_candidate() -> Dictionary:
var gender = randi() % 2
var type = 0
if gender == 0:
type = 0
else:
type = randi() % 2
var ret = {}
if gender == 0:
ret.name = "John"
ret.lastname = "Doe"
else:
ret.name = "Jane"
ret.lastname = "Doe"
ret.type = type
ret.speed = 0.3 + randf() * 0.7
ret.strength = 0.1 + randf() * 0.9
ret.agression = 0.1 + randf() * 0.9
ret.charisma = 0.1 + randf() * 0.9
ret.obedience = 0.1 + randf() * 0.9
if type == 0:
ret.cost = 2 + int(randf() * 20.0 * (ret.speed + ret.strength + ret.agression) / 3.0)
else:
ret.cost = 2 + int(randf() * 20.0 * (ret.speed + ret.strength + ret.charisma) / 3.0)
ret.xp = 0
ret.next_xp = 100
ret.points = 5
ret.level = 1
return ret
func auto_points(ch):
while ch.points > 0:
ch.points -= 1
var choice = randi() % 5
match(choice):
0:
if ch.type == 0:
ch.strength += 0.15
else:
ch.charisma += 0.15
1:
ch.speed += 0.2
2:
ch.agression += 0.2
3:
ch.obedience += 0.2
4:
if ch.type == 1:
ch.strength += 0.05
else:
ch.charisma += 0.05
func level_up(ch):
emit_signal("level_up", ch)
ch.points += 1 + randi() % 5
if ch.level < 20:
ch.next_xp *= 2
elif ch.level < 60:
ch.next_xp += (10 + ch.level) * 1000
else:
ch.next_xp += (20 + ch.level) * 2000
ch.level += 1
print("level up!, new level: ", ch.level, " next xp: ", ch.next_xp)
auto_points(ch)
func increase_xp(ch, num):
ch.xp += num
print("added ", num, " xp, xp = ", ch.xp)
if ch.xp >= ch.next_xp:
level_up(ch)
else:
print("next at ", ch.next_xp)
func init_data():
for ci in range(24):
var cd : = new_candidate()
line[ci] = cd
team = {}
cheer_team = {}
print(line)
func dialogue(npc):
pass
var day_period = 0
var day = 1
func next_day():
day += 1
emit_signal("next_day")
func next_period():
day_period += 1
emit_signal("next_period")
if day_period == 4:
day_period = 0
next_day()
func action1():
print("action1")
var obj = null
var dstc = 0.0
for k in get_tree().get_nodes_in_group("act") + get_tree().get_nodes_in_group("npc"):
if obj == null:
obj = k
dstc = master_node.global_position.distance_squared_to(obj.global_position)
continue
var dst = master_node.global_position.distance_squared_to(k.global_position)
if dstc > dst:
obj = k
dstc = master_node.global_position.distance_squared_to(obj.global_position)
continue
if obj && dstc < 400.0:
print("action1 obj")
if obj.is_in_group("npc"):
dialogue(obj)
else:
obj.call_deferred("activate")
else:
print("action1 room")
emit_signal("room_event", "action1")

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

283
proto2/export_presets.cfg Normal file
View File

@@ -0,0 +1,283 @@
[preset.0]
name="linux"
platform="Linux/X11"
runnable=true
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path=""
patch_list=PoolStringArray( )
script_export_mode=1
script_encryption_key=""
[preset.0.options]
texture_format/bptc=false
texture_format/s3tc=true
texture_format/etc=false
texture_format/etc2=false
texture_format/no_bptc_fallbacks=true
binary_format/64_bits=true
binary_format/embed_pck=true
custom_template/release="../export-templates/godot.x11.opt.64"
custom_template/debug="../export-templates/godot.x11.opt.debug.64"
[preset.1]
name="Android"
platform="Android"
runnable=true
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path=""
patch_list=PoolStringArray( )
script_export_mode=1
script_encryption_key=""
[preset.1.options]
graphics/xr_mode=0
graphics/32_bits_framebuffer=true
one_click_deploy/clear_previous_install=true
custom_package/debug=""
custom_package/release=""
custom_package/use_custom_build=false
command_line/extra_args=""
version/code=1
version/name="1.0"
package/unique_name="org.godotengine.$genname"
package/name=""
package/signed=true
screen/immersive_mode=true
screen/orientation=0
screen/support_small=true
screen/support_normal=true
screen/support_large=true
screen/support_xlarge=true
screen/opengl_debug=false
launcher_icons/xxxhdpi_192x192=""
launcher_icons/xxhdpi_144x144=""
launcher_icons/xhdpi_96x96=""
launcher_icons/hdpi_72x72=""
launcher_icons/mdpi_48x48=""
keystore/debug=""
keystore/debug_user=""
keystore/debug_password=""
keystore/release=""
keystore/release_user=""
keystore/release_password=""
apk_expansion/enable=false
apk_expansion/SALT=""
apk_expansion/public_key=""
architectures/armeabi-v7a=true
architectures/arm64-v8a=true
architectures/x86=false
architectures/x86_64=false
permissions/custom_permissions=PoolStringArray( )
permissions/access_checkin_properties=false
permissions/access_coarse_location=false
permissions/access_fine_location=false
permissions/access_location_extra_commands=false
permissions/access_mock_location=false
permissions/access_network_state=false
permissions/access_surface_flinger=false
permissions/access_wifi_state=false
permissions/account_manager=false
permissions/add_voicemail=false
permissions/authenticate_accounts=false
permissions/battery_stats=false
permissions/bind_accessibility_service=false
permissions/bind_appwidget=false
permissions/bind_device_admin=false
permissions/bind_input_method=false
permissions/bind_nfc_service=false
permissions/bind_notification_listener_service=false
permissions/bind_print_service=false
permissions/bind_remoteviews=false
permissions/bind_text_service=false
permissions/bind_vpn_service=false
permissions/bind_wallpaper=false
permissions/bluetooth=false
permissions/bluetooth_admin=false
permissions/bluetooth_privileged=false
permissions/brick=false
permissions/broadcast_package_removed=false
permissions/broadcast_sms=false
permissions/broadcast_sticky=false
permissions/broadcast_wap_push=false
permissions/call_phone=false
permissions/call_privileged=false
permissions/camera=false
permissions/capture_audio_output=false
permissions/capture_secure_video_output=false
permissions/capture_video_output=false
permissions/change_component_enabled_state=false
permissions/change_configuration=false
permissions/change_network_state=false
permissions/change_wifi_multicast_state=false
permissions/change_wifi_state=false
permissions/clear_app_cache=false
permissions/clear_app_user_data=false
permissions/control_location_updates=false
permissions/delete_cache_files=false
permissions/delete_packages=false
permissions/device_power=false
permissions/diagnostic=false
permissions/disable_keyguard=false
permissions/dump=false
permissions/expand_status_bar=false
permissions/factory_test=false
permissions/flashlight=false
permissions/force_back=false
permissions/get_accounts=false
permissions/get_package_size=false
permissions/get_tasks=false
permissions/get_top_activity_info=false
permissions/global_search=false
permissions/hardware_test=false
permissions/inject_events=false
permissions/install_location_provider=false
permissions/install_packages=false
permissions/install_shortcut=false
permissions/internal_system_window=false
permissions/internet=false
permissions/kill_background_processes=false
permissions/location_hardware=false
permissions/manage_accounts=false
permissions/manage_app_tokens=false
permissions/manage_documents=false
permissions/master_clear=false
permissions/media_content_control=false
permissions/modify_audio_settings=false
permissions/modify_phone_state=false
permissions/mount_format_filesystems=false
permissions/mount_unmount_filesystems=false
permissions/nfc=false
permissions/persistent_activity=false
permissions/process_outgoing_calls=false
permissions/read_calendar=false
permissions/read_call_log=false
permissions/read_contacts=false
permissions/read_external_storage=false
permissions/read_frame_buffer=false
permissions/read_history_bookmarks=false
permissions/read_input_state=false
permissions/read_logs=false
permissions/read_phone_state=false
permissions/read_profile=false
permissions/read_sms=false
permissions/read_social_stream=false
permissions/read_sync_settings=false
permissions/read_sync_stats=false
permissions/read_user_dictionary=false
permissions/reboot=false
permissions/receive_boot_completed=false
permissions/receive_mms=false
permissions/receive_sms=false
permissions/receive_wap_push=false
permissions/record_audio=false
permissions/reorder_tasks=false
permissions/restart_packages=false
permissions/send_respond_via_message=false
permissions/send_sms=false
permissions/set_activity_watcher=false
permissions/set_alarm=false
permissions/set_always_finish=false
permissions/set_animation_scale=false
permissions/set_debug_app=false
permissions/set_orientation=false
permissions/set_pointer_speed=false
permissions/set_preferred_applications=false
permissions/set_process_limit=false
permissions/set_time=false
permissions/set_time_zone=false
permissions/set_wallpaper=false
permissions/set_wallpaper_hints=false
permissions/signal_persistent_processes=false
permissions/status_bar=false
permissions/subscribed_feeds_read=false
permissions/subscribed_feeds_write=false
permissions/system_alert_window=false
permissions/transmit_ir=false
permissions/uninstall_shortcut=false
permissions/update_device_stats=false
permissions/use_credentials=false
permissions/use_sip=false
permissions/vibrate=false
permissions/wake_lock=false
permissions/write_apn_settings=false
permissions/write_calendar=false
permissions/write_call_log=false
permissions/write_contacts=false
permissions/write_external_storage=false
permissions/write_gservices=false
permissions/write_history_bookmarks=false
permissions/write_profile=false
permissions/write_secure_settings=false
permissions/write_settings=false
permissions/write_sms=false
permissions/write_social_stream=false
permissions/write_sync_settings=false
permissions/write_user_dictionary=false
[preset.2]
name="HTML5"
platform="HTML5"
runnable=true
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path=""
patch_list=PoolStringArray( )
script_export_mode=1
script_encryption_key=""
[preset.2.options]
vram_texture_compression/for_desktop=true
vram_texture_compression/for_mobile=false
html/custom_html_shell=""
html/head_include=""
custom_template/release="../export-templates/godot.javascript.opt.zip"
custom_template/debug="../export-templates/godot.javascript.opt.debug.zip"
[preset.3]
name="windows"
platform="Windows Desktop"
runnable=true
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path=""
patch_list=PoolStringArray( )
script_export_mode=1
script_encryption_key=""
[preset.3.options]
texture_format/bptc=false
texture_format/s3tc=true
texture_format/etc=false
texture_format/etc2=false
texture_format/no_bptc_fallbacks=true
binary_format/64_bits=true
binary_format/embed_pck=true
custom_template/release="../export-templates/godot.windows.opt.64.exe"
custom_template/debug="../export-templates/godot.windows.debug.64.exe"
application/icon=""
application/file_version=""
application/product_version=""
application/company_name=""
application/product_name=""
application/file_description=""
application/copyright=""
application/trademarks=""

55
proto2/project.godot Normal file
View File

@@ -0,0 +1,55 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=4
_global_script_classes=[ {
"base": "Node",
"class": "BallGameAI",
"language": "GDScript",
"path": "res://ai/ball_game_ai.gd"
} ]
_global_script_class_icons={
"BallGameAI": ""
}
[application]
run/main_scene="res://ui/menu_root.tscn"
[autoload]
world="*res://autoloads/world.gd"
[input]
move_west={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"unicode":0,"echo":false,"script":null)
]
}
move_east={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":68,"unicode":0,"echo":false,"script":null)
]
}
move_north={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"unicode":0,"echo":false,"script":null)
]
}
move_south={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":83,"unicode":0,"echo":false,"script":null)
]
}
action1={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":69,"unicode":0,"echo":false,"script":null)
]
}

33
proto2/ui/menu_root.gd Normal file
View File

@@ -0,0 +1,33 @@
extends Control
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func start_game():
var sc = load("res://main.tscn")
world.init_data()
get_tree().change_scene_to(sc)
func load_game():
pass
func display_options():
var sc = load("res://ui/options.tscn")
get_tree().change_scene_to(sc)
func display_development():
var sc = load("res://ui/development_menu.tscn")
get_tree().change_scene_to(sc)
func quit_game():
get_tree().quit()
func _ready():
$VBoxContainer/exit.connect("pressed", self, "quit_game")
$VBoxContainer/start.connect("pressed", self, "start_game")
$"VBoxContainer/load".connect("pressed", self, "load_game")
$VBoxContainer/options.connect("pressed", self, "display_options")
$VBoxContainer/development.connect("pressed", self, "display_development")
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass

78
proto2/ui/menu_root.tscn Normal file
View File

@@ -0,0 +1,78 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://ui/menu_root.gd" type="Script" id=1]
[ext_resource path="res://fonts/DroidSansFallback.ttf" type="DynamicFontData" id=2]
[sub_resource type="DynamicFont" id=1]
size = 32
font_data = ExtResource( 2 )
[node name="menu_root" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="VBoxContainer" type="VBoxContainer" parent="."]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -512.0
margin_top = -125.5
margin_right = 512.0
margin_bottom = 125.5
__meta__ = {
"_edit_lock_": true
}
[node name="start" type="Button" parent="VBoxContainer"]
margin_right = 1024.0
margin_bottom = 49.0
custom_fonts/font = SubResource( 1 )
text = "Start"
__meta__ = {
"_edit_lock_": true
}
[node name="load" type="Button" parent="VBoxContainer"]
margin_top = 53.0
margin_right = 1024.0
margin_bottom = 102.0
custom_fonts/font = SubResource( 1 )
text = "Load"
__meta__ = {
"_edit_lock_": true
}
[node name="options" type="Button" parent="VBoxContainer"]
margin_top = 106.0
margin_right = 1024.0
margin_bottom = 155.0
custom_fonts/font = SubResource( 1 )
text = "Options"
__meta__ = {
"_edit_lock_": true
}
[node name="development" type="Button" parent="VBoxContainer"]
margin_top = 159.0
margin_right = 1024.0
margin_bottom = 208.0
custom_fonts/font = SubResource( 1 )
text = "Development"
__meta__ = {
"_edit_lock_": true
}
[node name="exit" type="Button" parent="VBoxContainer"]
margin_top = 212.0
margin_right = 1024.0
margin_bottom = 261.0
custom_fonts/font = SubResource( 1 )
text = "Exit"
__meta__ = {
"_edit_lock_": true
}

File diff suppressed because one or more lines are too long