added a very basic boat simulation
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
[gd_resource type="Environment" load_steps=2 format=2]
|
||||
|
||||
[sub_resource type="ProceduralSky" id=1]
|
||||
|
||||
[resource]
|
||||
background_mode = 2
|
||||
background_sky = SubResource( 1 )
|
||||
|
@@ -11,8 +11,22 @@ config_version=4
|
||||
[application]
|
||||
|
||||
config/name="SailGame"
|
||||
run/main_scene="res://resources/scenes/Level1.tscn"
|
||||
config/icon="res://icon.png"
|
||||
|
||||
[input]
|
||||
|
||||
right={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":16777233,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
left={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":16777231,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[physics]
|
||||
|
||||
common/enable_pause_aware_picking=true
|
||||
|
10
resources/scenes/Level1.tscn
Normal file
10
resources/scenes/Level1.tscn
Normal file
@@ -0,0 +1,10 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://resources/scenes/Player.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://resources/scenes/Player.gd" type="Script" id=2]
|
||||
|
||||
[node name="Level1" type="Node2D"]
|
||||
|
||||
[node name="Player" parent="." instance=ExtResource( 1 )]
|
||||
position = Vector2( 304, 152 )
|
||||
script = ExtResource( 2 )
|
37
resources/scenes/Player.gd
Normal file
37
resources/scenes/Player.gd
Normal file
@@ -0,0 +1,37 @@
|
||||
extends KinematicBody2D
|
||||
|
||||
const WIND = 20
|
||||
const SPEED = 400
|
||||
const STEERING = deg2rad(5)
|
||||
const WINDLIMIT = deg2rad(180-45)
|
||||
const WINDDIR = Vector2(0,1)
|
||||
const STEERPEN = 1
|
||||
const ACCELERATION = 2
|
||||
|
||||
var velocity = Vector2(0,10)
|
||||
|
||||
func _calculate_velocity(_velocity, _acceleration, _rotation):
|
||||
velocity = _velocity * _acceleration
|
||||
velocity = velocity.clamped(_calculate_maxspeed())
|
||||
return velocity.rotated(_rotation)
|
||||
|
||||
func _calculate_maxspeed():
|
||||
var angle_to_wind = WINDDIR.angle_to(velocity)
|
||||
if angle_to_wind > WINDLIMIT || angle_to_wind < -WINDLIMIT:
|
||||
return 0.1
|
||||
else:
|
||||
return 75
|
||||
|
||||
func _physics_process(_delta):
|
||||
if Input.is_action_pressed("right"):
|
||||
velocity = _calculate_velocity(velocity, STEERPEN, STEERING)
|
||||
rotate(STEERING)
|
||||
elif Input.is_action_pressed("left"):
|
||||
velocity = _calculate_velocity(velocity, STEERPEN, -STEERING)
|
||||
rotate(-STEERING)
|
||||
else:
|
||||
velocity = _calculate_velocity(velocity, ACCELERATION, 0)
|
||||
velocity = move_and_slide(velocity)
|
||||
|
||||
func _ready():
|
||||
pass
|
14
resources/scenes/Player.tscn
Normal file
14
resources/scenes/Player.tscn
Normal file
@@ -0,0 +1,14 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://resources/sprites/bluedotwithline.png" type="Texture" id=1]
|
||||
|
||||
[sub_resource type="CircleShape2D" id=1]
|
||||
|
||||
[node name="Player" type="KinematicBody2D"]
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
texture = ExtResource( 1 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
scale = Vector2( 5, 5 )
|
||||
shape = SubResource( 1 )
|
BIN
resources/sprites/blackdot.png
Normal file
BIN
resources/sprites/blackdot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
35
resources/sprites/blackdot.png.import
Normal file
35
resources/sprites/blackdot.png.import
Normal file
@@ -0,0 +1,35 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/blackdot.png-1a5bec39eabfc1e72a781050e9b2a025.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://resources/sprites/blackdot.png"
|
||||
dest_files=[ "res://.import/blackdot.png-1a5bec39eabfc1e72a781050e9b2a025.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=true
|
||||
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
|
BIN
resources/sprites/bluedot.png
Normal file
BIN
resources/sprites/bluedot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
35
resources/sprites/bluedot.png.import
Normal file
35
resources/sprites/bluedot.png.import
Normal file
@@ -0,0 +1,35 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/bluedot.png-822b3607b0ee4390ae445e3d316914d5.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://resources/sprites/bluedot.png"
|
||||
dest_files=[ "res://.import/bluedot.png-822b3607b0ee4390ae445e3d316914d5.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=true
|
||||
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
|
BIN
resources/sprites/bluedotwithline.png
Normal file
BIN
resources/sprites/bluedotwithline.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.6 KiB |
35
resources/sprites/bluedotwithline.png.import
Normal file
35
resources/sprites/bluedotwithline.png.import
Normal file
@@ -0,0 +1,35 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/bluedotwithline.png-9bd6c79f9e749d1334cb830595876e9b.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://resources/sprites/bluedotwithline.png"
|
||||
dest_files=[ "res://.import/bluedotwithline.png-9bd6c79f9e749d1334cb830595876e9b.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=true
|
||||
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
|
BIN
resources/sprites/reddot.png
Normal file
BIN
resources/sprites/reddot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
35
resources/sprites/reddot.png.import
Normal file
35
resources/sprites/reddot.png.import
Normal file
@@ -0,0 +1,35 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/reddot.png-01df36789040b36e0f02d697caf9dd6d.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://resources/sprites/reddot.png"
|
||||
dest_files=[ "res://.import/reddot.png-01df36789040b36e0f02d697caf9dd6d.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=true
|
||||
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
|
Reference in New Issue
Block a user