Slight sprite refactor, toying with physics

This commit is contained in:
Luke Hubmayer-Werner 2020-04-19 15:12:51 +09:30
parent 8f60694745
commit 7a1c9cfa3a
25 changed files with 211 additions and 227 deletions

235
Main.tscn

File diff suppressed because one or more lines are too long

75
assets/BeltSet.tres Normal file
View File

@ -0,0 +1,75 @@
[gd_resource type="TileSet" load_steps=2 format=2]
[ext_resource path="res://spritesheet.png" type="Texture" id=1]
[resource]
0/name = "belt"
0/texture = ExtResource( 1 )
0/tex_offset = Vector2( 0, 0 )
0/modulate = Color( 1, 1, 1, 1 )
0/region = Rect2( 8, 240, 8, 8 )
0/tile_mode = 0
0/occluder_offset = Vector2( 0, 0 )
0/navigation_offset = Vector2( 0, 0 )
0/shape_offset = Vector2( 0, 0 )
0/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
0/shape_one_way = false
0/shape_one_way_margin = 0.0
0/shapes = [ ]
0/z_index = 0
1/name = "widebelt1"
1/texture = ExtResource( 1 )
1/tex_offset = Vector2( 0, 0 )
1/modulate = Color( 1, 1, 1, 1 )
1/region = Rect2( 8, 224, 8, 8 )
1/tile_mode = 0
1/occluder_offset = Vector2( 0, 0 )
1/navigation_offset = Vector2( 0, 0 )
1/shape_offset = Vector2( 0, 0 )
1/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
1/shape_one_way = false
1/shape_one_way_margin = 0.0
1/shapes = [ ]
1/z_index = 0
2/name = "widebelt2"
2/texture = ExtResource( 1 )
2/tex_offset = Vector2( 0, 0 )
2/modulate = Color( 1, 1, 1, 1 )
2/region = Rect2( 8, 232, 8, 8 )
2/tile_mode = 0
2/occluder_offset = Vector2( 0, 0 )
2/navigation_offset = Vector2( 0, 0 )
2/shape_offset = Vector2( 0, 0 )
2/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
2/shape_one_way = false
2/shape_one_way_margin = 0.0
2/shapes = [ ]
2/z_index = 0
3/name = "widebelt3"
3/texture = ExtResource( 1 )
3/tex_offset = Vector2( 0, 0 )
3/modulate = Color( 1, 1, 1, 1 )
3/region = Rect2( 8, 216, 8, 8 )
3/tile_mode = 0
3/occluder_offset = Vector2( 0, 0 )
3/navigation_offset = Vector2( 0, 0 )
3/shape_offset = Vector2( 0, 0 )
3/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
3/shape_one_way = false
3/shape_one_way_margin = 0.0
3/shapes = [ ]
3/z_index = 0
4/name = "channel"
4/texture = ExtResource( 1 )
4/tex_offset = Vector2( 0, 0 )
4/modulate = Color( 1, 1, 1, 1 )
4/region = Rect2( 8, 248, 8, 8 )
4/tile_mode = 0
4/occluder_offset = Vector2( 0, 0 )
4/navigation_offset = Vector2( 0, 0 )
4/shape_offset = Vector2( 0, 0 )
4/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
4/shape_one_way = false
4/shape_one_way_margin = 0.0
4/shapes = [ ]
4/z_index = 0

View File

@ -157,7 +157,7 @@ points = PoolVector2Array( 8, 8, 0, 8, 0, 0, 8, 0 )
1/texture = ExtResource( 1 )
1/tex_offset = Vector2( 0, 0 )
1/modulate = Color( 1, 1, 1, 1 )
1/region = Rect2( 0, 48, 8, 8 )
1/region = Rect2( 72, 0, 8, 8 )
1/tile_mode = 0
1/occluder_offset = Vector2( 0, 0 )
1/navigation_offset = Vector2( 0, 0 )

View File

@ -1,16 +0,0 @@
[gd_resource type="AnimatedTexture" load_steps=5 format=2]
[ext_resource path="res://assets/sprites/2x2belt_0.tres" type="Texture" id=1]
[ext_resource path="res://assets/sprites/2x2belt_2.tres" type="Texture" id=2]
[ext_resource path="res://assets/sprites/2x2belt_1.tres" type="Texture" id=3]
[ext_resource path="res://assets/sprites/2x2belt_3.tres" type="Texture" id=4]
[resource]
frames = 4
frame_0/texture = ExtResource( 1 )
frame_1/texture = ExtResource( 3 )
frame_1/delay_sec = 0.0
frame_2/texture = ExtResource( 2 )
frame_2/delay_sec = 0.0
frame_3/texture = ExtResource( 4 )
frame_3/delay_sec = 0.0

View File

@ -1,7 +0,0 @@
[gd_resource type="AtlasTexture" load_steps=2 format=2]
[ext_resource path="res://spritesheet.png" type="Texture" id=1]
[resource]
atlas = ExtResource( 1 )
region = Rect2( 0, 208, 16, 16 )

View File

@ -1,7 +0,0 @@
[gd_resource type="AtlasTexture" load_steps=2 format=2]
[ext_resource path="res://spritesheet.png" type="Texture" id=1]
[resource]
atlas = ExtResource( 1 )
region = Rect2( 0, 192, 16, 16 )

View File

@ -1,7 +0,0 @@
[gd_resource type="AtlasTexture" load_steps=2 format=2]
[ext_resource path="res://spritesheet.png" type="Texture" id=1]
[resource]
atlas = ExtResource( 1 )
region = Rect2( 0, 176, 16, 16 )

View File

@ -1,27 +0,0 @@
[gd_resource type="SpriteFrames" load_steps=6 format=2]
[ext_resource path="res://spritesheet.png" type="Texture" id=1]
[sub_resource type="AtlasTexture" id=4]
atlas = ExtResource( 1 )
region = Rect2( 0, 224, 16, 16 )
[sub_resource type="AtlasTexture" id=3]
atlas = ExtResource( 1 )
region = Rect2( 0, 208, 16, 16 )
[sub_resource type="AtlasTexture" id=2]
atlas = ExtResource( 1 )
region = Rect2( 0, 192, 16, 16 )
[sub_resource type="AtlasTexture" id=1]
atlas = ExtResource( 1 )
region = Rect2( 0, 176, 16, 16 )
[resource]
animations = [ {
"frames": [ SubResource( 4 ), SubResource( 3 ), SubResource( 2 ), SubResource( 1 ) ],
"loop": true,
"name": "default",
"speed": 10.0
} ]

View File

@ -4,4 +4,4 @@
[resource]
atlas = ExtResource( 1 )
region = Rect2( 16, 232, 8, 8 )
region = Rect2( 16, 248, 8, 8 )

View File

@ -4,4 +4,4 @@
[resource]
atlas = ExtResource( 1 )
region = Rect2( 24, 232, 8, 8 )
region = Rect2( 24, 248, 8, 8 )

View File

@ -4,4 +4,4 @@
[resource]
atlas = ExtResource( 1 )
region = Rect2( 0, 168, 8, 8 )
region = Rect2( 8, 240, 8, 8 )

View File

@ -1,27 +0,0 @@
[gd_resource type="SpriteFrames" load_steps=6 format=2]
[ext_resource path="res://spritesheet.png" type="Texture" id=1]
[sub_resource type="AtlasTexture" id=1]
atlas = ExtResource( 1 )
region = Rect2( 0, 168, 8, 8 )
[sub_resource type="AtlasTexture" id=2]
atlas = ExtResource( 1 )
region = Rect2( 8, 168, 8, 8 )
[sub_resource type="AtlasTexture" id=3]
atlas = ExtResource( 1 )
region = Rect2( 0, 160, 8, 8 )
[sub_resource type="AtlasTexture" id=4]
atlas = ExtResource( 1 )
region = Rect2( 8, 160, 8, 8 )
[resource]
animations = [ {
"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ) ],
"loop": true,
"name": "default",
"speed": 10.0
} ]

View File

@ -4,4 +4,4 @@
[resource]
atlas = ExtResource( 1 )
region = Rect2( 8, 168, 8, 8 )
region = Rect2( 8, 248, 8, 8 )

View File

@ -4,4 +4,4 @@
[resource]
atlas = ExtResource( 1 )
region = Rect2( 16, 192, 16, 16 )
region = Rect2( 0, 80, 16, 16 )

View File

@ -4,4 +4,4 @@
[resource]
atlas = ExtResource( 1 )
region = Rect2( 0, 160, 8, 8 )
region = Rect2( 0, 64, 28, 16 )

View File

@ -4,4 +4,4 @@
[resource]
atlas = ExtResource( 1 )
region = Rect2( 8, 160, 8, 8 )
region = Rect2( 0, 48, 52, 16 )

View File

@ -4,4 +4,4 @@
[resource]
atlas = ExtResource( 1 )
region = Rect2( 16, 224, 8, 8 )
region = Rect2( 0, 112, 8, 8 )

View File

@ -4,4 +4,4 @@
[resource]
atlas = ExtResource( 1 )
region = Rect2( 16, 208, 16, 8 )
region = Rect2( 0, 96, 16, 8 )

View File

@ -4,4 +4,4 @@
[resource]
atlas = ExtResource( 1 )
region = Rect2( 16, 216, 16, 8 )
region = Rect2( 0, 104, 16, 8 )

View File

@ -4,4 +4,4 @@
[resource]
atlas = ExtResource( 1 )
region = Rect2( 24, 224, 8, 8 )
region = Rect2( 8, 112, 8, 8 )

View File

@ -5,9 +5,9 @@ onready var beltmap = $"../BeltTiles"
var dir_vectors = [Vector2(1,0), Vector2(0,-1), Vector2(-1,0), Vector2(0,1)]
var cx := 5 # offset for edge feet
var cy := 5 # offset for edge feet
var foot_vectors = [Vector2(0,0), Vector2(cx,cy), Vector2(cx,-cy), Vector2(-cx,-cy), Vector2(-cx,cy)]
export var cx := 5 # offset for edge feet
export var cy := 5 # offset for edge feet
onready var foot_vectors = [Vector2(0,0), Vector2(cx,cy), Vector2(cx,-cy), Vector2(-cx,-cy), Vector2(-cx,cy)]
var foot_weights = [3, 1, 1, 1, 1]
var total_weight = 7
#var stuck_vec = null
@ -29,7 +29,7 @@ func _process(delta):
var direction = Vector2(0, 0)
for i in len(foot_vectors):
var vec = beltmap.world_to_map(position + foot_vectors[i])
var vec = beltmap.world_to_map(position + foot_vectors[i].rotated(rotation))
if beltmap.get_cell(vec.x, vec.y) >= 0:
direction += dir_vectors[get_belt_direction(vec.x, vec.y)] * foot_weights[i]
position += direction/total_weight * belt_speed

View File

@ -30,6 +30,11 @@ window/size/height=360
window/stretch/mode="2d"
window/stretch/aspect="keep"
[physics]
2d/default_gravity=0
2d/default_gravity_vector=Vector2( 0, 0 )
[rendering]
quality/driver/driver_name="GLES2"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.