midori-school/sprites/common/natasha/natasha.gd

103 lines
2.6 KiB
GDScript3
Raw Normal View History

2024-01-27 21:10:58 +01:00
extends CharacterBody2D
2024-01-29 03:42:38 +01:00
var theta: float = 0.0
@export_range(0,2*PI) var alpha: float = 1.5
2024-01-30 04:05:17 +01:00
var bullet = load("res://sprites/common/bullet/snowflake.tscn")
2024-01-27 21:10:58 +01:00
const SPEED = 300.0
2024-04-17 22:00:30 +02:00
const fspeed = 100.0
2024-01-27 21:10:58 +01:00
const JUMP_VELOCITY = -400.0
2024-01-29 03:42:38 +01:00
var vangle = 2
2024-01-30 04:05:17 +01:00
var weakness = 2
2024-04-17 22:00:30 +02:00
var player
var movex = 0
var movey = 0
2024-05-16 00:51:17 +02:00
var attack = 87
var crit = 7
2024-01-29 03:42:38 +01:00
2024-02-02 04:15:29 +01:00
func _ready():
2024-05-16 00:51:17 +02:00
if Global.isboss:
Global.cboss = ["Natasha Dostoyevsky",20520,20520]
2024-02-02 04:15:29 +01:00
var stimer = $Speed
stimer.start(0.05)
2024-04-17 22:00:30 +02:00
#player = get_parent().root.get_node("Player")
2024-02-02 04:15:29 +01:00
2024-01-29 03:42:38 +01:00
func get_vector(angle):
theta = angle + alpha
return Vector2(cos(theta),sin(theta))
2024-01-27 21:10:58 +01:00
# Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
@onready var anim := $AnimationPlayer
func _physics_process(delta):
2024-04-17 22:00:30 +02:00
if Global.live == 1:
if Global.playerx < position.x && (position.x - Global.playerx) > 200:
movex = -1
elif Global.playerx > position.x && (Global.playerx - position.x) > 200:
movex = 1
else:
movex = 0
if Global.playery < position.y && (position.y - Global.playery) > 200:
movey = -1
elif Global.playery > position.y && (Global.playery - position.y) > 200:
movey = 1
else:
movey = 0
else:
movex = 0
movey = 0
velocity.x = movex * fspeed * delta
velocity.y = movey * fspeed * delta
2024-01-27 21:10:58 +01:00
# Add the gravity.
#var velocity = Vector2.ZERO
#if Global.live == 1:
#velocity = (Vector2.RIGHT.rotated(rotation) * 500 * Global.xm * delta)-Vector2.UP.rotated(rotation) * 500 * Global.ym * delta
#origmpos = get_viewport().get_mouse_position()
#if Input.get_joy_axis(0,JOY_AXIS_LEFT_Y) != 0:
# velocity = Vector2.UP.rotated(rotation) * -400 * Input.get_joy_axis(0,JOY_AXIS_LEFT_Y)
#position += velocity
position += velocity
if velocity.y > 0.3:
2024-01-29 03:42:38 +01:00
vangle = 2
2024-01-27 21:10:58 +01:00
elif velocity.y < -0.3:
2024-01-29 03:42:38 +01:00
vangle = 0
2024-01-27 21:10:58 +01:00
elif velocity.x > 0.3:
2024-01-29 03:42:38 +01:00
vangle = 1
2024-01-27 21:10:58 +01:00
elif velocity.x < -0.3:
2024-01-29 03:42:38 +01:00
vangle = 3
2024-01-27 21:10:58 +01:00
if velocity.y != 0 || velocity.x != 0:
2024-01-29 03:42:38 +01:00
if vangle == 0:
2024-01-27 21:10:58 +01:00
anim.play("nwalk")
2024-01-29 03:42:38 +01:00
elif vangle == 1:
2024-01-27 21:10:58 +01:00
anim.play("ewalk")
2024-01-29 03:42:38 +01:00
elif vangle == 3:
2024-01-27 21:10:58 +01:00
anim.play("wwalk")
else:
anim.play("swalk")
else:
2024-01-29 03:42:38 +01:00
if vangle == 0:
2024-01-27 21:10:58 +01:00
anim.play("nidle")
2024-01-29 03:42:38 +01:00
elif vangle == 1:
2024-01-27 21:10:58 +01:00
anim.play("eidle")
2024-01-29 03:42:38 +01:00
elif vangle == 3:
2024-01-27 21:10:58 +01:00
anim.play("widle")
else:
anim.play("sidle")
2024-01-29 01:52:01 +01:00
#move_and_slide()
2024-01-29 03:42:38 +01:00
func shoot(angle):
var new_bullet = bullet.instantiate()
new_bullet.position = Vector2(position.x, position.y)
new_bullet.direction = get_vector(angle)
new_bullet.btype = "boss"
2024-05-16 00:51:17 +02:00
new_bullet.attack = attack
new_bullet.crit = crit
2024-01-29 03:42:38 +01:00
get_parent().call_deferred("add_child",new_bullet)
func _on_speed_timeout():
if Global.live == 1:
shoot(theta)