mirror of https://github.com/profan/ld-39-jam.git
more stuff, still thinking about power
This commit is contained in:
parent
4f1a3fc4ea
commit
9834ca9ace
|
@ -0,0 +1,28 @@
|
||||||
|
extends KinematicBody2D
|
||||||
|
|
||||||
|
var rect = Rect2(0, 0, 0, 0)
|
||||||
|
var velocity = Vector2(0, 0)
|
||||||
|
var rot_vel = 0
|
||||||
|
|
||||||
|
var max_vel = 6 # pixels per second?
|
||||||
|
var max_rot_vel = 2.5 # degrees per second
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
randomize()
|
||||||
|
velocity.x = floor(rand_range(-max_vel, max_vel))
|
||||||
|
velocity.y = floor(rand_range(-max_vel, max_vel))
|
||||||
|
rect.size.x = floor(rand_range(32, 64))
|
||||||
|
rect.size.y = floor(rand_range(32, 64))
|
||||||
|
rot_vel = deg2rad(floor(rand_range(1, max_rot_vel)))
|
||||||
|
set_fixed_process(true)
|
||||||
|
|
||||||
|
func _fixed_process(delta):
|
||||||
|
#var cur_pos = get_pos()
|
||||||
|
#cur_pos.x = cur_pos.x % get_viewport().get_rect().size.x
|
||||||
|
#cur_pos.y = cur_pos.y % get_viewport().get_rect().size.y
|
||||||
|
#set_pos(cur_pos)
|
||||||
|
self.move(velocity)
|
||||||
|
self.rotate(rot_vel)
|
||||||
|
|
||||||
|
func _draw():
|
||||||
|
draw_rect(rect, Color(0x42, 0x8b, 0xca))
|
|
@ -0,0 +1,13 @@
|
||||||
|
[gd_scene load_steps=2 format=1]
|
||||||
|
|
||||||
|
[ext_resource path="res://Asteroid.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[node name="Asteroid" type="KinematicBody2D"]
|
||||||
|
|
||||||
|
input/pickable = false
|
||||||
|
collision/layers = 1
|
||||||
|
collision/mask = 1
|
||||||
|
collision/margin = 0.08
|
||||||
|
script/script = ExtResource( 1 )
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
var Asteroid = load("res://Asteroid.tscn")
|
||||||
|
|
||||||
|
var total_asteroids = 0
|
||||||
|
var total_time_passed = 0
|
||||||
|
var current_threshold = 5
|
||||||
|
|
||||||
|
# delay between each spawn of asteroid
|
||||||
|
var spawn_delay = 1 # seconds
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
set_fixed_process(true)
|
||||||
|
|
||||||
|
func _fixed_process(delta):
|
||||||
|
|
||||||
|
# we gots teh times
|
||||||
|
total_time_passed += delta
|
||||||
|
spawn_delay -= delta
|
||||||
|
|
||||||
|
if total_asteroids < current_threshold and spawn_delay <= 0:
|
||||||
|
|
||||||
|
var new_asteroid = Asteroid.instance()
|
||||||
|
|
||||||
|
randomize()
|
||||||
|
var x = floor(rand_range(1, get_viewport().get_rect().size.x))
|
||||||
|
var y = floor(rand_range(1, get_viewport().get_rect().size.y))
|
||||||
|
var spawn_pos = Vector2(x, y)
|
||||||
|
|
||||||
|
print(spawn_pos)
|
||||||
|
new_asteroid.set_pos(spawn_pos)
|
||||||
|
get_parent().add_child(new_asteroid) # add to tree
|
||||||
|
|
||||||
|
total_asteroids += 1
|
|
@ -0,0 +1,9 @@
|
||||||
|
[gd_scene load_steps=2 format=1]
|
||||||
|
|
||||||
|
[ext_resource path="res://AsteroidSpawner.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[node name="AsteroidSpawner" type="Node"]
|
||||||
|
|
||||||
|
script/script = ExtResource( 1 )
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
[gd_scene load_steps=2 format=1]
|
[gd_scene load_steps=3 format=1]
|
||||||
|
|
||||||
[ext_resource path="res://Player.tscn" type="PackedScene" id=1]
|
[ext_resource path="res://Player.tscn" type="PackedScene" id=1]
|
||||||
|
[ext_resource path="res://AsteroidSpawner.tscn" type="PackedScene" id=2]
|
||||||
|
|
||||||
[node name="Game" type="Node"]
|
[node name="Game" type="Node"]
|
||||||
|
|
||||||
|
@ -8,4 +9,6 @@
|
||||||
|
|
||||||
transform/pos = Vector2( 92.7742, 71.7896 )
|
transform/pos = Vector2( 92.7742, 71.7896 )
|
||||||
|
|
||||||
|
[node name="AsteroidSpawner" parent="." instance=ExtResource( 2 )]
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue