diff --git a/assets/img/check.png.import b/assets/img/check.png.import index c8284f5..caad503 100644 --- a/assets/img/check.png.import +++ b/assets/img/check.png.import @@ -20,7 +20,7 @@ compress/hdr_mode=0 compress/bptc_ldr=0 compress/normal_map=0 flags/repeat=0 -flags/filter=true +flags/filter=false flags/mipmaps=false flags/anisotropic=false flags/srgb=2 diff --git a/assets/img/cross.png.import b/assets/img/cross.png.import index 3096a08..7e48d2c 100644 --- a/assets/img/cross.png.import +++ b/assets/img/cross.png.import @@ -20,7 +20,7 @@ compress/hdr_mode=0 compress/bptc_ldr=0 compress/normal_map=0 flags/repeat=0 -flags/filter=true +flags/filter=false flags/mipmaps=false flags/anisotropic=false flags/srgb=2 diff --git a/assets/img/spaced-dungeon-tileset.png.import b/assets/img/spaced-dungeon-tileset.png.import index 34261a1..8ad4e7f 100644 --- a/assets/img/spaced-dungeon-tileset.png.import +++ b/assets/img/spaced-dungeon-tileset.png.import @@ -20,11 +20,11 @@ compress/hdr_mode=0 compress/bptc_ldr=0 compress/normal_map=0 flags/repeat=0 -flags/filter=true +flags/filter=false flags/mipmaps=false flags/anisotropic=false flags/srgb=2 -process/fix_alpha_border=true +process/fix_alpha_border=false process/premult_alpha=false process/HDR_as_SRGB=false process/invert_color=false diff --git a/objects/player.tscn b/objects/player.tscn index 1c7cf50..3193bf5 100644 --- a/objects/player.tscn +++ b/objects/player.tscn @@ -1,51 +1,43 @@ -[gd_scene load_steps=16 format=2] +[gd_scene load_steps=18 format=2] [ext_resource path="res://assets/img/spaced-dungeon-tileset.png" type="Texture" id=1] +[ext_resource path="res://assets/fonts/iosevkalyte/iosevkalyte-regular.ttf" type="DynamicFontData" id=2] [ext_resource path="res://objects/bar.tscn" type="PackedScene" id=3] [ext_resource path="res://scripts/objects/player.gd" type="Script" id=10] [sub_resource type="AtlasTexture" id=1] -flags = 4 atlas = ExtResource( 1 ) region = Rect2( 0, 468, 18, 36 ) [sub_resource type="AtlasTexture" id=2] -flags = 4 atlas = ExtResource( 1 ) region = Rect2( 18, 468, 18, 36 ) [sub_resource type="AtlasTexture" id=3] -flags = 4 atlas = ExtResource( 1 ) region = Rect2( 36, 468, 18, 36 ) [sub_resource type="AtlasTexture" id=4] -flags = 4 atlas = ExtResource( 1 ) region = Rect2( 54, 468, 18, 36 ) [sub_resource type="AtlasTexture" id=5] -flags = 4 atlas = ExtResource( 1 ) region = Rect2( 72, 468, 18, 36 ) [sub_resource type="AtlasTexture" id=6] -flags = 4 atlas = ExtResource( 1 ) region = Rect2( 90, 468, 18, 36 ) [sub_resource type="AtlasTexture" id=7] -flags = 4 atlas = ExtResource( 1 ) region = Rect2( 108, 468, 18, 36 ) [sub_resource type="AtlasTexture" id=8] -flags = 4 atlas = ExtResource( 1 ) region = Rect2( 126, 468, 18, 36 ) [sub_resource type="AtlasTexture" id=9] -flags = 4 atlas = ExtResource( 1 ) region = Rect2( 144, 468, 18, 36 ) @@ -70,6 +62,10 @@ animations = [ { [sub_resource type="ConvexPolygonShape2D" id=11] points = PoolVector2Array( -2, 4, 2, 4, 6, 1, 6, -1, 1, -4, -1, -4, -6, -1, -6, 1 ) +[sub_resource type="DynamicFont" id=13] +size = 64 +font_data = ExtResource( 2 ) + [sub_resource type="StyleBoxFlat" id=12] bg_color = Color( 0, 0.25098, 1, 1 ) @@ -81,7 +77,7 @@ modulate = Color( 0.384314, 0.796078, 1, 1 ) position = Vector2( 0, -18 ) frames = SubResource( 10 ) animation = "idle" -frame = 2 +frame = 1 playing = true [node name="collider" type="CollisionShape2D" parent="."] @@ -89,10 +85,28 @@ position = Vector2( 0, -6.5 ) scale = Vector2( 1, 1.6 ) shape = SubResource( 11 ) -[node name="player_name" type="Label" parent="."] -margin_left = -21.0 -margin_right = 21.0 -margin_bottom = 25.0 +[node name="ui" type="CanvasLayer" parent="."] + +[node name="c" type="CenterContainer" parent="ui"] +margin_left = -50.0 +margin_top = 8.0 +margin_right = 350.0 +margin_bottom = 89.0 +grow_horizontal = 2 +grow_vertical = 2 +rect_scale = Vector2( 0.25, 0.25 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="player_name" type="Label" parent="ui/c"] +visible = false +margin_left = 24.0 +margin_right = 376.0 +margin_bottom = 81.0 +size_flags_horizontal = 3 +size_flags_vertical = 7 +custom_fonts/font = SubResource( 13 ) text = "player_name" align = 1 __meta__ = { diff --git a/screens/game.tscn b/screens/game.tscn index 96cadb9..516c365 100644 --- a/screens/game.tscn +++ b/screens/game.tscn @@ -1,11 +1,51 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=6 format=2] [ext_resource path="res://scripts/screens/game.gd" type="Script" id=1] [ext_resource path="res://assets/theme.tres" type="Theme" id=2] +[ext_resource path="res://assets/img/spaced-dungeon-tileset.png" type="Texture" id=3] + +[sub_resource type="NavigationPolygon" id=2] +vertices = PoolVector2Array( 16, 17, 0, 17, 0, 0, 16, 0 ) +polygons = [ PoolIntArray( 0, 1, 2, 3 ) ] + +[sub_resource type="TileSet" id=1] +0/name = "spaced-dungeon-tileset.png 0" +0/texture = ExtResource( 3 ) +0/tex_offset = Vector2( 0, 0 ) +0/modulate = Color( 1, 1, 1, 1 ) +0/region = Rect2( 18, 36, 16, 17 ) +0/tile_mode = 0 +0/occluder_offset = Vector2( 0, 0 ) +0/navigation_offset = Vector2( 0, 0 ) +0/navigation = SubResource( 2 ) +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="game" type="Node2D"] script = ExtResource( 1 ) +[node name="bg" type="ParallaxBackground" parent="."] + +[node name="bglayer" type="ParallaxLayer" parent="bg"] +motion_scale = Vector2( 0.5, 0.5 ) + +[node name="image" type="Sprite" parent="bg/bglayer"] +texture = ExtResource( 3 ) + +[node name="tiles" type="TileMap" parent="."] +tile_set = SubResource( 1 ) +cell_size = Vector2( 16, 16 ) +format = 1 +tile_data = PoolIntArray( -851970, 0, 0, -851969, 0, 0, -917504, 0, 0, -786434, 0, 0, -786433, 0, 0, -851968, 0, 0, -720898, 0, 0, -720897, 0, 0, -786432, 0, 0, -655362, 0, 0, -655361, 0, 0, -720896, 0, 0, -720895, 0, 0, -589826, 0, 0, -589825, 0, 0, -655360, 0, 0, -655359, 0, 0, -524290, 0, 0, -524289, 0, 0, -589824, 0, 0, -458754, 0, 0, -458753, 0, 0, -524288, 0, 0, -393218, 0, 0, -393217, 0, 0, -458752, 0, 0, -327682, 0, 0, -327681, 0, 0, -393216, 0, 0, -262145, 0, 0, -327680, 0, 0, -196609, 0, 0, -262144, 0, 0, -131073, 0, 0, -196608, 0, 0, -65537, 0, 0, -131072, 0, 0, -1, 0, 0, -65536, 0, 0, 65535, 0, 0, 0, 0, 0 ) + +[node name="objects" type="YSort" parent="."] + +[node name="players" type="YSort" parent="objects"] + [node name="camera" type="Camera2D" parent="."] offset = Vector2( 100, 0 ) current = true diff --git a/scripts/objects/player.gd b/scripts/objects/player.gd index 112a5f2..9f81004 100644 --- a/scripts/objects/player.gd +++ b/scripts/objects/player.gd @@ -4,17 +4,19 @@ export var weight = 8 export var max_speed = 80 # ~5 tiles/sec at top speed export var friction = 500 export var speed = 20 +export var mana_per_sec = 10 +export var health_per_sec = 1 export var health = 100 setget set_health export var max_health = 100 setget set_max_health export var mana = 50 setget set_mana -export var max_mana = 100 setget set_max_mana +export var max_mana = 1000 setget set_max_mana enum PlayerClass { WIZARD } onready var viewport = get_viewport() onready var sprite = $sprite onready var collider = $collider -onready var name_displayer = $player_name +onready var name_displayer = $ui/c/player_name onready var display_name = name onready var player_class = PlayerClass.WIZARD onready var skills = [] @@ -94,8 +96,9 @@ static func int_input_action(actions) -> int: return int(Input.is_action_pressed(actions)) func _physics_process(delta): - self.mana += (10*delta) - self.health += (1*delta) + # if get_viewport().get_camera() != null: name_displayer.rect_scale = Vector2(get_viewport().get_camera().zoom) + self.mana += (mana_per_sec*delta) + self.health += (health_per_sec*delta) _process_input() _process_animation() rset("velocity", move_and_slide((velocity + acceleration).clamped(max_speed), Vector2.ZERO, false, 4, 0.785398, false).move_toward(Vector2.ZERO, friction * delta)) diff --git a/scripts/screens/game.gd b/scripts/screens/game.gd index bcb00ef..680aa96 100644 --- a/scripts/screens/game.gd +++ b/scripts/screens/game.gd @@ -10,6 +10,7 @@ onready var players = null func _ready(): # TODO: probably have to wait for all peers to be ready before we add players + camera.zoom = Vector2(0.25, 0.25) if Global.client.is_host(): for id in get_tree().get_network_connected_peers(): Global.client.peers[id].ready = false