first commit
This commit is contained in:
commit
a673773183
21 changed files with 305 additions and 0 deletions
9
pinball/ball.gd
Normal file
9
pinball/ball.gd
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
extends RigidBody2D
|
||||
|
||||
func _ready() -> void:
|
||||
mass = 1.0
|
||||
gravity_scale = 1.0
|
||||
physics_material_override.bounce = 0.8
|
||||
linear_damp = 0.1
|
||||
contact_monitor = true
|
||||
max_contacts_reported = 4
|
||||
1
pinball/ball.gd.uid
Normal file
1
pinball/ball.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://by01oc4lqlma4
|
||||
19
pinball/ball.tscn
Normal file
19
pinball/ball.tscn
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
[gd_scene load_steps=5 format=3 uid="uid://bri6gyx0bp87t"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://mucscwsbmfoq" path="res://assets/ball.png" id="1_qbdsi"]
|
||||
[ext_resource type="Script" uid="uid://by01oc4lqlma4" path="res://pinball/ball.gd" id="1_qu1p4"]
|
||||
|
||||
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_s64ax"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_o681m"]
|
||||
radius = 4.0
|
||||
|
||||
[node name="Ball" type="RigidBody2D"]
|
||||
physics_material_override = SubResource("PhysicsMaterial_s64ax")
|
||||
script = ExtResource("1_qu1p4")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("CircleShape2D_o681m")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("1_qbdsi")
|
||||
8
pinball/bumper.tscn
Normal file
8
pinball/bumper.tscn
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://b4mlc72u3danp"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://bjkqwg7x8boun" path="res://assets/bumper.png" id="1_gph4f"]
|
||||
|
||||
[node name="Bumper" type="Node2D"]
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("1_gph4f")
|
||||
35
pinball/flipper.gd
Normal file
35
pinball/flipper.gd
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
extends RigidBody2D
|
||||
|
||||
@export var flip_strength: float = 50.0
|
||||
@export var rest_strength: float = 20.0
|
||||
@export var right_flipper: bool = false
|
||||
|
||||
var rest_angle: float = 0.0
|
||||
var flipped_angle: float = -60.0 #deg
|
||||
|
||||
func _ready() -> void:
|
||||
gravity_scale = 0.0
|
||||
freeze = false
|
||||
|
||||
if right_flipper:
|
||||
flipped_angle *= -1
|
||||
rest_angle *= -1
|
||||
|
||||
rotation_degrees = rest_angle
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if right_flipper and event.is_action_pressed("right_flipper"):
|
||||
flip()
|
||||
elif !right_flipper and event.is_action_pressed("left_flipper"):
|
||||
flip()
|
||||
|
||||
if right_flipper and event.is_action_released("right_flipper"):
|
||||
rest()
|
||||
elif !right_flipper and event.is_action_released("left_flipper"):
|
||||
rest()
|
||||
|
||||
func flip() -> void:
|
||||
angular_velocity = flip_strength
|
||||
|
||||
func rest() -> void:
|
||||
angular_velocity = -rest_strength
|
||||
1
pinball/flipper.gd.uid
Normal file
1
pinball/flipper.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://fnuonblf0vk2
|
||||
15
pinball/flipper.tscn
Normal file
15
pinball/flipper.tscn
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://idjf5lor2py2"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://b1r22t327pigo" path="res://assets/flipper.png" id="1_duuhy"]
|
||||
|
||||
[sub_resource type="ConcavePolygonShape2D" id="ConcavePolygonShape2D_duuhy"]
|
||||
|
||||
[node name="Flipper" type="RigidBody2D"]
|
||||
|
||||
[node name="Flipper" type="Sprite2D" parent="."]
|
||||
position = Vector2(-26, -3)
|
||||
texture = ExtResource("1_duuhy")
|
||||
offset = Vector2(26, 3)
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("ConcavePolygonShape2D_duuhy")
|
||||
3
pinball/table.tscn
Normal file
3
pinball/table.tscn
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
[gd_scene format=3 uid="uid://2bnojgnoj8df"]
|
||||
|
||||
[node name="Table" type="Node2D"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue