diff --git a/src/actors/player.gd b/src/actors/player.gd index 95f8eed..e8c7f72 100644 --- a/src/actors/player.gd +++ b/src/actors/player.gd @@ -1,18 +1,84 @@ extends Node2D +"""######################################## + VARIABLES +########################################""" # Declare member variables here. -enum gender_enum {BOY, GIRL} -enum team_enum {RED, BLACK} +enum gender_e {BOY=0, GIRL=1} +enum team_e {RED=0, BLACK=1} -onready var gender = null +var velocity = Vector2.ZERO +var speed = 500 +var gender = null +var team = null +var flip_h = false +var current_animation = "idle" + +"""######################################## + INIT +########################################""" + +func _init(): + self.gender = gender_e.BOY + self.team = team_e.BLACK + + +func init_animated_sprite(): + for sprite in $Sprites.get_children(): + var sprite_as = sprite as AnimatedSprite + sprite_as.hide() + get_sprite_node().show() + # Called when the node enters the scene tree for the first time. func _ready(): - pass # Replace with function body. + init_animated_sprite() +"""######################################## + PROCESS +########################################""" # Called every frame. 'delta' is the elapsed time since the previous frame. -#func _process(delta): -# pass +func _process(delta): + run() + animate() + position += velocity * delta + + +func run(): + var player_input_x = Input.get_action_strength("right") - Input.get_action_strength("left") + var player_input_y = Input.get_action_strength("down") - Input.get_action_strength("up") + velocity.x = player_input_x + velocity.y = player_input_y + velocity = velocity.normalized() * speed + + +"""######################################## + ANIMATIONS +########################################""" + + +func animate(): + current_animation = get_animation() + var node = str(self.gender) + '_' + str(self.team) + var animated_node = get_sprite_node() + animated_node.animation = get_animation() + animated_node.flip_h = flip_h + if abs(velocity.x) > 0: + flip_h = velocity.x < 0 + + +func get_sprite_node(): + if gender == gender_e.BOY and team == team_e.RED: return $Sprites/BoyRed + if gender == gender_e.BOY and team == team_e.BLACK: return $Sprites/BoyBlack + if gender == gender_e.GIRL and team == team_e.RED: return $Sprites/GirlRed + if gender == gender_e.GIRL and team == team_e.BLACK: return $Sprites/GirlBlack + print("No animation defined") + assert(false) + +func get_animation(): + if abs(velocity.x) > 0 || abs(velocity.y) > 0: + return "run" + return "idle" diff --git a/src/actors/player.tscn b/src/actors/player.tscn index 6e74209..91d73c0 100644 --- a/src/actors/player.tscn +++ b/src/actors/player.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=76 format=2] +[gd_scene load_steps=79 format=2] [ext_resource path="res://src/actors/player.gd" type="Script" id=1] [ext_resource path="res://assets/player/idle/girl-red-idle.png" type="Texture" id=2] @@ -10,320 +10,359 @@ [ext_resource path="res://assets/player/idle/boy-red-idle.png" type="Texture" id=8] [ext_resource path="res://assets/player/idle/girl-black-idle.png" type="Texture" id=9] +[sub_resource type="AtlasTexture" id=11] +atlas = ExtResource( 8 ) +region = Rect2( 0, 0, 12, 15 ) + +[sub_resource type="AtlasTexture" id=12] +atlas = ExtResource( 8 ) +region = Rect2( 12, 0, 12, 15 ) + +[sub_resource type="AtlasTexture" id=13] +atlas = ExtResource( 8 ) +region = Rect2( 24, 0, 12, 15 ) + +[sub_resource type="AtlasTexture" id=14] +atlas = ExtResource( 8 ) +region = Rect2( 36, 0, 12, 15 ) + +[sub_resource type="AtlasTexture" id=15] +atlas = ExtResource( 8 ) +region = Rect2( 48, 0, 12, 15 ) + +[sub_resource type="AtlasTexture" id=16] +atlas = ExtResource( 8 ) +region = Rect2( 60, 0, 12, 15 ) + [sub_resource type="AtlasTexture" id=1] -atlas = ExtResource( 6 ) +atlas = ExtResource( 7 ) region = Rect2( 0, 0, 12, 15 ) [sub_resource type="AtlasTexture" id=2] -atlas = ExtResource( 6 ) +atlas = ExtResource( 7 ) region = Rect2( 12, 0, 12, 15 ) [sub_resource type="AtlasTexture" id=3] -atlas = ExtResource( 6 ) +atlas = ExtResource( 7 ) region = Rect2( 24, 0, 12, 15 ) [sub_resource type="AtlasTexture" id=4] -atlas = ExtResource( 6 ) +atlas = ExtResource( 7 ) region = Rect2( 36, 0, 12, 15 ) [sub_resource type="AtlasTexture" id=5] -atlas = ExtResource( 6 ) +atlas = ExtResource( 7 ) region = Rect2( 48, 0, 12, 15 ) [sub_resource type="AtlasTexture" id=6] -atlas = ExtResource( 6 ) +atlas = ExtResource( 7 ) region = Rect2( 60, 0, 12, 15 ) [sub_resource type="AtlasTexture" id=7] -atlas = ExtResource( 6 ) +atlas = ExtResource( 7 ) region = Rect2( 72, 0, 12, 15 ) [sub_resource type="AtlasTexture" id=8] -atlas = ExtResource( 6 ) +atlas = ExtResource( 7 ) region = Rect2( 84, 0, 12, 15 ) [sub_resource type="AtlasTexture" id=9] -atlas = ExtResource( 6 ) +atlas = ExtResource( 7 ) region = Rect2( 96, 0, 12, 15 ) [sub_resource type="AtlasTexture" id=10] -atlas = ExtResource( 6 ) +atlas = ExtResource( 7 ) region = Rect2( 108, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=11] -atlas = ExtResource( 9 ) +[sub_resource type="SpriteFrames" id=17] +animations = [ { +"frames": [ SubResource( 11 ), SubResource( 12 ), SubResource( 13 ), SubResource( 14 ), SubResource( 15 ), SubResource( 16 ) ], +"loop": true, +"name": "idle", +"speed": 5.0 +}, { +"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ), SubResource( 7 ), SubResource( 8 ), SubResource( 9 ), SubResource( 10 ) ], +"loop": true, +"name": "run", +"speed": 15.0 +} ] + +[sub_resource type="AtlasTexture" id=18] +atlas = ExtResource( 4 ) region = Rect2( 0, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=12] -atlas = ExtResource( 9 ) +[sub_resource type="AtlasTexture" id=19] +atlas = ExtResource( 4 ) region = Rect2( 12, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=13] -atlas = ExtResource( 9 ) +[sub_resource type="AtlasTexture" id=20] +atlas = ExtResource( 4 ) region = Rect2( 24, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=14] -atlas = ExtResource( 9 ) +[sub_resource type="AtlasTexture" id=21] +atlas = ExtResource( 4 ) region = Rect2( 36, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=15] -atlas = ExtResource( 9 ) +[sub_resource type="AtlasTexture" id=22] +atlas = ExtResource( 4 ) region = Rect2( 48, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=16] -atlas = ExtResource( 9 ) +[sub_resource type="AtlasTexture" id=23] +atlas = ExtResource( 4 ) region = Rect2( 60, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=17] +[sub_resource type="AtlasTexture" id=24] atlas = ExtResource( 5 ) region = Rect2( 0, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=18] +[sub_resource type="AtlasTexture" id=25] atlas = ExtResource( 5 ) region = Rect2( 12, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=19] +[sub_resource type="AtlasTexture" id=26] atlas = ExtResource( 5 ) region = Rect2( 24, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=20] +[sub_resource type="AtlasTexture" id=27] atlas = ExtResource( 5 ) region = Rect2( 36, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=21] +[sub_resource type="AtlasTexture" id=28] atlas = ExtResource( 5 ) region = Rect2( 48, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=22] +[sub_resource type="AtlasTexture" id=29] atlas = ExtResource( 5 ) region = Rect2( 60, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=23] +[sub_resource type="AtlasTexture" id=30] atlas = ExtResource( 5 ) region = Rect2( 72, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=24] +[sub_resource type="AtlasTexture" id=31] atlas = ExtResource( 5 ) region = Rect2( 84, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=25] +[sub_resource type="AtlasTexture" id=32] atlas = ExtResource( 5 ) region = Rect2( 96, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=26] +[sub_resource type="AtlasTexture" id=33] atlas = ExtResource( 5 ) region = Rect2( 108, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=27] -atlas = ExtResource( 4 ) -region = Rect2( 0, 0, 12, 15 ) - -[sub_resource type="AtlasTexture" id=28] -atlas = ExtResource( 4 ) -region = Rect2( 12, 0, 12, 15 ) - -[sub_resource type="AtlasTexture" id=29] -atlas = ExtResource( 4 ) -region = Rect2( 24, 0, 12, 15 ) - -[sub_resource type="AtlasTexture" id=30] -atlas = ExtResource( 4 ) -region = Rect2( 36, 0, 12, 15 ) - -[sub_resource type="AtlasTexture" id=31] -atlas = ExtResource( 4 ) -region = Rect2( 48, 0, 12, 15 ) - -[sub_resource type="AtlasTexture" id=32] -atlas = ExtResource( 4 ) -region = Rect2( 60, 0, 12, 15 ) +[sub_resource type="SpriteFrames" id=34] +animations = [ { +"frames": [ SubResource( 18 ), SubResource( 19 ), SubResource( 20 ), SubResource( 21 ), SubResource( 22 ), SubResource( 23 ) ], +"loop": true, +"name": "idle", +"speed": 5.0 +}, { +"frames": [ SubResource( 24 ), SubResource( 25 ), SubResource( 26 ), SubResource( 27 ), SubResource( 28 ), SubResource( 29 ), SubResource( 30 ), SubResource( 31 ), SubResource( 32 ), SubResource( 33 ) ], +"loop": true, +"name": "run", +"speed": 15.0 +} ] -[sub_resource type="AtlasTexture" id=33] +[sub_resource type="AtlasTexture" id=35] atlas = ExtResource( 2 ) region = Rect2( 0, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=34] +[sub_resource type="AtlasTexture" id=36] atlas = ExtResource( 2 ) region = Rect2( 12, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=35] +[sub_resource type="AtlasTexture" id=37] atlas = ExtResource( 2 ) region = Rect2( 24, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=36] +[sub_resource type="AtlasTexture" id=38] atlas = ExtResource( 2 ) region = Rect2( 36, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=37] +[sub_resource type="AtlasTexture" id=39] atlas = ExtResource( 2 ) region = Rect2( 48, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=38] +[sub_resource type="AtlasTexture" id=40] atlas = ExtResource( 2 ) region = Rect2( 60, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=39] -atlas = ExtResource( 8 ) -region = Rect2( 0, 0, 12, 15 ) - -[sub_resource type="AtlasTexture" id=40] -atlas = ExtResource( 8 ) -region = Rect2( 12, 0, 12, 15 ) - [sub_resource type="AtlasTexture" id=41] -atlas = ExtResource( 8 ) -region = Rect2( 24, 0, 12, 15 ) - -[sub_resource type="AtlasTexture" id=42] -atlas = ExtResource( 8 ) -region = Rect2( 36, 0, 12, 15 ) - -[sub_resource type="AtlasTexture" id=43] -atlas = ExtResource( 8 ) -region = Rect2( 48, 0, 12, 15 ) - -[sub_resource type="AtlasTexture" id=44] -atlas = ExtResource( 8 ) -region = Rect2( 60, 0, 12, 15 ) - -[sub_resource type="AtlasTexture" id=45] atlas = ExtResource( 3 ) region = Rect2( 0, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=46] +[sub_resource type="AtlasTexture" id=42] atlas = ExtResource( 3 ) region = Rect2( 12, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=47] +[sub_resource type="AtlasTexture" id=43] atlas = ExtResource( 3 ) region = Rect2( 24, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=48] +[sub_resource type="AtlasTexture" id=44] atlas = ExtResource( 3 ) region = Rect2( 36, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=49] +[sub_resource type="AtlasTexture" id=45] atlas = ExtResource( 3 ) region = Rect2( 48, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=50] +[sub_resource type="AtlasTexture" id=46] atlas = ExtResource( 3 ) region = Rect2( 60, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=51] +[sub_resource type="AtlasTexture" id=47] atlas = ExtResource( 3 ) region = Rect2( 72, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=52] +[sub_resource type="AtlasTexture" id=48] atlas = ExtResource( 3 ) region = Rect2( 84, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=53] +[sub_resource type="AtlasTexture" id=49] atlas = ExtResource( 3 ) region = Rect2( 96, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=54] +[sub_resource type="AtlasTexture" id=50] atlas = ExtResource( 3 ) region = Rect2( 108, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=55] -atlas = ExtResource( 7 ) +[sub_resource type="SpriteFrames" id=51] +animations = [ { +"frames": [ SubResource( 35 ), SubResource( 36 ), SubResource( 37 ), SubResource( 38 ), SubResource( 39 ), SubResource( 40 ) ], +"loop": true, +"name": "idle", +"speed": 5.0 +}, { +"frames": [ SubResource( 41 ), SubResource( 42 ), SubResource( 43 ), SubResource( 44 ), SubResource( 45 ), SubResource( 46 ), SubResource( 47 ), SubResource( 48 ), SubResource( 49 ), SubResource( 50 ) ], +"loop": true, +"name": "run", +"speed": 15.0 +} ] + +[sub_resource type="AtlasTexture" id=62] +atlas = ExtResource( 9 ) region = Rect2( 0, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=56] -atlas = ExtResource( 7 ) +[sub_resource type="AtlasTexture" id=63] +atlas = ExtResource( 9 ) region = Rect2( 12, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=57] -atlas = ExtResource( 7 ) +[sub_resource type="AtlasTexture" id=64] +atlas = ExtResource( 9 ) region = Rect2( 24, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=58] -atlas = ExtResource( 7 ) +[sub_resource type="AtlasTexture" id=65] +atlas = ExtResource( 9 ) region = Rect2( 36, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=59] -atlas = ExtResource( 7 ) +[sub_resource type="AtlasTexture" id=66] +atlas = ExtResource( 9 ) region = Rect2( 48, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=60] -atlas = ExtResource( 7 ) +[sub_resource type="AtlasTexture" id=67] +atlas = ExtResource( 9 ) region = Rect2( 60, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=61] -atlas = ExtResource( 7 ) +[sub_resource type="AtlasTexture" id=52] +atlas = ExtResource( 6 ) +region = Rect2( 0, 0, 12, 15 ) + +[sub_resource type="AtlasTexture" id=53] +atlas = ExtResource( 6 ) +region = Rect2( 12, 0, 12, 15 ) + +[sub_resource type="AtlasTexture" id=54] +atlas = ExtResource( 6 ) +region = Rect2( 24, 0, 12, 15 ) + +[sub_resource type="AtlasTexture" id=55] +atlas = ExtResource( 6 ) +region = Rect2( 36, 0, 12, 15 ) + +[sub_resource type="AtlasTexture" id=56] +atlas = ExtResource( 6 ) +region = Rect2( 48, 0, 12, 15 ) + +[sub_resource type="AtlasTexture" id=57] +atlas = ExtResource( 6 ) +region = Rect2( 60, 0, 12, 15 ) + +[sub_resource type="AtlasTexture" id=58] +atlas = ExtResource( 6 ) region = Rect2( 72, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=62] -atlas = ExtResource( 7 ) +[sub_resource type="AtlasTexture" id=59] +atlas = ExtResource( 6 ) region = Rect2( 84, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=63] -atlas = ExtResource( 7 ) +[sub_resource type="AtlasTexture" id=60] +atlas = ExtResource( 6 ) region = Rect2( 96, 0, 12, 15 ) -[sub_resource type="AtlasTexture" id=64] -atlas = ExtResource( 7 ) +[sub_resource type="AtlasTexture" id=61] +atlas = ExtResource( 6 ) region = Rect2( 108, 0, 12, 15 ) -[sub_resource type="SpriteFrames" id=65] +[sub_resource type="SpriteFrames" id=68] animations = [ { -"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ), SubResource( 7 ), SubResource( 8 ), SubResource( 9 ), SubResource( 10 ) ], -"loop": true, -"name": "girl_black_run", -"speed": 15.0 -}, { -"frames": [ SubResource( 11 ), SubResource( 12 ), SubResource( 13 ), SubResource( 14 ), SubResource( 15 ), SubResource( 16 ) ], -"loop": true, -"name": "girl_black_idle", -"speed": 5.0 -}, { -"frames": [ SubResource( 17 ), SubResource( 18 ), SubResource( 19 ), SubResource( 20 ), SubResource( 21 ), SubResource( 22 ), SubResource( 23 ), SubResource( 24 ), SubResource( 25 ), SubResource( 26 ) ], -"loop": true, -"name": "boy_black_run", -"speed": 15.0 -}, { -"frames": [ SubResource( 27 ), SubResource( 28 ), SubResource( 29 ), SubResource( 30 ), SubResource( 31 ), SubResource( 32 ) ], -"loop": true, -"name": "boy_black_idle", -"speed": 5.0 -}, { -"frames": [ SubResource( 33 ), SubResource( 34 ), SubResource( 35 ), SubResource( 36 ), SubResource( 37 ), SubResource( 38 ) ], +"frames": [ SubResource( 62 ), SubResource( 63 ), SubResource( 64 ), SubResource( 65 ), SubResource( 66 ), SubResource( 67 ) ], "loop": true, -"name": "girl_red_idle", +"name": "idle", "speed": 5.0 }, { -"frames": [ SubResource( 39 ), SubResource( 40 ), SubResource( 41 ), SubResource( 42 ), SubResource( 43 ), SubResource( 44 ) ], +"frames": [ SubResource( 52 ), SubResource( 53 ), SubResource( 54 ), SubResource( 55 ), SubResource( 56 ), SubResource( 57 ), SubResource( 58 ), SubResource( 59 ), SubResource( 60 ), SubResource( 61 ) ], "loop": true, -"name": "boy_red_idle", -"speed": 5.0 -}, { -"frames": [ SubResource( 45 ), SubResource( 46 ), SubResource( 47 ), SubResource( 48 ), SubResource( 49 ), SubResource( 50 ), SubResource( 51 ), SubResource( 52 ), SubResource( 53 ), SubResource( 54 ) ], -"loop": true, -"name": "girl_red_run", -"speed": 15.0 -}, { -"frames": [ SubResource( 55 ), SubResource( 56 ), SubResource( 57 ), SubResource( 58 ), SubResource( 59 ), SubResource( 60 ), SubResource( 61 ), SubResource( 62 ), SubResource( 63 ), SubResource( 64 ) ], -"loop": true, -"name": "boy_red_run", +"name": "run", "speed": 15.0 } ] -[sub_resource type="RectangleShape2D" id=66] -extents = Vector2( 60, 80 ) +[sub_resource type="RectangleShape2D" id=69] +extents = Vector2( 6, 0.5 ) [node name="Player" type="Node2D"] -position = Vector2( 0.657692, -80.0397 ) +position = Vector2( 0, -80 ) +scale = Vector2( 10, 10 ) script = ExtResource( 1 ) -[node name="AnimatedSprite" type="AnimatedSprite" parent="."] -scale = Vector2( 10, 10 ) -frames = SubResource( 65 ) -animation = "boy_black_run" +[node name="Sprites" type="Node2D" parent="."] + +[node name="BoyRed" type="AnimatedSprite" parent="Sprites"] +frames = SubResource( 17 ) +animation = "idle" frame = 2 playing = true +[node name="BoyBlack" type="AnimatedSprite" parent="Sprites"] +visible = false +frames = SubResource( 34 ) +animation = "run" +frame = 6 +playing = true + +[node name="GirlRed" type="AnimatedSprite" parent="Sprites"] +visible = false +frames = SubResource( 51 ) +animation = "run" +frame = 6 +playing = true + +[node name="GirlBlack" type="AnimatedSprite" parent="Sprites"] +visible = false +frames = SubResource( 68 ) +animation = "run" +frame = 9 +playing = true + [node name="KinematicBody2D" type="KinematicBody2D" parent="."] +position = Vector2( 0, 7.5 ) [node name="CollisionShape2D" type="CollisionShape2D" parent="KinematicBody2D"] -shape = SubResource( 66 ) +shape = SubResource( 69 ) + +[node name="Camera2D" type="Camera2D" parent="."] +current = true +smoothing_enabled = true +smoothing_speed = 10.0 +editor_draw_screen = false diff --git a/src/levels/demo.tscn b/src/levels/demo.tscn index 938c5af..3d1ef82 100644 --- a/src/levels/demo.tscn +++ b/src/levels/demo.tscn @@ -1,8 +1,61 @@ -[gd_scene load_steps=2 format=2] +[gd_scene load_steps=6 format=2] [ext_resource path="res://src/actors/player.tscn" type="PackedScene" id=1] +[ext_resource path="res://assets/world/base/path/path.png" type="Texture" id=2] +[ext_resource path="res://src/levels/map.gd" type="Script" id=3] +[ext_resource path="res://src/ui/HUD.tscn" type="PackedScene" id=4] -[node name="Node2D" type="Node2D"] +[sub_resource type="TileSet" id=1] +0/name = "path.png 0" +0/texture = ExtResource( 2 ) +0/tex_offset = Vector2( 0, 0 ) +0/modulate = Color( 1, 1, 1, 1 ) +0/region = Rect2( 0, 0, 156, 52 ) +0/tile_mode = 1 +0/autotile/bitmask_mode = 1 +0/autotile/bitmask_flags = [ Vector2( 0, 0 ), 144, Vector2( 0, 1 ), 146, Vector2( 0, 2 ), 18, Vector2( 0, 3 ), 48, Vector2( 1, 0 ), 176, Vector2( 1, 1 ), 178, Vector2( 1, 2 ), 50, Vector2( 1, 3 ), 56, Vector2( 2, 0 ), 184, Vector2( 2, 1 ), 186, Vector2( 2, 2 ), 58, Vector2( 2, 3 ), 24, Vector2( 3, 0 ), 152, Vector2( 3, 1 ), 154, Vector2( 3, 2 ), 26, Vector2( 3, 3 ), 16, Vector2( 4, 0 ), 187, Vector2( 4, 1 ), 434, Vector2( 4, 2 ), 182, Vector2( 4, 3 ), 250, Vector2( 5, 0 ), 440, Vector2( 5, 1 ), 510, Vector2( 5, 2 ), 447, Vector2( 5, 3 ), 62, Vector2( 6, 0 ), 248, Vector2( 6, 1 ), 507, Vector2( 6, 2 ), 255, Vector2( 6, 3 ), 59, Vector2( 7, 0 ), 190, Vector2( 7, 1 ), 218, Vector2( 7, 2 ), 155, Vector2( 7, 3 ), 442, Vector2( 8, 0 ), 432, Vector2( 8, 1 ), 438, Vector2( 8, 2 ), 446, Vector2( 8, 3 ), 54, Vector2( 9, 0 ), 506, Vector2( 9, 2 ), 443, Vector2( 9, 3 ), 63, Vector2( 10, 0 ), 504, Vector2( 10, 1 ), 511, Vector2( 10, 2 ), 254, Vector2( 10, 3 ), 191, Vector2( 11, 0 ), 216, Vector2( 11, 1 ), 219, Vector2( 11, 2 ), 251, Vector2( 11, 3 ), 27 ] +0/autotile/icon_coordinate = Vector2( 3, 3 ) +0/autotile/tile_size = Vector2( 13, 13 ) +0/autotile/spacing = 0 +0/autotile/occluder_map = [ ] +0/autotile/navpoly_map = [ ] +0/autotile/priority_map = [ ] +0/autotile/z_index_map = [ ] +0/occluder_offset = Vector2( 0, 0 ) +0/navigation_offset = Vector2( 0, 0 ) +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 + +[node name="Map" type="Node2D"] +script = ExtResource( 3 ) [node name="Player" parent="." instance=ExtResource( 1 )] -position = Vector2( 391.323, 305.517 ) +position = Vector2( 414.59, 184.684 ) +rotation = -0.0024598 +z_index = 1 + +[node name="Node" type="Node2D" parent="."] + +[node name="Path" type="TileMap" parent="Node"] +scale = Vector2( 10, 10 ) +tile_set = SubResource( 1 ) +cell_size = Vector2( 13, 13 ) +cell_custom_transform = Transform2D( 0, 0, 0, 0, 0, 0 ) +format = 1 +tile_data = PoolIntArray( 65536, 0, 196608, 65537, 0, 5, 65538, 0, 10, 65539, 0, 10, 65540, 0, 10, 65541, 0, 10, 65542, 0, 6, 65543, 0, 196609, 65544, 0, 3, 131073, 0, 196616, 131074, 0, 131077, 131075, 0, 65546, 131076, 0, 65546, 131077, 0, 65546, 131078, 0, 65547, 131080, 0, 131073, 131081, 0, 3, 196610, 0, 196616, 196611, 0, 196617, 196612, 0, 196617, 196613, 0, 196617, 196614, 0, 196614, 196615, 0, 3, 196617, 0, 65536, 262151, 0, 131073, 262152, 0, 196609, 262153, 0, 131075 ) + +[node name="CanvasLayer" type="CanvasLayer" parent="."] + +[node name="Control" parent="CanvasLayer" instance=ExtResource( 4 )] +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +margin_left = 491.691 +margin_top = 280.333 +margin_right = 491.691 +margin_bottom = 280.333 diff --git a/src/levels/map.gd b/src/levels/map.gd new file mode 100644 index 0000000..32b71dc --- /dev/null +++ b/src/levels/map.gd @@ -0,0 +1,16 @@ +extends Node2D + + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" + + +# 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 diff --git a/src/ui/HUD.gd b/src/ui/HUD.gd new file mode 100644 index 0000000..b764168 --- /dev/null +++ b/src/ui/HUD.gd @@ -0,0 +1,54 @@ +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 _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass + +func btn_move_pressed(direction, pressed): + var ev = InputEventAction.new() + ev.action = direction + ev.pressed = pressed + Input.parse_input_event(ev) + + +func _on_ButtonUp_button_down(): + btn_move_pressed("up", true) + + +func _on_ButtonRight_button_down(): + btn_move_pressed("right", true) + + +func _on_ButtonDown_button_down(): + btn_move_pressed("down", true) + + +func _on_ButtonLeft_button_down(): + btn_move_pressed("left", true) + + +func _on_ButtonUp_button_up(): + btn_move_pressed("up", false) + + +func _on_ButtonRight_button_up(): + btn_move_pressed("right", false) + + +func _on_ButtonDown_button_up(): + btn_move_pressed("down", false) + + +func _on_ButtonLeft_button_up(): + btn_move_pressed("left", false) diff --git a/src/ui/HUD.tscn b/src/ui/HUD.tscn new file mode 100644 index 0000000..932a683 --- /dev/null +++ b/src/ui/HUD.tscn @@ -0,0 +1,85 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://src/ui/HUD.gd" type="Script" id=1] + +[node name="Control" type="Control"] +anchor_right = 1.0 +anchor_bottom = 1.0 +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Moving" type="Control" parent="."] +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = 1.33484 +margin_right = 1.33484 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="ButtonUp" type="Button" parent="Moving"] +anchor_left = 1.0 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = -163.461 +margin_top = -194.163 +margin_right = -113.461 +margin_bottom = -144.163 +text = "haut" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="ButtonRight" type="Button" parent="Moving"] +anchor_left = 1.0 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = -100.724 +margin_top = -128.756 +margin_right = -50.7239 +margin_bottom = -78.7556 +text = "droite" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="ButtonDown" type="Button" parent="Moving"] +anchor_left = 1.0 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = -163.461 +margin_top = -68.6879 +margin_right = -113.461 +margin_bottom = -18.6879 +text = "bas" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="ButtonLeft" type="Button" parent="Moving"] +anchor_left = 1.0 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = -228.869 +margin_top = -130.09 +margin_right = -178.869 +margin_bottom = -80.0905 +text = "gauche" +__meta__ = { +"_edit_use_anchors_": false +} + +[connection signal="button_down" from="Moving/ButtonUp" to="." method="_on_ButtonUp_button_down"] +[connection signal="button_up" from="Moving/ButtonUp" to="." method="_on_ButtonUp_button_up"] +[connection signal="button_down" from="Moving/ButtonRight" to="." method="_on_ButtonRight_button_down"] +[connection signal="button_up" from="Moving/ButtonRight" to="." method="_on_ButtonRight_button_up"] +[connection signal="button_down" from="Moving/ButtonDown" to="." method="_on_ButtonDown_button_down"] +[connection signal="button_up" from="Moving/ButtonDown" to="." method="_on_ButtonDown_button_up"] +[connection signal="button_down" from="Moving/ButtonLeft" to="." method="_on_ButtonLeft_button_down"] +[connection signal="button_up" from="Moving/ButtonLeft" to="." method="_on_ButtonLeft_button_up"]