Sorted things out
This commit is contained in:
parent
86cbd96180
commit
3a2931bf9e
|
@ -1,5 +0,0 @@
|
|||
extends RigidBody2D
|
||||
|
||||
func _on_Area2D_body_entered(body):
|
||||
if "Enemy" in body.name:
|
||||
queue_free()
|
37
Bullet.tscn
37
Bullet.tscn
|
@ -1,37 +0,0 @@
|
|||
[gd_scene load_steps=6 format=2]
|
||||
|
||||
[ext_resource path="res://Sprites/bullet.png" type="Texture" id=1]
|
||||
[ext_resource path="res://Bullet.gd" type="Script" id=2]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 4, 8.5 )
|
||||
|
||||
[sub_resource type="GDScript" id=3]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=2]
|
||||
extents = Vector2( 5, 9.5 )
|
||||
|
||||
[node name="Bullet" type="RigidBody2D"]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2( 76.704, 3 )
|
||||
scale = Vector2( 2.15162, 0.446 )
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
position = Vector2( 100, 7 )
|
||||
rotation = -1.5708
|
||||
texture = ExtResource( 1 )
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="."]
|
||||
position = Vector2( 69.733, 15.448 )
|
||||
scale = Vector2( 1.726, 0.454 )
|
||||
script = SubResource( 3 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||
position = Vector2( 4, -27.5 )
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[connection signal="body_entered" from="Area2D" to="." method="_on_Area2D_body_entered"]
|
||||
[connection signal="body_shape_entered" from="Area2D" to="." method="_on_Area2D_body_shape_entered"]
|
17
Enemy.gd
17
Enemy.gd
|
@ -1,17 +0,0 @@
|
|||
extends KinematicBody2D
|
||||
|
||||
var motion = Vector2()
|
||||
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
func _physics_process(delta):
|
||||
var Player = get_parent().get_node("Player")
|
||||
position += (Player.position - position) / 50
|
||||
look_at(Player.position)
|
||||
move_and_collide(motion)
|
||||
|
||||
func _on_Area2D_body_entered(body):
|
||||
if "Bullet" in body.name:
|
||||
queue_free()
|
||||
|
30
Enemy.tscn
30
Enemy.tscn
|
@ -1,30 +0,0 @@
|
|||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://Sprites/player.png" type="Texture" id=1]
|
||||
[ext_resource path="res://Enemy.gd" type="Script" id=2]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 16, 16.5 )
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=2]
|
||||
extents = Vector2( 23, 19.5 )
|
||||
|
||||
[node name="Enemy" type="KinematicBody2D"]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2( 0, -0.5 )
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
modulate = Color( 1, 0, 0, 1 )
|
||||
rotation = 1.56981
|
||||
texture = ExtResource( 1 )
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="."]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||
position = Vector2( 0, -0.5 )
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[connection signal="body_entered" from="Area2D" to="." method="_on_Area2D_body_entered"]
|
105
Main.tscn
105
Main.tscn
|
@ -1,105 +0,0 @@
|
|||
[gd_scene load_steps=11 format=2]
|
||||
|
||||
[ext_resource path="res://Sprites/player.png" type="Texture" id=1]
|
||||
[ext_resource path="res://Sprites/weapon.png" type="Texture" id=2]
|
||||
[ext_resource path="res://Sprites/grass.png" type="Texture" id=3]
|
||||
[ext_resource path="res://movement.gd" type="Script" id=4]
|
||||
[ext_resource path="res://wall.tres" type="TileSet" id=6]
|
||||
[ext_resource path="res://Sprites/light.png" type="Texture" id=7]
|
||||
[ext_resource path="res://SceneSpawner.gd" type="Script" id=8]
|
||||
|
||||
[sub_resource type="GDScript" id=3]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 36.4995, 55.7176 )
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=2]
|
||||
extents = Vector2( 20, 24 )
|
||||
|
||||
[node name="World" type="Node2D"]
|
||||
position = Vector2( 6, -10 )
|
||||
z_as_relative = false
|
||||
script = ExtResource( 8 )
|
||||
|
||||
[node name="Ground" type="Node2D" parent="."]
|
||||
|
||||
[node name="grass" type="Sprite" parent="Ground"]
|
||||
texture = ExtResource( 3 )
|
||||
script = SubResource( 3 )
|
||||
|
||||
[node name="grass2" type="Sprite" parent="Ground"]
|
||||
position = Vector2( 650, 0 )
|
||||
texture = ExtResource( 3 )
|
||||
|
||||
[node name="grass3" type="Sprite" parent="Ground"]
|
||||
position = Vector2( 0, 600 )
|
||||
texture = ExtResource( 3 )
|
||||
|
||||
[node name="grass4" type="Sprite" parent="Ground"]
|
||||
position = Vector2( 650, 600 )
|
||||
texture = ExtResource( 3 )
|
||||
|
||||
[node name="grass5" type="Sprite" parent="Ground"]
|
||||
position = Vector2( 1300, 600 )
|
||||
texture = ExtResource( 3 )
|
||||
|
||||
[node name="grass6" type="Sprite" parent="Ground"]
|
||||
position = Vector2( 1300, 0 )
|
||||
texture = ExtResource( 3 )
|
||||
|
||||
[node name="Map" type="Node2D" parent="."]
|
||||
|
||||
[node name="TileMap" type="TileMap" parent="Map"]
|
||||
position = Vector2( -1, -2 )
|
||||
scale = Vector2( 0.5, 0.5 )
|
||||
tile_set = ExtResource( 6 )
|
||||
format = 1
|
||||
tile_data = PoolIntArray( -1245213, -1073741824, 0, -1245204, -1073741824, 0, -1245195, -1073741824, 0, -1245186, -1073741824, 0, -1310713, -1073741824, 0, -1310704, -1073741824, 0, -1310688, -1073741824, 0, -1310679, -1073741824, 0, -1310670, -1073741824, 0, -1310661, -1073741824, 0, -1310660, -1073741824, 0, -1245125, -1073741824, 0, -589853, -1073741824, 0, -589844, -1073741824, 0, -655309, -1073741824, 0, -655300, -1073741824, 0, 51, -1073741824, 0, 60, -1073741824, 0, 589795, -1073741824, 0, 589804, -1073741824, 0, 655411, -1073741824, 0, 655420, -1073741824, 0, 1245155, -1073741824, 0, 1245164, -1073741824, 0, 1900515, -1073741824, 0, 1900517, -1073741824, 0, 1900526, -1073741824, 0, 1900534, -1073741824, 0, 1900535, 0, 0, 1900543, -1073741824, 0, 1835009, 0, 0, 1835016, -1073741824, 0, 1835019, 0, 0, 1835025, -1073741824, 0, 1835029, 0, 0, 1835034, -1073741824, 0, 1835039, 0, 0, 1835043, -1073741824, 0, 1835049, 0, 0, 1835052, -1073741824, 0, 1835059, -1073741824, 0, 1835068, -1073741824, 0 )
|
||||
|
||||
[node name="TileMap2" type="TileMap" parent="Map"]
|
||||
scale = Vector2( 0.1, 0.1 )
|
||||
tile_set = ExtResource( 6 )
|
||||
format = 1
|
||||
tile_data = PoolIntArray( -3145626, -1073741824, 0, -2490266, -1073741824, 0, -1834906, -1073741824, 0, -1179546, -1073741824, 0, -524186, -1073741824, 0, 180, -1073741824, 0, 189, -1073741824, 0, 198, -1073741824, 0, 204, -1073741824, 0, 208, -1073741824, 0, 217, -1073741824, 0, 226, -1073741824, 0, 235, -1073741824, 0, 244, -1073741824, 0, 246, -1073741824, 0, 131174, -1073741824, 0, 655540, -1073741824, 0, 786534, -1073741824, 0, 1310900, -1073741824, 0, 1966260, -1073741824, 0, 2621620, -1073741824, 0, 3276971, -1073741824, 0, 3276980, -1073741824, 0, 3866572, -1073741824, 0, 3866581, -1073741824, 0, 3866590, -1073741824, 0, 3866599, -1073741824, 0, 3866608, -1073741824, 0, 3866617, -1073741824, 0, 3801090, -1073741824, 0, 3801099, -1073741824, 0, 4718763, -1073741824, 0, 4718772, -1073741824, 0, 5177402, -1073741824, 0, 5374132, -1073741824, 0, 5832762, -1073741824, 0, 6029492, -1073741824, 0, 6029501, -1073741824, 0, 6029508, -1073741824, 0, 6029511, -1073741824, 0, 6029517, -1073741824, 0, 6029521, -1073741824, 0, 6029530, -1073741824, 0, 6029539, -1073741824, 0, 6029548, -1073741824, 0, 6029557, -1073741824, 0, 6029559, 1610612736, 0, 6488122, -1073741824, 0, 7143482, -1073741824, 0, 7798842, -1073741824, 0, 8454202, -1073741824, 0, 8585274, -1073741824, 0 )
|
||||
|
||||
[node name="Player" type="KinematicBody2D" parent="."]
|
||||
position = Vector2( 539, 334 )
|
||||
script = ExtResource( 4 )
|
||||
|
||||
[node name="Light2D" type="Light2D" parent="Player"]
|
||||
position = Vector2( -1, 2 )
|
||||
texture = ExtResource( 7 )
|
||||
color = Color( 1, 0.878431, 0.0745098, 1 )
|
||||
energy = 0.5
|
||||
shadow_enabled = true
|
||||
shadow_buffer_size = 4096
|
||||
shadow_filter_smooth = 64.0
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="Player"]
|
||||
position = Vector2( 0, 1 )
|
||||
rotation = 1.56962
|
||||
texture = ExtResource( 1 )
|
||||
|
||||
[node name="weapon" type="Sprite" parent="Player"]
|
||||
position = Vector2( 35, 3 )
|
||||
rotation = 1.5708
|
||||
texture = ExtResource( 2 )
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="Player"]
|
||||
position = Vector2( 2, 1 )
|
||||
current = true
|
||||
smoothing_enabled = true
|
||||
smoothing_speed = 10.0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Player"]
|
||||
position = Vector2( 0, 1.5 )
|
||||
scale = Vector2( 0.493156, -0.314084 )
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="Player"]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Player/Area2D"]
|
||||
position = Vector2( 0, 1 )
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[connection signal="body_entered" from="Player/Area2D" to="Player" method="_on_Area2D_body_entered"]
|
|
@ -1,23 +0,0 @@
|
|||
extends Node
|
||||
|
||||
func _ready():
|
||||
var rand = RandomNumberGenerator.new()
|
||||
var enemyscene = load("res://Enemy.tscn")
|
||||
|
||||
var screen_size = get_viewport().get_visible_rect().size
|
||||
|
||||
for i in range(0,10):
|
||||
var enemy = enemyscene.instance()
|
||||
rand.randomize()
|
||||
var x = rand.randf_range(0, screen_size.x)
|
||||
|
||||
rand.randomize()
|
||||
var y = rand.randf_range(0, screen_size.y)
|
||||
enemy.position.y = y
|
||||
enemy.position.x = x
|
||||
add_child(enemy)
|
||||
|
||||
func _on_Area2D_body_entered(body):
|
||||
if "Bullet" in body.name:
|
||||
queue_free()
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
[gd_resource type="Environment" load_steps=2 format=2]
|
||||
|
||||
[sub_resource type="ProceduralSky" id=1]
|
||||
|
||||
[resource]
|
||||
background_mode = 2
|
||||
background_sky = SubResource( 1 )
|
|
@ -1,35 +0,0 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://icon.png"
|
||||
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.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=true
|
||||
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
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
37
movement.gd
37
movement.gd
|
@ -1,37 +0,0 @@
|
|||
extends KinematicBody2D
|
||||
|
||||
var speed = 300
|
||||
var bullet_speed = 2000
|
||||
var bullet = preload("res://Bullet.tscn")
|
||||
|
||||
func _physics_process(delta):
|
||||
var motion = Vector2()
|
||||
if Input.is_action_pressed("ui_right"):
|
||||
motion.x += 1
|
||||
if Input.is_action_pressed("ui_left"):
|
||||
motion.x -= 1
|
||||
if Input.is_action_pressed("ui_down"):
|
||||
motion.y += 1
|
||||
if Input.is_action_pressed("ui_up"):
|
||||
motion.y -= 1
|
||||
motion = motion.normalized()
|
||||
motion = move_and_slide(motion * speed)
|
||||
look_at(get_global_mouse_position())
|
||||
if Input.is_action_just_pressed("LMB"):
|
||||
fire()
|
||||
|
||||
func fire():
|
||||
var bullet_instance = bullet.instance()
|
||||
bullet_instance.position = get_global_position()
|
||||
bullet_instance.rotation_degrees = rotation_degrees
|
||||
bullet_instance.apply_impulse(Vector2(), Vector2(bullet_speed, 0).rotated(rotation))
|
||||
get_tree().get_root().call_deferred("add_child", bullet_instance)
|
||||
|
||||
|
||||
func kill():
|
||||
get_tree().reload_current_scene()
|
||||
|
||||
|
||||
func _on_Area2D_body_entered(body):
|
||||
if "Enemy" in body.name:
|
||||
kill()
|
|
@ -11,8 +11,8 @@ config_version=4
|
|||
[application]
|
||||
|
||||
config/name="HOTROYAL"
|
||||
run/main_scene="res://Main.tscn"
|
||||
config/icon="res://icon.png"
|
||||
run/main_scene="res://Scenes/Main.tscn"
|
||||
config/icon="res://Sprites/icon.png"
|
||||
|
||||
[gui]
|
||||
|
||||
|
@ -56,4 +56,4 @@ common/enable_pause_aware_picking=true
|
|||
|
||||
[rendering]
|
||||
|
||||
environment/default_environment="res://default_env.tres"
|
||||
environment/default_environment="res://Scenes/default_env.tres"
|
||||
|
|
33
wall.tres
33
wall.tres
|
@ -1,33 +0,0 @@
|
|||
[gd_resource type="TileSet" load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://Sprites/grass.png" type="Texture" id=1]
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=1]
|
||||
polygon = PoolVector2Array( -338, -312, -337, 312, 337, 312, 338, -313 )
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=2]
|
||||
extents = Vector2( 337.5, 312 )
|
||||
|
||||
[resource]
|
||||
0/name = "Sprite"
|
||||
0/texture = ExtResource( 1 )
|
||||
0/tex_offset = Vector2( 0, 0 )
|
||||
0/modulate = Color( 0.588235, 0.392157, 0.588235, 1 )
|
||||
0/region = Rect2( 0, 0, 674, 624 )
|
||||
0/tile_mode = 0
|
||||
0/occluder_offset = Vector2( 337, 312 )
|
||||
0/occluder = SubResource( 1 )
|
||||
0/navigation_offset = Vector2( 337, 312 )
|
||||
0/shape_offset = Vector2( 337.5, 312 )
|
||||
0/shape_transform = Transform2D( 1, 0, 0, 1, 337.5, 312 )
|
||||
0/shape = SubResource( 2 )
|
||||
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( 2 ),
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 337.5, 312 )
|
||||
} ]
|
||||
0/z_index = 0
|
25
wall.tscn
25
wall.tscn
|
@ -1,25 +0,0 @@
|
|||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://Sprites/grass.png" type="Texture" id=1]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=2]
|
||||
extents = Vector2( 337.5, 312 )
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id=1]
|
||||
polygon = PoolVector2Array( -338, -312, -337, 312, 337, 312, 338, -313 )
|
||||
|
||||
[node name="Node2D" type="Node2D"]
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
modulate = Color( 0.588235, 0.392157, 0.588235, 1 )
|
||||
scale = Vector2( 0.1, 0.1 )
|
||||
texture = ExtResource( 1 )
|
||||
|
||||
[node name="StaticBody2D" type="StaticBody2D" parent="Sprite"]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Sprite/StaticBody2D"]
|
||||
position = Vector2( 0.5, 0 )
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[node name="LightOccluder2D" type="LightOccluder2D" parent="Sprite"]
|
||||
occluder = SubResource( 1 )
|
Loading…
Reference in New Issue