-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from Fris0uman/gears
Divercify ressources
- Loading branch information
Showing
11 changed files
with
266 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[gd_scene load_steps=4 format=2] | ||
|
||
[ext_resource path="res://assets/cdda_sprites/30gal_drum_winter.png" type="Texture" id=1] | ||
[ext_resource path="res://src/Body.gd" type="Script" id=2] | ||
|
||
[sub_resource type="CapsuleShape2D" id=1] | ||
radius = 4.5 | ||
height = 6.0 | ||
|
||
[node name="Body" type="RigidBody2D" groups=["Ressource"]] | ||
z_index = 1 | ||
collision_layer = 7 | ||
mass = 40.0 | ||
script = ExtResource( 2 ) | ||
_body_size = 11 | ||
_flags = [ "Fuel" ] | ||
|
||
[node name="Sprite" type="Sprite" parent="."] | ||
texture = ExtResource( 1 ) | ||
|
||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] | ||
position = Vector2( -0.5, 1.5 ) | ||
shape = SubResource( 1 ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
[gd_scene load_steps=5 format=2] | ||
|
||
[ext_resource path="res://src/Prey.gd" type="Script" id=1] | ||
[ext_resource path="res://assets/cdda_sprites/e_scrap_season_winter.png" type="Texture" id=2] | ||
|
||
[sub_resource type="CapsuleShape2D" id=1] | ||
radius = 5.0 | ||
height = 4.0 | ||
|
||
[sub_resource type="CircleShape2D" id=2] | ||
radius = 51.0098 | ||
|
||
[node name="Prey" type="RigidBody2D" groups=["Prey", "Ressource"]] | ||
z_index = 1 | ||
collision_layer = 7 | ||
mode = 2 | ||
mass = 70.0 | ||
linear_damp = 2.0 | ||
script = ExtResource( 1 ) | ||
_flags = [ "Scrap" ] | ||
|
||
[node name="Sprite" type="Sprite" parent="."] | ||
texture = ExtResource( 2 ) | ||
|
||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] | ||
position = Vector2( -1, 1 ) | ||
rotation = 1.5708 | ||
shape = SubResource( 1 ) | ||
|
||
[node name="RayCast2D" type="RayCast2D" parent="."] | ||
enabled = true | ||
collision_mask = 4 | ||
|
||
[node name="Area2D" type="Area2D" parent="."] | ||
|
||
[node name="AwarnessShape2D" type="CollisionShape2D" parent="Area2D"] | ||
position = Vector2( -1, 1 ) | ||
shape = SubResource( 2 ) | ||
|
||
[node name="NavigationAgent2D" type="NavigationAgent2D" parent="."] | ||
avoidance_enabled = true | ||
radius = 12.0 | ||
neighbor_dist = 32.0 | ||
|
||
[node name="NavigationObstacle2D" type="NavigationObstacle2D" parent="."] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
[gd_scene load_steps=4 format=2] | ||
|
||
[ext_resource path="res://assets/cdda_sprites/e_scrap_season_winter.png" type="Texture" id=1] | ||
[ext_resource path="res://src/Body.gd" type="Script" id=2] | ||
|
||
[sub_resource type="CapsuleShape2D" id=1] | ||
radius = 4.5 | ||
height = 6.0 | ||
|
||
[node name="Body" type="RigidBody2D" groups=["Ressource"]] | ||
z_index = 1 | ||
collision_layer = 7 | ||
mass = 40.0 | ||
script = ExtResource( 2 ) | ||
_body_size = 11 | ||
_flags = [ "Scrap" ] | ||
|
||
[node name="Sprite" type="Sprite" parent="."] | ||
texture = ExtResource( 1 ) | ||
|
||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] | ||
position = Vector2( -0.5, 1.5 ) | ||
rotation = 1.5708 | ||
shape = SubResource( 1 ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
[remap] | ||
|
||
importer="texture" | ||
type="StreamTexture" | ||
path="res://.import/e_scrap_season_winter.png-fcb5c7e800676a4d76cb83e16a54d30b.stex" | ||
metadata={ | ||
"vram_texture": false | ||
} | ||
|
||
[deps] | ||
|
||
source_file="res://assets/cdda_sprites/e_scrap_season_winter.png" | ||
dest_files=[ "res://.import/e_scrap_season_winter.png-fcb5c7e800676a4d76cb83e16a54d30b.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=false | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
extends Actor | ||
|
||
var _current_path: PoolVector2Array | ||
var _curr_dest: Vector2 | ||
var _heading: float | ||
|
||
var _bodies_fleeing_from: Array | ||
|
||
export var _step_size:= 40 | ||
|
||
onready var awarness_area:= $Area2D | ||
onready var nav_agent:= $NavigationAgent2D | ||
|
||
onready var map := get_node("../TileMap") | ||
|
||
|
||
func _ready() -> void: | ||
set_process(true) | ||
|
||
awarness_area.connect("body_entered",self, "_on_body_entered") | ||
awarness_area.connect("body_exited",self,"_on_body_exited") | ||
nav_agent.connect("velocity_computed", self, "move") | ||
|
||
pick_heading() | ||
|
||
func _physics_process(_delta: float) -> void: | ||
if _bodies_fleeing_from.empty(): | ||
return | ||
|
||
if _current_path.empty(): | ||
new_path() | ||
|
||
var next_location= _current_path[0] | ||
var direction:= position.direction_to(next_location) | ||
var target_vel:= direction * _speed | ||
|
||
nav_agent.set_velocity(target_vel) | ||
|
||
if close_enough(next_location): | ||
_current_path.remove(0) | ||
|
||
func _on_body_entered(body: Body)->void: | ||
if body == null || !body.is_in_group("Actor"): | ||
return | ||
|
||
_bodies_fleeing_from.append(body) | ||
new_path() | ||
|
||
|
||
func _on_body_exited(body: Body)->void: | ||
if body == null || !body.is_in_group("Actor"): | ||
return | ||
_bodies_fleeing_from.erase(body) | ||
|
||
func pick_fleeing_heading()->void: | ||
var chaser_vector:= Vector2.ZERO | ||
for body in _bodies_fleeing_from: | ||
chaser_vector += position.direction_to(body.position) | ||
_heading = acos( - chaser_vector.normalized().x ) | ||
|
||
func new_path()->void: | ||
pick_fleeing_heading() | ||
_curr_dest = pick_destination() | ||
_current_path = make_path(_curr_dest) | ||
|
||
func make_path(destination: Vector2)->PoolVector2Array: | ||
var path = Navigation2DServer.map_get_path(nav_agent.get_navigation_map() ,position,destination, false) | ||
return path | ||
|
||
|
||
func pick_destination()->Vector2: | ||
var dest:= position | ||
var cell_index:= -1 | ||
while cell_index != 1: | ||
var rand_angle:= rand_range(_heading-PI/3, _heading+ PI/3) | ||
var rand_vector:= Vector2(cos(rand_angle),sin(rand_angle)) | ||
dest = global_position + rand_vector * _step_size | ||
cell_index = map.get_cellv(map.world_to_map(dest)) | ||
|
||
return dest | ||
|
||
func pick_heading(): | ||
_heading = rand_range(0,2*PI) | ||
|
||
func close_enough(vect: Vector2, bod = null)->bool: | ||
if bod == null: | ||
return position.distance_to(vect)<=_body_size/2.0 | ||
else: | ||
var bod_size= bod.get_body_size() | ||
var dist:= position.distance_to(vect) | ||
return dist <= (bod_size + _body_size)/2 + GRAB_DIST |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters