-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
016a6ad
commit 91cd532
Showing
11 changed files
with
147 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
extends Node2D | ||
|
||
export(Texture) var icon_texture | ||
export(NodePath)var entity | ||
|
||
var direction = Vector2.ZERO | ||
var is_firing :=false | ||
var old_position := Vector2.ZERO | ||
|
||
onready var fire_timer = $FireTimer | ||
onready var tween = $Tween | ||
|
||
func _ready(): | ||
add_to_group("weapon") | ||
|
||
|
||
func on_mouse_moved(pos: Vector2,dir: Vector2): | ||
#print("On mouse moved pos = ", pos, " dir = ", dir) | ||
direction = dir | ||
|
||
global_position = pos + 10*dir | ||
#print("pos(pre) = ",global_position) | ||
global_position.x = clamp(global_position.x,pos.x-5,pos.x+5) | ||
global_position.y = clamp(global_position.y,pos.y-15,pos.y+15) | ||
|
||
look_at(global_position + 200*direction) | ||
|
||
func shoot(): | ||
if not is_firing: | ||
is_firing = true | ||
fire_timer.start() | ||
old_position = global_position | ||
#global_position = global_position + 10*direction | ||
tween.interpolate_property(self, | ||
"global_position", | ||
global_position, | ||
global_position + 10*direction,0.1,Tween.TRANS_QUAD | ||
) | ||
tween.start() | ||
|
||
|
||
|
||
|
||
|
||
func _on_FireTimer_timeout(): | ||
global_position = old_position | ||
is_firing = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[gd_scene load_steps=4 format=2] | ||
|
||
[ext_resource path="res://lib/knife/Knife.gd" type="Script" id=1] | ||
[ext_resource path="res://assets/0x72_DungeonTilesetII_v1.4/0x72_DungeonTilesetII_v1.4/frames/weapon_knife.png" type="Texture" id=2] | ||
[ext_resource path="res://assets/Minifantasy_Dungeon_SFX/27_sword_miss_1.wav" type="AudioStream" id=3] | ||
|
||
[node name="Knife" type="Node2D"] | ||
script = ExtResource( 1 ) | ||
|
||
[node name="Sprite" type="Sprite" parent="."] | ||
position = Vector2( 1, 0 ) | ||
rotation = 1.5708 | ||
texture = ExtResource( 2 ) | ||
offset = Vector2( 0, 0.034 ) | ||
|
||
[node name="FireTimer" type="Timer" parent="."] | ||
|
||
[node name="Tween" type="Tween" parent="."] | ||
|
||
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."] | ||
stream = ExtResource( 3 ) | ||
|
||
[connection signal="timeout" from="FireTimer" to="." method="_on_FireTimer_timeout"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters