made a lil asteroids game but now messing around with packed scenes so putting a save heere
This commit is contained in:
parent
caa2cd4c11
commit
d5c27030c5
9 changed files with 129 additions and 16 deletions
43
games/asteroids/asteroids.tscn
Normal file
43
games/asteroids/asteroids.tscn
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
[gd_scene load_steps=7 format=3 uid="uid://bw1hhx7lyfonr"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://brih2jftm2tsa" path="res://games/asteroids/ship_controller.gd" id="1_6dc0m"]
|
||||
[ext_resource type="Texture2D" uid="uid://dqorec3q3h3pp" path="res://sprites/asteroidsShip.png" id="2_j0tb1"]
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_4laqq"]
|
||||
interpolation_mode = 1
|
||||
offsets = PackedFloat32Array(0, 0.882845)
|
||||
|
||||
[sub_resource type="FastNoiseLite" id="FastNoiseLite_ceqm6"]
|
||||
frequency = 0.0683
|
||||
|
||||
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_f07rl"]
|
||||
width = 640
|
||||
height = 360
|
||||
color_ramp = SubResource("Gradient_4laqq")
|
||||
noise = SubResource("FastNoiseLite_ceqm6")
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_dtqgl"]
|
||||
radius = 26.0192
|
||||
|
||||
[node name="Asteroids" type="Node"]
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="."]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
texture = SubResource("NoiseTexture2D_f07rl")
|
||||
|
||||
[node name="Ship" type="RigidBody2D" parent="."]
|
||||
position = Vector2(327, 183)
|
||||
gravity_scale = 0.0
|
||||
script = ExtResource("1_6dc0m")
|
||||
rotation_force = 10
|
||||
drag = 10
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="Ship"]
|
||||
texture = ExtResource("2_j0tb1")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Ship"]
|
||||
shape = SubResource("CircleShape2D_dtqgl")
|
||||
13
games/asteroids/ship_controller.gd
Normal file
13
games/asteroids/ship_controller.gd
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
extends RigidBody2D
|
||||
|
||||
@export var rotation_force = 1
|
||||
@export var drag = 2
|
||||
@export var top_speed = 6
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
var input = Input.get_axis("asteroids_left","asteroids_right")
|
||||
angular_velocity += rotation_force * delta * input
|
||||
print(angular_velocity)
|
||||
angular_velocity = clampf(angular_velocity, -top_speed, top_speed)
|
||||
if(input == 0):
|
||||
angular_velocity = move_toward(angular_velocity, 0, delta * drag)
|
||||
1
games/asteroids/ship_controller.gd.uid
Normal file
1
games/asteroids/ship_controller.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://brih2jftm2tsa
|
||||
Loading…
Add table
Add a link
Reference in a new issue