commit 5ec0a52c2111ac261fbbbb74f98dbedc9b118dd9 Author: Simon Pirkelmann Date: Sat Nov 7 17:03:35 2020 +0100 initial commit diff --git a/dungeon.gd b/dungeon.gd new file mode 100644 index 0000000..abdd28b --- /dev/null +++ b/dungeon.gd @@ -0,0 +1,21 @@ +extends Node2D + + +# Declare member variables here. Examples: +# var a = 2 +var cmds = "" + + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass + + +func _on_TextEdit_text_changed(): + get_ + pass # Replace with function body. diff --git a/dungeon.tscn b/dungeon.tscn new file mode 100644 index 0000000..f846e25 --- /dev/null +++ b/dungeon.tscn @@ -0,0 +1,58 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://tileset.tres" type="TileSet" id=1] +[ext_resource path="res://troll.tscn" type="PackedScene" id=2] + +[node name="Dungeon" type="Node2D"] + +[node name="Floor" type="TileMap" parent="."] +mode = 1 +tile_set = ExtResource( 1 ) +cell_size = Vector2( 128, 64 ) +cell_tile_origin = 1 +centered_textures = true +format = 1 +tile_data = PoolIntArray( -917493, 0, 0, -917492, 0, 0, -917491, 0, 0, -917490, 0, 0, -851957, 0, 0, -851956, 0, 0, -851955, 0, 0, -851954, 0, 0, -786421, 0, 0, -786420, 1, 0, -786419, 0, -1200553578, -786418, 0, 0, -720885, 0, 0, -720884, 0, 0, -720883, 0, -1200553578, -720882, 0, 0, -655349, 0, 0, -655348, 1, 0, -655347, 0, -1200553578, -655346, 0, 0, -589813, 0, 0, -589812, 1, 0, -589811, 0, -1200553578, -589810, 0, 0, -524277, 0, 0, -524276, 0, 0, -524275, 1, -1200553578, -524274, 0, 0, -458747, 0, 0, -458746, 0, 0, -458745, 0, 0, -458744, 0, 0, -458743, 0, 0, -458742, 0, 0, -458741, 0, 0, -458740, 0, 0, -458739, 0, -1200553578, -458738, 0, 0, -393211, 0, 0, -393210, 0, 0, -393209, 0, 0, -393208, 0, 0, -393207, 0, 0, -393206, 0, 0, -393205, 0, 0, -393204, 0, 0, -393203, 0, -1200553578, -393202, 0, 0, -327675, 0, 0, -327674, 0, 0, -327673, 0, -1200553578, -327672, 1, -1200553578, -327671, 1, -1200553578, -327670, 1, 0, -327669, 1, 0, -327668, 1, 0, -327667, 0, -1200553578, -327666, 0, 0, -262139, 0, 0, -262138, 0, 0, -262137, 0, -1200553578, -262136, 0, -1200553578, -262135, 0, -1200553578, -262134, 0, -1200553578, -262133, 0, -1200553578, -262132, 0, -1200553578, -262131, 0, -1200553578, -262130, 0, 0, -196603, 0, 0, -196602, 0, 0, -196601, 0, -1200553578, -196600, 0, -1200553578, -196599, 0, 0, -196598, 0, 0, -196597, 0, 0, -196596, 0, 0, -196595, 0, 0, -196594, 0, 0, -131067, 0, 0, -131066, 0, 0, -131065, 0, -1200553578, -131064, 0, -1200553578, -131063, 0, 0, -65531, 0, 0, -65530, 0, 0, -65529, 0, -1200553578, -65528, 0, -1200553578, -65527, 0, 0, 5, 0, 0, 6, 0, 0, 7, 1, -1200553578, 8, 0, -1200553578, 9, 0, 0, 65541, 0, 0, 65542, 0, 0, 65543, 0, -1200553578, 65544, 0, -1200553578, 65545, 0, 0, 131077, 0, 0, 131078, 0, 0, 131079, 0, -1200553578, 131080, 0, -1200553578, 131081, 0, 0, 196613, 0, 0, 196614, 0, 0, 196615, 0, 0, 196616, 0, 0 ) + +[node name="Walls" type="TileMap" parent="."] +mode = 1 +tile_set = ExtResource( 1 ) +cell_size = Vector2( 128, 64 ) +cell_tile_origin = 1 +cell_y_sort = true +centered_textures = true +format = 1 +tile_data = PoolIntArray( -917493, 2, -1200553578, -917492, 2, -1200553578, -917491, 2, -1200553578, -917490, 2, -1200553578, -917489, 2, -1200553578, -851957, 2, -1200553578, -851956, 3, -1200553578, -851954, 3, -1200553578, -851953, 2, -1200553578, -786421, 2, -1200553578, -786420, 3, -1200553578, -786418, 3, -1200553578, -786417, 2, -1200553578, -720885, 2, -1200553578, -720881, 2, -1200553578, -655349, 2, -1200553578, -655348, 2, -1200553578, -655346, 3, -1200553578, -655345, 2, -1200553578, -589813, 2, -1200553578, -589809, 2, -1200553578, -524277, 2, -1200553578, -524273, 2, -1200553578, -458747, 2, -1200553578, -458746, 2, -1200553578, -458745, 2, -1200553578, -458744, 536870916, -1200553578, -458743, 536870916, -1200553578, -458742, 2, 0, -458741, 2, 0, -458740, 2, 0, -458738, 2, 0, -458737, 2, -1200553578, -393211, 2, -1200553578, -393209, 3, -1200553578, -393201, 2, -1200553578, -327675, 4, -1200553578, -327665, 2, -1200553578, -262139, 4, -1200553578, -262129, 2, -1200553578, -196603, 2, 0, -196601, 3, 0, -196593, 2, -1200553578, -131071, 0, 0, -131070, 0, 0, -131069, 0, 0, -131067, 2, 0, -131062, 2, -1200553578, -131061, 2, -1200553578, -131060, 2, -1200553578, -131059, 2, -1200553578, -131058, 2, -1200553578, -131057, 2, -1200553578, -65535, 0, 0, -65534, 0, 0, -65533, 0, 0, -65532, 0, 0, -65531, 2, 0, -65530, 2, 0, -65527, 2, -1200553578, -65526, 2, -1200553578, 1, 0, 0, 2, 0, 0, 3, 0, 0, 4, 0, 0, 5, 2, 0, 7, 0, 0, 10, 2, 0, 65537, 0, 0, 65538, 0, 0, 65539, 0, 0, 65540, 0, 0, 65541, 0, 0, 65542, 0, 0, 65543, 0, 0, 65544, 0, 0, 65546, 2, 0, 131073, 0, 0, 131074, 0, 0, 131075, 0, 0, 131076, 0, 0, 131077, 0, 0, 131078, 0, 0, 131079, 0, 0, 131080, 0, 0, 131081, 3, 0, 131082, 2, 0, 196612, 0, 0, 196613, 0, 0, 196614, 0, 0, 196615, 0, 0, 196616, 0, 0, 196618, 2, 0, 262149, 0, 0, 262150, 0, 0, 262151, 0, 0, 262152, 0, 0, 262153, 0, 0, 262154, 2, 0 ) + +[node name="Troll" parent="Walls" instance=ExtResource( 2 )] +position = Vector2( 200, 241.121 ) + +[node name="TextEdit" type="TextEdit" parent="Walls/Troll"] +margin_left = -208.157 +margin_top = -281.227 +margin_right = 91.8427 +margin_bottom = -79.227 +syntax_highlighting = true +show_line_numbers = true +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Button" type="Button" parent="."] +margin_left = 292.797 +margin_top = 219.432 +margin_right = 364.797 +margin_bottom = 239.432 +text = "Press me" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="LineEdit" type="LineEdit" parent="."] +margin_left = 529.797 +margin_top = -24.5685 +margin_right = 587.797 +margin_bottom = -0.568451 +[connection signal="text_changed" from="Walls/Troll/TextEdit" to="Walls/Troll" method="_on_TextEdit_text_changed"] +[connection signal="button_down" from="Button" to="Walls/Troll" method="_on_Button_button_down"] +[connection signal="text_entered" from="LineEdit" to="Walls/Troll" method="_on_LineEdit_text_entered"] diff --git a/harry.jpg.import b/harry.jpg.import new file mode 100644 index 0000000..a1fc8e6 --- /dev/null +++ b/harry.jpg.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/harry.jpg-6308a5720b28090cf5a34d0d2f53ab02.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://harry.jpg" +dest_files=[ "res://.import/harry.jpg-6308a5720b28090cf5a34d0d2f53ab02.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..7e4eea5 Binary files /dev/null and b/icon.png differ diff --git a/icon.png.import b/icon.png.import new file mode 100644 index 0000000..96cbf46 --- /dev/null +++ b/icon.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.png" +dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/isotiles.png b/isotiles.png new file mode 100644 index 0000000..c141cff Binary files /dev/null and b/isotiles.png differ diff --git a/isotiles.png.import b/isotiles.png.import new file mode 100644 index 0000000..787038e --- /dev/null +++ b/isotiles.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/isotiles.png-502434fe0d6c3fd8ce67cea5a960c208.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://isotiles.png" +dest_files=[ "res://.import/isotiles.png-502434fe0d6c3fd8ce67cea5a960c208.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..c043503 --- /dev/null +++ b/project.godot @@ -0,0 +1,82 @@ +; 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=[ ] +_global_script_class_icons={ + +} + +[application] + +config/name="Isometric Game" +config/description="This demo shows a traditional isometric view with depth sorting. + +A character can move around the level and will also slide around objects, +as well as be occluded when standing in front or behind them." +run/main_scene="res://dungeon.tscn" +config/icon="res://icon.png" + +[display] + +window/stretch/mode="2d" +window/stretch/aspect="expand" + +[gdnative] + +singletons=[ ] + +[image_loader] + +filter=false +gen_mipmaps=false + +[input] + +move_down={ +"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":16777234,"unicode":0,"echo":false,"script":null) +, 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) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":13,"pressure":0.0,"pressed":false,"script":null) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":1.0,"script":null) + ] +} +move_left={ +"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":16777231,"unicode":0,"echo":false,"script":null) +, 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) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":14,"pressure":0.0,"pressed":false,"script":null) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":-1.0,"script":null) + ] +} +move_right={ +"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":16777233,"unicode":0,"echo":false,"script":null) +, 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) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":15,"pressure":0.0,"pressed":false,"script":null) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":1.0,"script":null) + ] +} +move_up={ +"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":16777232,"unicode":0,"echo":false,"script":null) +, 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) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":12,"pressure":0.0,"pressed":false,"script":null) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":-1.0,"script":null) + ] +} + +[rasterizer] + +use_pixel_snap=true + +[rendering] + +quality/driver/driver_name="GLES2" +environment/default_clear_color=Color( 0.0784314, 0.105882, 0.145098, 1 ) diff --git a/robot_brain.py b/robot_brain.py new file mode 100644 index 0000000..4d847fb --- /dev/null +++ b/robot_brain.py @@ -0,0 +1,25 @@ +import sys + +cmds = [] +def forward(n=1): + for i in range(n): + cmds.append('forward') + +print(sys.argv) +user_code = sys.argv[1].replace('\\n', '\n') +#print("user code lines: \n", user_code_lines) +#user_code = "\n".join(user_code_lines) +print("user code: \n" + user_code) +arguments = sys.argv[2].replace('\\n', '\n') + +user_script_wrapper = ''' +{0} # user cmds are filled in here +''' + +try: + new_script = user_script_wrapper.format(user_code, arguments) + print("calling exec() on: \n", new_script) + exec(new_script) + print("OUTPUT: ", cmds) # -> output from this print will be read in godot +except Exception as e: + print("FAIL: {0}".format(e)) diff --git a/tileset.tres b/tileset.tres new file mode 100644 index 0000000..99d1279 --- /dev/null +++ b/tileset.tres @@ -0,0 +1,105 @@ +[gd_resource type="TileSet" load_steps=5 format=2] + +[ext_resource path="res://isotiles.png" type="Texture" id=1] + +[sub_resource type="ConvexPolygonShape2D" id=1] +points = PoolVector2Array( 0, -32, 64, 0, 0, 32, -64, 0 ) + +[sub_resource type="ConvexPolygonShape2D" id=2] +points = PoolVector2Array( -24, -12, -10, -22, 10, -22, 24, -12, 24, 2, 10, 12, -10, 12, -24, 2 ) + +[sub_resource type="ConvexPolygonShape2D" id=3] +points = PoolVector2Array( -40, 16, 24, -16, 40, -8, -24, 24 ) + +[resource] +0/name = "Base" +0/texture = ExtResource( 1 ) +0/tex_offset = Vector2( 0, 0 ) +0/modulate = Color( 1, 1, 1, 1 ) +0/region = Rect2( 28, 75, 135, 105 ) +0/tile_mode = 0 +0/occluder_offset = Vector2( 67.5, 52.5 ) +0/navigation_offset = Vector2( 67.5, 52.5 ) +0/shape_offset = Vector2( 0, 0 ) +0/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) +0/shape_one_way = false +0/shape_one_way_margin = 0.0 +0/shapes = [ ] +0/z_index = 0 +1/name = "Base2" +1/texture = ExtResource( 1 ) +1/tex_offset = Vector2( 0, 0 ) +1/modulate = Color( 1, 1, 1, 1 ) +1/region = Rect2( 221, 75, 135, 105 ) +1/tile_mode = 0 +1/occluder_offset = Vector2( 67.5, 52.5 ) +1/navigation_offset = Vector2( 67.5, 52.5 ) +1/shape_offset = Vector2( 0, 0 ) +1/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 ) +1/shape_one_way = false +1/shape_one_way_margin = 0.0 +1/shapes = [ ] +1/z_index = 0 +2/name = "Wall" +2/texture = ExtResource( 1 ) +2/tex_offset = Vector2( 0, -32 ) +2/modulate = Color( 1, 1, 1, 1 ) +2/region = Rect2( 28, 220, 140, 140 ) +2/tile_mode = 0 +2/occluder_offset = Vector2( 70, 70 ) +2/navigation_offset = Vector2( 70, 70 ) +2/shape_offset = Vector2( 70, 70 ) +2/shape_transform = Transform2D( 1, 0, 0, 1, 70, 70 ) +2/shape = SubResource( 1 ) +2/shape_one_way = false +2/shape_one_way_margin = 1.0 +2/shapes = [ { +"autotile_coord": Vector2( 0, 0 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 1 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 70, 70 ) +} ] +2/z_index = 0 +3/name = "Column" +3/texture = ExtResource( 1 ) +3/tex_offset = Vector2( 0, -32 ) +3/modulate = Color( 1, 1, 1, 1 ) +3/region = Rect2( 259, 241, 55, 95 ) +3/tile_mode = 0 +3/occluder_offset = Vector2( 27.5, 47.5 ) +3/navigation_offset = Vector2( 27.5, 47.5 ) +3/shape_offset = Vector2( 29.5, 47.5 ) +3/shape_transform = Transform2D( 1, 0, 0, 1, 29.5, 47.5 ) +3/shape = SubResource( 2 ) +3/shape_one_way = false +3/shape_one_way_margin = 1.0 +3/shapes = [ { +"autotile_coord": Vector2( 0, 0 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 2 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 29.5, 47.5 ) +} ] +3/z_index = 0 +4/name = "Door1" +4/texture = ExtResource( 1 ) +4/tex_offset = Vector2( 0, -25 ) +4/modulate = Color( 1, 1, 1, 1 ) +4/region = Rect2( 54, 426, 85, 110 ) +4/tile_mode = 0 +4/occluder_offset = Vector2( 42.5, 55 ) +4/navigation_offset = Vector2( 42.5, 55 ) +4/shape_offset = Vector2( 42.5, 55 ) +4/shape_transform = Transform2D( 1, 0, 0, 1, 42.5, 55 ) +4/shape = SubResource( 3 ) +4/shape_one_way = false +4/shape_one_way_margin = 1.0 +4/shapes = [ { +"autotile_coord": Vector2( 0, 0 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 3 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 42.5, 55 ) +} ] +4/z_index = 0 diff --git a/tileset_edit.tscn b/tileset_edit.tscn new file mode 100644 index 0000000..8dd5199 --- /dev/null +++ b/tileset_edit.tscn @@ -0,0 +1,53 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://isotiles.png" type="Texture" id=1] + +[node name="TilesetEdit" type="Node2D"] + +[node name="Base" type="Sprite" parent="."] +texture = ExtResource( 1 ) +region_enabled = true +region_rect = Rect2( 28, 75, 135, 105 ) + +[node name="Base2" type="Sprite" parent="."] +position = Vector2( 200, 0 ) +texture = ExtResource( 1 ) +region_enabled = true +region_rect = Rect2( 221, 75, 135, 105 ) + +[node name="Wall" type="Sprite" parent="."] +position = Vector2( 400, 0 ) +texture = ExtResource( 1 ) +offset = Vector2( 0, -32 ) +region_enabled = true +region_rect = Rect2( 28, 220, 140, 140 ) + +[node name="StaticBody2D" type="StaticBody2D" parent="Wall"] + +[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Wall/StaticBody2D"] +polygon = PoolVector2Array( -64, 0, 0, 32, 64, 0, 0, -32 ) + +[node name="Column" type="Sprite" parent="."] +position = Vector2( 600, 0 ) +texture = ExtResource( 1 ) +offset = Vector2( 0, -32 ) +region_enabled = true +region_rect = Rect2( 259, 241, 55, 95 ) + +[node name="StaticBody2D" type="StaticBody2D" parent="Column"] + +[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Column/StaticBody2D"] +position = Vector2( 2, 0 ) +polygon = PoolVector2Array( -24, 2, -10, 12, 10, 12, 24, 2, 24, -12, 10, -22, -10, -22, -24, -12 ) + +[node name="Door1" type="Sprite" parent="."] +position = Vector2( 800, 0 ) +texture = ExtResource( 1 ) +offset = Vector2( 0, -25 ) +region_enabled = true +region_rect = Rect2( 54, 426, 85, 110 ) + +[node name="StaticBody2D" type="StaticBody2D" parent="Door1"] + +[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Door1/StaticBody2D"] +polygon = PoolVector2Array( -24, 24, 40, -8, 24, -16, -40, 16 ) diff --git a/troll.gd b/troll.gd new file mode 100644 index 0000000..99918b4 --- /dev/null +++ b/troll.gd @@ -0,0 +1,32 @@ +extends KinematicBody2D + +const MOTION_SPEED = 160 # Pixels/second. + +var text = "" + +func _physics_process(_delta): + var motion = Vector2() + motion.x = Input.get_action_strength("move_right") - Input.get_action_strength("move_left") + motion.y = Input.get_action_strength("move_down") - Input.get_action_strength("move_up") + motion.y /= 2 + motion = motion.normalized() * MOTION_SPEED + #warning-ignore:return_value_discarded + move_and_slide(motion) + + +func _on_Button_button_down(): + # read textbox + # -> f (state) -> cmd + var cmds = $TextEdit.text + var params = "[]" + + # call python script for executing user input + var output = [] + var exit_code = OS.execute("python", ["robot_brain.py", cmds, params], true, output) + + var response_index = output[0].find('OUTPUT') + 7 + var response = output[0].right(response_index) + print(response) + var response_array = response.rsplit(',') + print(len(response_array)) + print(response_array) diff --git a/troll.png b/troll.png new file mode 100644 index 0000000..a0b5ae1 Binary files /dev/null and b/troll.png differ diff --git a/troll.png.import b/troll.png.import new file mode 100644 index 0000000..3029f67 --- /dev/null +++ b/troll.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/troll.png-78efc50bfccaa17f54d40cfea3eef5f5.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://troll.png" +dest_files=[ "res://.import/troll.png-78efc50bfccaa17f54d40cfea3eef5f5.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/troll.tscn b/troll.tscn new file mode 100644 index 0000000..a7ccb88 --- /dev/null +++ b/troll.tscn @@ -0,0 +1,20 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://troll.gd" type="Script" id=1] +[ext_resource path="res://troll.png" type="Texture" id=2] + +[sub_resource type="CircleShape2D" id=1] +radius = 16.0 + +[node name="Troll" type="KinematicBody2D"] +script = ExtResource( 1 ) + +[node name="Sprite" type="Sprite" parent="."] +position = Vector2( -4, -28 ) +texture = ExtResource( 2 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource( 1 ) + +[node name="Camera2D" type="Camera2D" parent="."] +current = true