-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTitleBoat2.gd
49 lines (31 loc) · 949 Bytes
/
TitleBoat2.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
extends KinematicBody2D
# Max speeds
const FWD_SPEED = 100
# Global Vars
var velocity = Vector2.ZERO
var move_boat = false
var bullet_scene = preload("res://Bullet.tscn")
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func _physics_process(delta):
if move_boat == true:
# Move Up
velocity.y = -FWD_SPEED * delta
move_and_collide(velocity)
func shoot():
var direction = Vector2(0, -1)
var distance_from_me = 40
var gpos = get_global_position()
var spawn_point = gpos + (direction * distance_from_me)
var bullet = bullet_scene.instance()
bullet.set_global_position(spawn_point)
bullet.rotation = (0 - 90)* (PI/180)
owner.add_child(bullet)
#if play_sound == true:
# $SoundFire.playing = true
func _on_ShootTimer_timeout():
shoot()