Skip to content

Commit

Permalink
solved bow bug. added arrow
Browse files Browse the repository at this point in the history
  • Loading branch information
ProfAndreaPollini committed Jul 25, 2022
1 parent 3921eaa commit d936c8b
Show file tree
Hide file tree
Showing 27 changed files with 591 additions and 39 deletions.
5 changes: 5 additions & 0 deletions DialogueLayer.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ extends CanvasLayer
var sentences = []
var current = 0

func _ready():
set_process_input(false)

func say(text):
sentences = text
current = 0
Expand All @@ -28,4 +31,6 @@ func _process(delta):


func hide():
set_process_input(false)
$AnimationPlayer.play("hide")

1 change: 1 addition & 0 deletions MainScreen.gd
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ func _process(delta):
func _input(event):
if event is InputEventKey:
if event.scancode == KEY_K:
$DialogueLayer.set_process_input(true)
$DialogueLayer.say(["Zetalè noi non siamo boomer, ", "noi apparteniamo alla Generazione X, noi siamo stati i figli degli anni '80: qui sono leon fuxioa sotto luci blu, ", "colori accesi, batterie elettroniche, Magnum PI, Miami Vice e abiti fighissimi!!!"])
if event.scancode == KEY_L:
$DialogueLayer.hide()
Expand Down
167 changes: 165 additions & 2 deletions MainScreen.tscn
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[gd_scene load_steps=24 format=2]
[gd_scene load_steps=37 format=2]

[ext_resource path="res://Idle.gd" type="Script" id=1]
[ext_resource path="res://Running.gd" type="Script" id=2]
[ext_resource path="res://entites/King.tscn" type="PackedScene" id=3]
[ext_resource path="res://MainScreen.gd" type="Script" id=4]
[ext_resource path="res://entites/Sword.tscn" type="PackedScene" id=5]
[ext_resource path="res://entites/weapons/Sword.tscn" type="PackedScene" id=5]
[ext_resource path="res://entites/Potion.tscn" type="PackedScene" id=6]
[ext_resource path="res://lib/ecs/Entity.tscn" type="PackedScene" id=7]
[ext_resource path="res://lib/StateManager.gd" type="Script" id=8]
Expand All @@ -16,6 +16,156 @@
[ext_resource path="res://assets/Fantasy RPG NPCs - Individuel Frames/King/King_Idle_1.png" type="Texture" id=14]
[ext_resource path="res://DialogueLayer.gd" type="Script" id=15]
[ext_resource path="res://assets/fonts/dialogue_fonts.tres" type="DynamicFont" id=16]
[ext_resource path="res://entites/weapons/SimpleSword.tscn" type="PackedScene" id=17]
[ext_resource path="res://entites/weapons/Bow.tscn" type="PackedScene" id=18]
[ext_resource path="res://assets/0x72_16x16DungeonTileset.v4.png" type="Texture" id=19]

[sub_resource type="ConvexPolygonShape2D" id=11]
points = PoolVector2Array( 16, 16, 0, 16, 0, 16, 16, 16 )

[sub_resource type="ConvexPolygonShape2D" id=12]
points = PoolVector2Array( 16, 16, 0, 16, 0, 0, 16, 0 )

[sub_resource type="ConvexPolygonShape2D" id=13]
points = PoolVector2Array( 16, 16, 0, 16, 0, 0, 16, 0 )

[sub_resource type="ConvexPolygonShape2D" id=14]
points = PoolVector2Array( 16, 16, 0, 16, 0, 0, 16, 0 )

[sub_resource type="ConvexPolygonShape2D" id=15]
points = PoolVector2Array( 16, 16, 0, 16, 0, 0, 16, 0 )

[sub_resource type="ConvexPolygonShape2D" id=16]
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )

[sub_resource type="ConvexPolygonShape2D" id=17]
points = PoolVector2Array( 16, 16, 0, 16, 0, 0, 16, 0 )

[sub_resource type="ConvexPolygonShape2D" id=18]
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )

[sub_resource type="ConvexPolygonShape2D" id=19]
points = PoolVector2Array( 16, 16, 0, 16, 0, 0, 16, 0 )

[sub_resource type="TileSet" id=10]
0/name = "0x72_16x16DungeonTileset.v4.png 0"
0/texture = ExtResource( 19 )
0/tex_offset = Vector2( 0, 0 )
0/modulate = Color( 1, 1, 1, 1 )
0/region = Rect2( 0, 0, 112, 144 )
0/tile_mode = 2
0/autotile/icon_coordinate = Vector2( 0, 0 )
0/autotile/tile_size = Vector2( 16, 16 )
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 = SubResource( 11 )
0/shape_one_way = false
0/shape_one_way_margin = 1.0
0/shapes = [ {
"autotile_coord": Vector2( 0, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 11 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 0, 1 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 12 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 1, 1 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 13 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 2, 1 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 14 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 3, 1 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 15 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 3, 1 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 16 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 0, 4 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 17 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 0, 4 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 18 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
}, {
"autotile_coord": Vector2( 1, 4 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 19 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
} ]
0/z_index = 0
1/name = "0x72_16x16DungeonTileset.v4.png 1"
1/texture = ExtResource( 19 )
1/tex_offset = Vector2( 0, 0 )
1/modulate = Color( 1, 1, 1, 1 )
1/region = Rect2( 160, 64, 96, 80 )
1/tile_mode = 2
1/autotile/icon_coordinate = Vector2( 0, 0 )
1/autotile/tile_size = Vector2( 16, 16 )
1/autotile/spacing = 0
1/autotile/occluder_map = [ ]
1/autotile/navpoly_map = [ ]
1/autotile/priority_map = [ ]
1/autotile/z_index_map = [ ]
1/occluder_offset = Vector2( 0, 0 )
1/navigation_offset = Vector2( 0, 0 )
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 = "0x72_16x16DungeonTileset.v4.png 2"
2/texture = ExtResource( 19 )
2/tex_offset = Vector2( 0, 0 )
2/modulate = Color( 1, 1, 1, 1 )
2/region = Rect2( 128, 112, 32, 32 )
2/tile_mode = 2
2/autotile/icon_coordinate = Vector2( 0, 0 )
2/autotile/tile_size = Vector2( 16, 16 )
2/autotile/spacing = 0
2/autotile/occluder_map = [ ]
2/autotile/navpoly_map = [ ]
2/autotile/priority_map = [ ]
2/autotile/z_index_map = [ ]
2/occluder_offset = Vector2( 0, 0 )
2/navigation_offset = Vector2( 0, 0 )
2/shape_offset = Vector2( 0, 0 )
2/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
2/shape_one_way = false
2/shape_one_way_margin = 0.0
2/shapes = [ ]
2/z_index = 0

[sub_resource type="DynamicFontData" id=1]
font_path = "res://assets/fonts/Harmonic.ttf"
Expand Down Expand Up @@ -85,6 +235,12 @@ tracks/1/keys = {
position = Vector2( 1, 0 )
script = ExtResource( 4 )

[node name="TileMap" type="TileMap" parent="."]
tile_set = SubResource( 10 )
cell_size = Vector2( 16, 16 )
format = 1
tile_data = PoolIntArray( 65538, 0, 2, 65539, 0, 2, 65540, 0, 2, 65541, 0, 2, 65542, 0, 2, 65543, 0, 2, 65544, 0, 2, 65545, 0, 2, 65546, 0, 2, 65547, 0, 2, 65548, 0, 2, 65549, 0, 2, 65550, 0, 2, 65551, 0, 2, 65552, 0, 2, 65553, 0, 2, 65554, 0, 2, 65555, 0, 2, 131074, 0, 65536, 131075, 0, 65536, 131076, 1, 3, 131077, 0, 65536, 131078, 0, 262149, 131079, 0, 65536, 131080, 0, 65536, 131081, 0, 65536, 131082, 1, 5, 131083, 0, 65536, 131084, 0, 65536, 131085, 0, 65536, 131086, 0, 65536, 131087, 0, 65539, 131088, 0, 65536, 131089, 0, 65536, 131090, 0, 65536, 131091, 0, 65536, 196610, 0, 65536, 196611, 0, 131072, 196612, 0, 131072, 196613, 0, 131072, 196614, 0, 327685, 196615, 0, 131072, 196616, 0, 131072, 196617, 0, 131072, 196618, 0, 131072, 196619, 0, 131072, 196620, 0, 131072, 196621, 0, 131072, 196622, 0, 131072, 196623, 0, 131075, 196624, 0, 131072, 196625, 0, 131072, 196626, 0, 131072, 196627, 0, 65536, 262146, 0, 65536, 262147, 0, 196610, 262148, 0, 196610, 262149, 0, 196610, 262150, 0, 196610, 262151, 0, 196610, 262152, 0, 196610, 262153, 0, 196610, 262154, 0, 196610, 262155, 0, 196610, 262156, 0, 196610, 262157, 0, 196610, 262158, 0, 196610, 262159, 0, 196610, 262160, 0, 196610, 262161, 0, 196610, 262162, 0, 196610, 262163, 0, 65536, 327682, 0, 65536, 327683, 0, 196610, 327684, 0, 196610, 327685, 0, 196610, 327686, 0, 196610, 327687, 0, 196610, 327688, 0, 196610, 327689, 0, 196610, 327690, 0, 196610, 327691, 0, 196610, 327692, 0, 196610, 327693, 0, 196610, 327694, 0, 196610, 327695, 0, 196610, 327696, 0, 196610, 327697, 0, 196610, 327698, 0, 196610, 327699, 0, 65536, 393218, 0, 65536, 393219, 0, 196610, 393220, 0, 196610, 393221, 0, 196610, 393222, 0, 196610, 393223, 0, 393216, 393224, 0, 393217, 393225, 0, 393217, 393226, 0, 393217, 393227, 0, 393217, 393228, 0, 393219, 393229, 0, 196610, 393230, 0, 196610, 393231, 0, 196610, 393232, 0, 196610, 393233, 0, 196610, 393234, 0, 196610, 393235, 0, 65536, 458754, 0, 65536, 458755, 0, 196610, 458756, 0, 196610, 458757, 0, 196610, 458758, 0, 196610, 458759, 0, 458752, 458760, 0, 458756, 458761, 0, 458756, 458762, 0, 458756, 458763, 0, 458756, 458764, 0, 458755, 458765, 0, 196610, 458766, 0, 196610, 458767, 0, 196610, 458768, 0, 196610, 458769, 0, 196610, 458770, 0, 196610, 458771, 0, 65536, 524290, 0, 65536, 524291, 0, 196610, 524292, 0, 196610, 524293, 0, 196610, 524294, 0, 196610, 524295, 0, 524288, 524296, 0, 524289, 524297, 0, 524289, 524298, 0, 524289, 524299, 0, 524289, 524300, 0, 458755, 524301, 0, 196610, 524302, 0, 196610, 524303, 0, 196610, 524304, 0, 196610, 524305, 0, 196610, 524306, 0, 196610, 524307, 0, 65536, 589826, 0, 65536, 589827, 0, 196610, 589828, 0, 196610, 589829, 0, 196610, 589830, 0, 196610, 589831, 0, 196610, 589832, 0, 196610, 589833, 0, 196610, 589834, 0, 196610, 589835, 0, 196610, 589836, 0, 458755, 589837, 0, 196610, 589838, 0, 196610, 589839, 0, 196610, 589840, 0, 196610, 589841, 0, 196610, 589842, 0, 196610, 589843, 0, 65536, 655362, 0, 65536, 655363, 0, 196610, 655364, 0, 196610, 655365, 0, 196610, 655366, 0, 196610, 655367, 0, 196610, 655368, 0, 196610, 655369, 0, 196610, 655370, 0, 196610, 655371, 0, 196610, 655372, 0, 196610, 655373, 0, 196610, 655374, 0, 196610, 655375, 0, 196610, 655376, 0, 196610, 655377, 0, 196610, 655378, 0, 196610, 655379, 0, 65536, 720898, 0, 65536, 720899, 0, 196610, 720900, 0, 196610, 720901, 0, 196610, 720902, 0, 196610, 720903, 0, 196610, 720904, 0, 196610, 720905, 0, 196610, 720906, 0, 196610, 720907, 0, 196610, 720908, 0, 196610, 720909, 0, 196610, 720910, 0, 196610, 720911, 0, 196610, 720912, 0, 196610, 720913, 0, 196610, 720914, 0, 196610, 720915, 0, 65536, 786434, 0, 65536, 786435, 0, 196610, 786436, 0, 196610, 786437, 0, 196610, 786438, 0, 196610, 786439, 0, 196610, 786440, 0, 196610, 786441, 0, 196610, 786442, 0, 196610, 786443, 0, 196610, 786444, 0, 196610, 786445, 0, 196610, 786446, 0, 196610, 786447, 0, 196610, 786448, 0, 196610, 786449, 0, 196610, 786450, 0, 196610, 786451, 0, 65536, 851970, 0, 65536, 851971, 0, 65536, 851972, 0, 65536, 851973, 0, 65536, 851974, 0, 65536, 851975, 0, 65536, 851976, 0, 65536, 851977, 0, 65536, 851978, 0, 65536, 851979, 0, 65536, 851980, 0, 65536, 851981, 0, 65536, 851982, 0, 65536, 851983, 0, 65536, 851984, 0, 65536, 851985, 0, 65536, 851986, 0, 65536, 851987, 0, 65536 )

[node name="King" parent="." instance=ExtResource( 3 )]
position = Vector2( 191, 144 )
offset = Vector2( 10, -8 )
Expand Down Expand Up @@ -166,6 +322,7 @@ position = Vector2( 84, 179 )
position = Vector2( 61, 149 )

[node name="DialogueLayer" type="CanvasLayer" parent="."]
visible = false
script = ExtResource( 15 )

[node name="MarginContainer" type="MarginContainer" parent="DialogueLayer"]
Expand Down Expand Up @@ -252,3 +409,9 @@ stretch_mode = 1
[node name="AnimationPlayer" type="AnimationPlayer" parent="DialogueLayer"]
anims/hide = SubResource( 7 )
anims/show = SubResource( 6 )

[node name="SimpleSword" parent="." instance=ExtResource( 17 )]
position = Vector2( 78, 98 )

[node name="Bow" parent="." instance=ExtResource( 18 )]
position = Vector2( 134, 86 )
2 changes: 1 addition & 1 deletion assets/0x72_16x16DungeonTileset.v4.png.import
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file added assets/testsmoke.kra
Binary file not shown.
Binary file added assets/testsmoke.kra~
Binary file not shown.
Binary file added assets/testsmoke.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 49 additions & 1 deletion docs/ideas.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,52 @@ mariodose: item deve avere queste proprietà secondo me (aggiugete o cambiate se
paulus1969: poi al PG diamo una sola moneta il cui valore aumenta a mano a mano che raccoglie monete e diminuisce quando acquista cose, così è la monetona stessa che funge da borsellino

paulus1969: adesso farei così: la moneta scompare, il campo value del personaggio aumenta del valore contenuto nel campo value della moneta ed accanto scriviamo per un secondo "+100"
AngelOfDeath_V: potresti fare una base della vita da del mana con due pozioni che le compri o le trovi in mappa
AngelOfDeath_V: potresti fare una base della vita da del mana con due pozioni che le compri o le trovi in mappa


extends Area2D


# Declare member variables here. Examples:
# var a = 2
# var b = "text"

var is_firing := false
var old_global_position := Vector2.ZERO
var COOLDOWN_TIME := 0.1
var fire_time := 0.0
var direction = Vector2.ZERO

onready var owner_entity = null #get_parent().get_parent()


func on_mouse_moved(pos: Vector2,dir: Vector2):
direction = dir
var weapon_position = pos + 10*dir

global_position = pos
look_at(pos + 100*dir)
rotate(deg2rad(90))


func _process(delta):
if not owner_entity: return

if Input.is_action_just_pressed("ui_accept") and not is_firing:
fire_time = delta
is_firing = true
old_global_position = global_position
global_position += 10*owner_entity.direction
elif Input.is_action_pressed("ui_accept") and is_firing:
fire_time += delta
elif Input.is_action_just_released("ui_accept") and fire_time > COOLDOWN_TIME:
is_firing = false
global_position = old_global_position




func _on_Sword_body_entered(entity):
if entity.can_equip(self):
get_parent().remove_child(self)
entity.add_weapon(self)
44 changes: 29 additions & 15 deletions entites/King.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,22 @@ signal moved(dx,dy)
onready var inventory = $Inventory
onready var pocket = $Pocket

onready var weapon_position = $sword_position
onready var center_point = $CenterPosition
onready var weapon = get_node("Weapon").get_child(0)

export var offset: Vector2 = Vector2.ZERO

onready var entity_pivot: Vector2 = Vector2.ZERO setget ,get_entity_pivot
var direction := Vector2.ZERO

var Player = load("res://entites/Player.gd")

var player

# Called when the node enters the scene tree for the first time.
func _ready():
player = Player.new()
player.setup(self)
connect("moved",self,"on_moved")

func on_moved(dx: float ,dy : float ) -> void:
Expand All @@ -25,20 +31,28 @@ func on_moved(dx: float ,dy : float ) -> void:
#
# weapon.global_position = get_entity_pivot()

func _physics_process(delta):
func _physics_process(_delta):
player.update_player(_delta)
$AnimatedSprite.flip_h = (get_global_mouse_position() - global_position).dot(Vector2.RIGHT) < 0
if weapon:
direction = (get_global_mouse_position() - get_entity_pivot()).normalized()
#weapon.on_mouse_moved(get_entity_pivot(),direction)

weapon.global_position = global_position + 10*direction
weapon.global_position.x = clamp(weapon.global_position.x,global_position.x-5,global_position.x+5)
weapon.global_position.y = clamp(weapon.global_position.y,global_position.y-20,global_position.y)

weapon.look_at(global_position + 200*direction)

weapon.rotate(deg2rad(90))


#weapon.global_position = global_position #+ 10*direction
# weapon.global_position.x = clamp(weapon.global_position.x,global_position.x-5,global_position.x+5)
# weapon.global_position.y = clamp(weapon.global_position.y,global_position.y-20,global_position.y)
#
# weapon.look_at(global_position + 200*direction)
#
# weapon.rotate(deg2rad(90))
weapon.on_mouse_moved(get_entity_pivot(),direction)
#_draw()

func _draw():
draw_circle(Vector2.ZERO,2,Color.blue)
draw_circle(to_local(get_entity_pivot()),2,Color.green
)

func can_equip(obj)-> bool:
return obj.get_groups().has("weapon") and $Weapon.get_child_count() == 0

Expand All @@ -52,14 +66,14 @@ func add_weapon(new_weapon) -> void:
$Weapon.add_child(new_weapon)
new_weapon.owner_entity = self
new_weapon.position = Vector2.ZERO
new_weapon.global_position = weapon_position.global_position
#new_weapon.global_position = weapon_position.global_position
weapon = new_weapon

#weapon.global_position = get_entity_pivot()
print(weapon.owner_entity)

func get_entity_pivot():
return global_position + offset
return global_position + center_point.position

func pickup(item):
print("picked up item = ",item)
Expand All @@ -82,6 +96,6 @@ func _input(event):
# weapon.look_at(global_position + 200*direction)
#
# weapon.rotate(deg2rad(90))
print(weapon.global_position)

#print(weapon.global_position)
pass

Loading

0 comments on commit d936c8b

Please sign in to comment.