add scraps from other test project for now, bounce off this
This commit is contained in:
parent
0773b6c86c
commit
7d86ed5935
|
@ -0,0 +1,10 @@
|
||||||
|
extends StaticBody2D
|
||||||
|
|
||||||
|
# class member variables go here, for example:
|
||||||
|
# var a = 2
|
||||||
|
# var b = "textvar"
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
# Called every time the node is added to the scene.
|
||||||
|
# Initialization here
|
||||||
|
pass
|
|
@ -0,0 +1,35 @@
|
||||||
|
[gd_scene load_steps=4 format=1]
|
||||||
|
|
||||||
|
[ext_resource path="res://Box.gd" type="Script" id=1]
|
||||||
|
[ext_resource path="res://box.png" type="Texture" id=2]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id=1]
|
||||||
|
|
||||||
|
custom_solver_bias = 0.0
|
||||||
|
extents = Vector2( 24.7036, 30.1941 )
|
||||||
|
|
||||||
|
[node name="Box" type="StaticBody2D"]
|
||||||
|
|
||||||
|
input/pickable = false
|
||||||
|
shapes/0/shape = SubResource( 1 )
|
||||||
|
shapes/0/transform = Matrix32( 1, 0, 0, 1, 0, 0 )
|
||||||
|
shapes/0/trigger = false
|
||||||
|
collision/layers = 1
|
||||||
|
collision/mask = 1
|
||||||
|
constant_linear_velocity = Vector2( 0, 0 )
|
||||||
|
constant_angular_velocity = 0.0
|
||||||
|
friction = 1.0
|
||||||
|
bounce = 0.0
|
||||||
|
script/script = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="Sprite" type="Sprite" parent="."]
|
||||||
|
|
||||||
|
texture = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
|
||||||
|
shape = SubResource( 1 )
|
||||||
|
trigger = false
|
||||||
|
_update_shape_index = 0
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
extends Area2D
|
||||||
|
|
||||||
|
var velocity = Vector2(0, 0)
|
||||||
|
var bullet_velocity = 5
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
connect("body_enter", self, "bullet_enter_body")
|
||||||
|
set_collision_mask_bit(1, false)
|
||||||
|
set_fixed_process(true)
|
||||||
|
|
||||||
|
func bullet_enter_body(body):
|
||||||
|
if body.has_method("take_damage"):
|
||||||
|
body.take_damage(1)
|
||||||
|
queue_free()
|
||||||
|
|
||||||
|
func bullet_left_scene():
|
||||||
|
queue_free()
|
||||||
|
|
||||||
|
func set_bullet_velocity(rel, dir):
|
||||||
|
velocity = rel + dir * bullet_velocity
|
||||||
|
|
||||||
|
func _fixed_process(delta):
|
||||||
|
translate(velocity)
|
|
@ -0,0 +1,33 @@
|
||||||
|
[gd_scene load_steps=4 format=1]
|
||||||
|
|
||||||
|
[ext_resource path="res://Bullet.gd" type="Script" id=1]
|
||||||
|
[ext_resource path="res://bullet.png" type="Texture" id=2]
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id=1]
|
||||||
|
|
||||||
|
custom_solver_bias = 0.0
|
||||||
|
radius = 7.81268
|
||||||
|
|
||||||
|
[node name="Bullet" type="Area2D"]
|
||||||
|
|
||||||
|
input/pickable = false
|
||||||
|
shapes/0/shape = SubResource( 1 )
|
||||||
|
shapes/0/transform = Matrix32( 1, 0, 0, 1, 0, 0 )
|
||||||
|
shapes/0/trigger = false
|
||||||
|
gravity_vec = Vector2( 0, 1 )
|
||||||
|
gravity = 98.0
|
||||||
|
linear_damp = 0.1
|
||||||
|
angular_damp = 1.0
|
||||||
|
script/script = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="Sprite" type="Sprite" parent="."]
|
||||||
|
|
||||||
|
texture = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
|
||||||
|
shape = SubResource( 1 )
|
||||||
|
trigger = false
|
||||||
|
_update_shape_index = 0
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
extends KinematicBody2D
|
||||||
|
|
||||||
|
# class member variables go here, for example:
|
||||||
|
# var a = 2
|
||||||
|
# var b = "textvar"
|
||||||
|
var ani_sprite
|
||||||
|
var health = 100
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
# Called every time the node is added to the scene.
|
||||||
|
# Initialization here
|
||||||
|
ani_sprite = get_node("AnimatedSprite")
|
||||||
|
set_fixed_process(true)
|
||||||
|
|
||||||
|
func take_damage(damage):
|
||||||
|
health -= damage
|
||||||
|
|
||||||
|
func _fixed_process(delta):
|
||||||
|
|
||||||
|
if health <= 0:
|
||||||
|
queue_free()
|
||||||
|
|
||||||
|
var target = get_parent().get_node("Player")
|
||||||
|
var angle = get_angle_to(target.get_global_pos())
|
||||||
|
var move_dir = Vector2(0, 1).rotated(angle)
|
||||||
|
|
||||||
|
if move_dir.x > 0:
|
||||||
|
ani_sprite.set_animation("right")
|
||||||
|
elif move_dir.y > 0:
|
||||||
|
ani_sprite.set_animation("down")
|
||||||
|
elif move_dir.x < 0:
|
||||||
|
ani_sprite.set_animation("left")
|
||||||
|
elif move_dir.y < 0:
|
||||||
|
ani_sprite.set_animation("up")
|
||||||
|
|
||||||
|
# actually move too
|
||||||
|
move(move_dir)
|
|
@ -0,0 +1,60 @@
|
||||||
|
[gd_scene load_steps=8 format=1]
|
||||||
|
|
||||||
|
[ext_resource path="res://Enemy.gd" type="Script" id=1]
|
||||||
|
[ext_resource path="res://enright.png" type="Texture" id=2]
|
||||||
|
[ext_resource path="res://enleft.png" type="Texture" id=3]
|
||||||
|
[ext_resource path="res://enup.png" type="Texture" id=4]
|
||||||
|
[ext_resource path="res://endown.png" type="Texture" id=5]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id=2]
|
||||||
|
|
||||||
|
custom_solver_bias = 0.0
|
||||||
|
extents = Vector2( 16.7704, 24.8305 )
|
||||||
|
|
||||||
|
[sub_resource type="SpriteFrames" id=1]
|
||||||
|
|
||||||
|
animations = [ {
|
||||||
|
"frames": [ ExtResource( 2 ) ],
|
||||||
|
"loop": true,
|
||||||
|
"name": "right",
|
||||||
|
"speed": 5.0
|
||||||
|
}, {
|
||||||
|
"frames": [ ExtResource( 3 ) ],
|
||||||
|
"loop": true,
|
||||||
|
"name": "left",
|
||||||
|
"speed": 5.0
|
||||||
|
}, {
|
||||||
|
"frames": [ ExtResource( 4 ) ],
|
||||||
|
"loop": true,
|
||||||
|
"name": "up",
|
||||||
|
"speed": 5.0
|
||||||
|
}, {
|
||||||
|
"frames": [ ExtResource( 5 ) ],
|
||||||
|
"loop": true,
|
||||||
|
"name": "down",
|
||||||
|
"speed": 5.0
|
||||||
|
} ]
|
||||||
|
|
||||||
|
[node name="Enemy" type="KinematicBody2D"]
|
||||||
|
|
||||||
|
input/pickable = false
|
||||||
|
shapes/0/shape = SubResource( 2 )
|
||||||
|
shapes/0/transform = Matrix32( 1, 0, 0, 1, 0, 0 )
|
||||||
|
shapes/0/trigger = false
|
||||||
|
collision/layers = 1
|
||||||
|
collision/mask = 1
|
||||||
|
collision/margin = 0.08
|
||||||
|
script/script = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||||
|
|
||||||
|
frames = SubResource( 1 )
|
||||||
|
animation = "up"
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
|
||||||
|
shape = SubResource( 2 )
|
||||||
|
trigger = false
|
||||||
|
_update_shape_index = 0
|
||||||
|
|
||||||
|
|
27
Game.tscn
27
Game.tscn
|
@ -1,9 +1,30 @@
|
||||||
[gd_scene load_steps=2 format=1]
|
[gd_scene load_steps=5 format=1]
|
||||||
|
|
||||||
[ext_resource path="res://Player.tscn" type="PackedScene" id=1]
|
[ext_resource path="res://Game.gd" type="Script" id=1]
|
||||||
|
[ext_resource path="res://Player.tscn" type="PackedScene" id=2]
|
||||||
|
[ext_resource path="res://Enemy.tscn" type="PackedScene" id=3]
|
||||||
|
[ext_resource path="res://Box.tscn" type="PackedScene" id=4]
|
||||||
|
|
||||||
[node name="Game" type="Node"]
|
[node name="Game" type="Node"]
|
||||||
|
|
||||||
[node name="Player" parent="." instance=ExtResource( 1 )]
|
script/script = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="Player" parent="." instance=ExtResource( 2 )]
|
||||||
|
|
||||||
|
[node name="Enemy" parent="." instance=ExtResource( 3 )]
|
||||||
|
|
||||||
|
transform/pos = Vector2( 305.173, 133.348 )
|
||||||
|
|
||||||
|
[node name="Box 1" parent="." instance=ExtResource( 4 )]
|
||||||
|
|
||||||
|
transform/pos = Vector2( 121.777, 141.339 )
|
||||||
|
|
||||||
|
[node name="Box 2" parent="." instance=ExtResource( 4 )]
|
||||||
|
|
||||||
|
transform/pos = Vector2( 159.592, 142.666 )
|
||||||
|
|
||||||
|
[node name="Box 3" parent="." instance=ExtResource( 4 )]
|
||||||
|
|
||||||
|
transform/pos = Vector2( 139.69, 112.812 )
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
extends KinematicBody2D
|
||||||
|
|
||||||
|
var bullet = load("res://Bullet.tscn")
|
||||||
|
var velocity = Vector2(0, 0)
|
||||||
|
var pointer
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
# Called every time the node is added to the scene.
|
||||||
|
pointer = get_node("Pointer")
|
||||||
|
set_fixed_process(true)
|
||||||
|
|
||||||
|
func _fixed_process(delta):
|
||||||
|
|
||||||
|
var point_dir = (get_viewport().get_mouse_pos() - get_global_pos()).normalized()
|
||||||
|
|
||||||
|
if Input.is_action_pressed("move_left"):
|
||||||
|
velocity.x = -1
|
||||||
|
|
||||||
|
if Input.is_action_pressed("move_right"):
|
||||||
|
velocity.x = 1
|
||||||
|
|
||||||
|
if Input.is_action_pressed("move_up"):
|
||||||
|
velocity.y = -1
|
||||||
|
|
||||||
|
if Input.is_action_pressed("move_down"):
|
||||||
|
velocity.y = 1
|
||||||
|
|
||||||
|
# shooty
|
||||||
|
if Input.is_action_pressed("primary_fire"):
|
||||||
|
var new_bullet = bullet.instance()
|
||||||
|
new_bullet.set_pos(pointer.get_node("Sprite").get_global_pos() + velocity)
|
||||||
|
new_bullet.set_bullet_velocity(velocity, point_dir)
|
||||||
|
get_parent().add_child(new_bullet) # add to tree
|
||||||
|
|
||||||
|
# rotatey pointer thingy
|
||||||
|
pointer.look_at(get_viewport().get_mouse_pos())
|
||||||
|
|
||||||
|
self.move(velocity)
|
||||||
|
velocity.x = 0
|
||||||
|
velocity.y = 0
|
48
Player.tscn
48
Player.tscn
|
@ -1,18 +1,24 @@
|
||||||
[gd_scene load_steps=3 format=1]
|
[gd_scene load_steps=5 format=1]
|
||||||
|
|
||||||
[ext_resource path="res://player_controller.gd" type="Script" id=1]
|
[ext_resource path="res://Player.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://icon.png" type="Texture" id=2]
|
[ext_resource path="res://player.png" type="Texture" id=2]
|
||||||
|
[ext_resource path="res://pointer.png" type="Texture" id=3]
|
||||||
|
|
||||||
[node name="Player" type="Control"]
|
[sub_resource type="RectangleShape2D" id=1]
|
||||||
|
|
||||||
focus/ignore_mouse = false
|
custom_solver_bias = 0.0
|
||||||
focus/stop_mouse = true
|
extents = Vector2( 17.1165, 38.4685 )
|
||||||
size_flags/horizontal = 2
|
|
||||||
size_flags/vertical = 2
|
[node name="Player" type="KinematicBody2D"]
|
||||||
margin/left = 0.0
|
|
||||||
margin/top = 0.0
|
transform/pos = Vector2( 36.5, 31 )
|
||||||
margin/right = 40.0
|
input/pickable = false
|
||||||
margin/bottom = 40.0
|
shapes/0/shape = SubResource( 1 )
|
||||||
|
shapes/0/transform = Matrix32( 1, 0, 0, 1, 0, 0 )
|
||||||
|
shapes/0/trigger = false
|
||||||
|
collision/layers = 1
|
||||||
|
collision/mask = 1
|
||||||
|
collision/margin = 0.08
|
||||||
script/script = ExtResource( 1 )
|
script/script = ExtResource( 1 )
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite" parent="."]
|
[node name="Sprite" type="Sprite" parent="."]
|
||||||
|
@ -22,6 +28,22 @@ texture = ExtResource( 2 )
|
||||||
[node name="Listener" type="Listener" parent="."]
|
[node name="Listener" type="Listener" parent="."]
|
||||||
|
|
||||||
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
|
_import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
|
||||||
current = false
|
current = true
|
||||||
|
|
||||||
|
[node name="Position2D" type="Position2D" parent="."]
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
|
||||||
|
shape = SubResource( 1 )
|
||||||
|
trigger = false
|
||||||
|
_update_shape_index = 0
|
||||||
|
|
||||||
|
[node name="Pointer" type="Node2D" parent="."]
|
||||||
|
|
||||||
|
[node name="Sprite" type="Sprite" parent="Pointer"]
|
||||||
|
|
||||||
|
transform/pos = Vector2( 0, 50.2221 )
|
||||||
|
transform/rot = 90.0
|
||||||
|
texture = ExtResource( 3 )
|
||||||
|
|
||||||
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
19
engine.cfg
19
engine.cfg
|
@ -1,14 +1,13 @@
|
||||||
; Engine configuration file.
|
|
||||||
; It's best edited using the editor UI and not directly,
|
|
||||||
; since the parameters that go here are not all obvious.
|
|
||||||
;
|
|
||||||
; Format:
|
|
||||||
; [section] ; section goes between []
|
|
||||||
; param=value ; assign values to parameters
|
|
||||||
|
|
||||||
|
|
||||||
[application]
|
[application]
|
||||||
|
|
||||||
|
|
||||||
name="Scribe"
|
name="Scribe"
|
||||||
|
main_scene="res://Game.tscn"
|
||||||
icon="res://icon.png"
|
icon="res://icon.png"
|
||||||
|
|
||||||
|
[input]
|
||||||
|
|
||||||
|
move_up=[key(W), key(Up)]
|
||||||
|
move_down=[key(Down), key(S)]
|
||||||
|
move_left=[key(Left), key(A)]
|
||||||
|
move_right=[key(Right), key(D)]
|
||||||
|
primary_fire=[mbutton(0, 1)]
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue