Added layers for collision, one projectile

This commit is contained in:
Logan 2020-07-17 13:15:52 -05:00
parent 3610524eab
commit 4a0b01e275
6 changed files with 85 additions and 1 deletions

BIN
art/Wand.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 B

34
art/Wand.png.import Normal file
View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Wand.png-c060d81c9d45b3f06055d7ce9d6020ef.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://art/Wand.png"
dest_files=[ "res://.import/Wand.png-c060d81c9d45b3f06055d7ce9d6020ef.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=false
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=false
svg/scale=1.0

View file

@ -1,7 +1,8 @@
[gd_scene load_steps=3 format=2]
[gd_scene load_steps=4 format=2]
[ext_resource path="res://characters/Player.tscn" type="PackedScene" id=1]
[ext_resource path="res://meta/DungeonTilemap.tscn" type="PackedScene" id=2]
[ext_resource path="res://magic/projectiles/WhiteProjectile.tscn" type="PackedScene" id=3]
[node name="Node2D" type="Node2D"]
position = Vector2( -14, 0 )
@ -11,3 +12,6 @@ position = Vector2( 169, 166 )
[node name="TileMap" parent="." instance=ExtResource( 2 )]
tile_data = PoolIntArray( 0, 0, 8, 1, 0, 10, 2, 0, 10, 3, 0, 10, 4, 0, 10, 5, 0, 10, 6, 0, 10, 7, 0, 10, 8, 0, 10, 9, 0, 10, 10, 0, 10, 11, 0, 10, 12, 0, 10, 13, 0, 10, 14, 0, 10, 15, 0, 10, 16, 0, 10, 17, 0, 10, 18, 0, 10, 19, 0, 10, 20, 0, 11, 65536, 0, 65544, 65537, 0, 131078, 65538, 0, 196617, 65539, 0, 196617, 65540, 0, 196617, 65541, 0, 196617, 65542, 0, 196617, 65543, 0, 196617, 65544, 0, 196617, 65545, 0, 196617, 65546, 0, 196617, 65547, 0, 196617, 65548, 0, 196617, 65549, 0, 196617, 65550, 0, 196617, 65551, 0, 196617, 65552, 0, 196617, 65553, 0, 196617, 65554, 0, 196617, 65555, 0, 131077, 65556, 0, 131083, 131072, 0, 65544, 131073, 0, 131083, 131091, 0, 65544, 131092, 0, 131083, 196608, 0, 65544, 196609, 0, 131083, 196627, 0, 65544, 196628, 0, 131083, 262144, 0, 65544, 262145, 0, 131083, 262163, 0, 65544, 262164, 0, 131083, 327680, 0, 65544, 327681, 0, 131083, 327699, 0, 65544, 327700, 0, 131083, 393216, 0, 65544, 393217, 0, 131083, 393235, 0, 65544, 393236, 0, 131083, 458752, 0, 65544, 458753, 0, 131083, 458771, 0, 65544, 458772, 0, 131083, 524288, 0, 65544, 524289, 0, 131083, 524307, 0, 65544, 524308, 0, 131083, 589824, 0, 65544, 589825, 0, 131083, 589830, 0, 0, 589843, 0, 65544, 589844, 0, 131083, 655360, 0, 65544, 655361, 0, 131083, 655366, 0, 65536, 655379, 0, 65544, 655380, 0, 131083, 720896, 0, 65544, 720897, 0, 65542, 720898, 0, 10, 720899, 0, 10, 720900, 0, 10, 720901, 0, 10, 720902, 0, 9, 720903, 0, 10, 720904, 0, 10, 720905, 0, 10, 720906, 0, 10, 720907, 0, 10, 720908, 0, 10, 720909, 0, 10, 720910, 0, 10, 720911, 0, 10, 720912, 0, 10, 720913, 0, 10, 720914, 0, 10, 720915, 0, 65541, 720916, 0, 131083, 786432, 0, 196616, 786433, 0, 196617, 786434, 0, 196617, 786435, 0, 196617, 786436, 0, 196617, 786437, 0, 196617, 786438, 0, 196617, 786439, 0, 196617, 786440, 0, 196617, 786441, 0, 196617, 786442, 0, 196617, 786443, 0, 196617, 786444, 0, 196617, 786445, 0, 196617, 786446, 0, 196617, 786447, 0, 196617, 786448, 0, 196617, 786449, 0, 196617, 786450, 0, 196617, 786451, 0, 196617, 786452, 0, 196619 )
[node name="WhiteProjectile" parent="." instance=ExtResource( 3 )]
position = Vector2( 195, 158 )

View file

@ -0,0 +1,17 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://script/Projectile.gd" type="Script" id=1]
[ext_resource path="res://art/WhiteProjectile.png" type="Texture" id=2]
[sub_resource type="CircleShape2D" id=1]
radius = 7.0
[node name="WhiteProjectile" type="KinematicBody2D"]
scale = Vector2( 0.5, 0.5 )
script = ExtResource( 1 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource( 1 )
[node name="WhiteProjectile" type="Sprite" parent="."]
texture = ExtResource( 2 )

View file

@ -9,12 +9,18 @@
config_version=4
_global_script_classes=[ {
"base": "KinematicBody2D",
"class": "Projectile",
"language": "GDScript",
"path": "res://script/Projectile.gd"
}, {
"base": "Node",
"class": "StateMachine",
"language": "GDScript",
"path": "res://script/StateMachine.gd"
} ]
_global_script_class_icons={
"Projectile": "",
"StateMachine": ""
}
@ -89,6 +95,13 @@ right={
]
}
[layer_names]
2d_physics/layer_1="Player"
2d_physics/layer_2="World"
2d_physics/layer_3="Enemy"
2d_physics/layer_4="Projectiles"
[rendering]
environment/default_environment="res://default_env.tres"

16
script/Projectile.gd Normal file
View file

@ -0,0 +1,16 @@
extends KinematicBody2D
class_name Projectile
export var speed = 100
var velocity = Vector2.ZERO
func _physics_process(delta):
var collision = move_and_collide(velocity * delta)
if collision != null:
on_impact()
func launch(direction: Vector2):
velocity = direction * speed
func on_impact():
queue_free()