contents
|
@ -9,8 +9,8 @@ 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))
|
||||
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))
|
||||
rect.pos.x = -rect.size.x / 2
|
||||
|
|
|
@ -26,8 +26,8 @@ func _fixed_process(delta):
|
|||
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 x = floor(rand_range(-2000, 2000))
|
||||
var y = floor(rand_range(-2000, 2000))
|
||||
var spawn_pos = Vector2(x, y)
|
||||
|
||||
new_asteroid.set_pos(spawn_pos)
|
||||
|
|
|
@ -27,7 +27,11 @@ func _draw():
|
|||
var s_x = s_mw + (ent_pos.x / vp_rect.size.x) - (cam_pos.x / vp_rect.size.x) + 32
|
||||
var s_y = s_mh + (ent_pos.y / vp_rect.size.y) - (cam_pos.y / vp_rect.size.y) + 32
|
||||
|
||||
var rect = Rect2(Vector2(48, 48), Vector2(vp_rect.size.x - 32, vp_rect.size.y - 32))
|
||||
if rect.has_point(Vector2(s_x, s_y)):
|
||||
if ent.type() == "Asteroid":
|
||||
draw_rect(Rect2(s_x, s_y, 2, 2), Color(1, 1, 1))
|
||||
elif ent.type() == "PowerStation":
|
||||
draw_rect(Rect2(s_x, s_y, 4, 4), Color(0, 0, 1))
|
||||
elif ent.type() == "EnemyGrunt":
|
||||
draw_rect(Rect2(s_x, s_y, 2, 2), Color(1, 0, 0))
|
|
@ -0,0 +1,10 @@
|
|||
extends KinematicBody2D
|
||||
|
||||
func _ready():
|
||||
var t = get_tree()
|
||||
var r = t.get_root()
|
||||
var n = r.get_node("Game/MinimapControl")
|
||||
n.register_entity(self)
|
||||
|
||||
func type():
|
||||
return "EnemyGrunt"
|
|
@ -1,4 +1,6 @@
|
|||
[gd_scene format=1]
|
||||
[gd_scene load_steps=2 format=1]
|
||||
|
||||
[ext_resource path="res://EnemyGrunt.gd" type="Script" id=1]
|
||||
|
||||
[node name="EnemyGrunt" type="KinematicBody2D"]
|
||||
|
||||
|
@ -6,5 +8,6 @@ input/pickable = false
|
|||
collision/layers = 1
|
||||
collision/mask = 1
|
||||
collision/margin = 0.08
|
||||
script/script = ExtResource( 1 )
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
extends Node
|
||||
|
||||
func _ready():
|
||||
pass
|
|
@ -0,0 +1,9 @@
|
|||
[gd_scene load_steps=2 format=1]
|
||||
|
||||
[ext_resource path="res://EnemySpawner.gd" type="Script" id=1]
|
||||
|
||||
[node name="EnemySpawner" type="Node"]
|
||||
|
||||
script/script = ExtResource( 1 )
|
||||
|
||||
|
14
Minimap.tscn
|
@ -1,9 +1,10 @@
|
|||
[gd_scene load_steps=5 format=1]
|
||||
[gd_scene load_steps=6 format=1]
|
||||
|
||||
[ext_resource path="res://MinimapControl.gd" type="Script" id=1]
|
||||
[ext_resource path="res://Minimap.gd" type="Script" id=2]
|
||||
[ext_resource path="res://MinimapTarget.gd" type="Script" id=3]
|
||||
[ext_resource path="res://Drawer.gd" type="Script" id=4]
|
||||
[ext_resource path="res://raw/minimap.png" type="Texture" id=4]
|
||||
[ext_resource path="res://Drawer.gd" type="Script" id=5]
|
||||
|
||||
[node name="MinimapControl" type="CanvasLayer"]
|
||||
|
||||
|
@ -42,7 +43,7 @@ stretch_mode = 0
|
|||
rect = Rect2( 0, 0, 128, 128 )
|
||||
own_world = false
|
||||
world = null
|
||||
transparent_bg = false
|
||||
transparent_bg = true
|
||||
render_target/enabled = true
|
||||
render_target/v_flip = false
|
||||
render_target/clear_on_new_frame = false
|
||||
|
@ -55,8 +56,13 @@ physics/object_picking = false
|
|||
gui/disable_input = false
|
||||
script/script = ExtResource( 3 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="Minimap/Viewport"]
|
||||
|
||||
transform/pos = Vector2( 96, 96 )
|
||||
texture = ExtResource( 4 )
|
||||
|
||||
[node name="Drawer" type="Node2D" parent="Minimap/Viewport"]
|
||||
|
||||
script/script = ExtResource( 4 )
|
||||
script/script = ExtResource( 5 )
|
||||
|
||||
|
||||
|
|
|
@ -2,15 +2,17 @@ extends KinematicBody2D
|
|||
|
||||
onready var sprite = get_node("Sprite")
|
||||
onready var camera = get_node("Camera2D")
|
||||
onready var particles = get_node("Sprite/Particles2D")
|
||||
|
||||
var mov_speed = 64 # pixels per second
|
||||
var ship_vel = Vector2(0, 0)
|
||||
var ship_max_vel = 100 # pixels per second
|
||||
var ship_accel = 25 # pixels per second.. per second?
|
||||
var ship_turn_speed = deg2rad(360) # degrees per second.. i guess?
|
||||
var ship_dir = Vector2(1, 0)
|
||||
var ship_mass = 61
|
||||
|
||||
var ship_dir = Vector2(1, 0)
|
||||
var is_moving = false
|
||||
|
||||
func _ready():
|
||||
set_fixed_process(true)
|
||||
|
@ -31,9 +33,12 @@ func _fixed_process(delta):
|
|||
turn_towards(delta, get_global_mouse_pos())
|
||||
|
||||
if Input.is_action_pressed("player_move_forwards"):
|
||||
is_moving = true
|
||||
mov_delta += -ship_dir
|
||||
elif Input.is_action_pressed("player_move_backwards"):
|
||||
mov_delta += ship_dir
|
||||
else:
|
||||
is_moving = false
|
||||
|
||||
if Input.is_action_pressed("player_attack_primary"):
|
||||
pass
|
||||
|
@ -53,3 +58,5 @@ func _fixed_process(delta):
|
|||
|
||||
self.move(ship_vel)
|
||||
ship_vel = ship_vel / (delta * ship_mass)
|
||||
|
||||
particles.set_emitting(is_moving)
|
||||
|
|
28
Player.tscn
|
@ -1,7 +1,8 @@
|
|||
[gd_scene load_steps=3 format=1]
|
||||
[gd_scene load_steps=4 format=1]
|
||||
|
||||
[ext_resource path="res://Player.gd" type="Script" id=1]
|
||||
[ext_resource path="res://img/player_ship.tex" type="Texture" id=2]
|
||||
[ext_resource path="res://raw/exhaust.png" type="Texture" id=3]
|
||||
|
||||
[node name="Player" type="KinematicBody2D"]
|
||||
|
||||
|
@ -16,6 +17,31 @@ script/script = ExtResource( 1 )
|
|||
|
||||
texture = ExtResource( 2 )
|
||||
|
||||
[node name="Particles2D" type="Particles2D" parent="Sprite"]
|
||||
|
||||
transform/pos = Vector2( 0, 13.1031 )
|
||||
config/amount = 256
|
||||
config/lifetime = 2.0
|
||||
config/process_mode = 1
|
||||
config/local_space = false
|
||||
config/texture = ExtResource( 3 )
|
||||
params/direction = 0.0
|
||||
params/spread = 24.0
|
||||
params/linear_velocity = 32.0
|
||||
params/spin_velocity = 0.0
|
||||
params/orbit_velocity = 0.0
|
||||
params/gravity_direction = 0.0
|
||||
params/gravity_strength = 9.8
|
||||
params/radial_accel = 0.0
|
||||
params/tangential_accel = 0.0
|
||||
params/damping = 0.0
|
||||
params/initial_angle = 0.0
|
||||
params/initial_size = 2.0
|
||||
params/final_size = 1.0
|
||||
params/hue_variation = 0.0
|
||||
params/anim_speed_scale = 1.0
|
||||
params/anim_initial_pos = 0.0
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="."]
|
||||
|
||||
anchor_mode = 1
|
||||
|
|
After Width: | Height: | Size: 93 B |
After Width: | Height: | Size: 130 B |
|
@ -0,0 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:1d0b15e4d517c75f72f5046a83afe2a535dc4c7a040cd1112c9b34a289f872b9
|
||||
size 834
|
After Width: | Height: | Size: 1.1 KiB |
|
@ -0,0 +1 @@
|
|||
filter=false
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 141 B |
|
@ -0,0 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:e527fef8ec783c4d0fe4da31c38011107940600b9db3df77621c815f35166e0a
|
||||
size 578
|
After Width: | Height: | Size: 149 B |