forked from andreyratz/block
Projectiles+bounce
I hate github desktop oh my god just let me create a new branch i gave up on creating a new branch It wont let me move to a new branch cause it thinks there are conflicts. what the fuck is the point of that It may say that there are conflicting files. push them through anyways, git is tweaking. I tested it myself, and the last commit to main was also from me so there's nothing to be conflicting with
This commit is contained in:
57
todoList
57
todoList
@@ -12,3 +12,60 @@ Done
|
||||
|
||||
Current imported assests:
|
||||
https://screamingbrainstudios.itch.io/tiny-texture-pack
|
||||
|
||||
|
||||
|
||||
x1*x2+y1*y2
|
||||
|
||||
along normal speedx*sp
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var proje_normal = global_transform.x.normalized()
|
||||
#proje_normal.y = -proje_normal.y
|
||||
print("Proje Normal: ", proje_normal)
|
||||
var speed_perp: float = proje_normal.dot(normal)
|
||||
var perp_line: Vector2 = Vector2(normal.y,-normal.x)
|
||||
var speed_para: float = proje_normal.dot(perp_line)
|
||||
print("speed perp: ", speed_perp)
|
||||
print("speed para: ", speed_para)
|
||||
# this is just to check my math
|
||||
# should be aproximately 1 (there will be some bit depth precision errors)
|
||||
print("speed hype: ", speed_para*speed_para + speed_perp*speed_perp)
|
||||
|
||||
var newDirection: Vector2 = Vector2(
|
||||
(speed_perp * normal.x) + (speed_para * normal.y),
|
||||
(speed_perp * normal.y) + (speed_para *-normal.x))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var projectile_velocity = area.get_parent().get_facing_direction()
|
||||
print("projectile speed......................", projectile_velocity)
|
||||
var shield_normal = global_transform.x.normalized()
|
||||
print("Shield Normal: ", shield_normal)
|
||||
#shield_normal.y = -shield_normal.y
|
||||
# if abs(projectile_velocity.y)>abs(projectile_velocity.x):
|
||||
# shield_normal = global_transform.y.normalized()
|
||||
#shield_normal.y = -shield_normal.y
|
||||
#shield_normal.x = -shield_normal.x
|
||||
# var shield_perp = Vector2(shield_normal.y,-shield_normal.x)
|
||||
# if area.has_method("bounce"):
|
||||
# if projectile_velocity.dot(shield_perp) < 0:
|
||||
# area.bounce(shield_normal)
|
||||
if area.has_method("bounce"):
|
||||
#if projectile_velocity.dot(shield_normal) < 0:
|
||||
area.bounce(shield_normal)
|
||||
Reference in New Issue
Block a user