From 4f553abc0fc5c3530e9767b729e3102c34fa4729 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20H=C3=BCbner?= Date: Sun, 30 Jul 2017 21:57:41 +0200 Subject: [PATCH] contents --- Asteroid.gd | 4 ++-- AsteroidSpawner.gd | 4 ++-- Drawer.gd | 12 ++++++++---- EnemyGrunt.gd | 10 ++++++++++ EnemyGrunt.tscn | 5 ++++- EnemySpawner.gd | 4 ++++ EnemySpawner.tscn | 9 +++++++++ Minimap.tscn | 14 ++++++++++---- Player.gd | 9 ++++++++- Player.tscn | 28 +++++++++++++++++++++++++++- raw/exhaust.ase | 3 +++ raw/exhaust.png | Bin 0 -> 93 bytes raw/laser_start.ase | 3 +++ raw/laser_start.png | Bin 0 -> 130 bytes raw/minimap.ase | 3 +++ raw/minimap.png | Bin 0 -> 1082 bytes raw/minimap.png.flags | 1 + raw/power_station.png | Bin 1272 -> 1250 bytes raw/railgun.ase | 3 +++ raw/railgun.png | Bin 0 -> 141 bytes raw/simple_bullet.ase | 3 +++ raw/simple_bullet.png | Bin 0 -> 149 bytes 22 files changed, 100 insertions(+), 15 deletions(-) create mode 100644 EnemyGrunt.gd create mode 100644 EnemySpawner.gd create mode 100644 EnemySpawner.tscn create mode 100644 raw/exhaust.ase create mode 100644 raw/exhaust.png create mode 100644 raw/laser_start.ase create mode 100644 raw/laser_start.png create mode 100644 raw/minimap.ase create mode 100644 raw/minimap.png create mode 100644 raw/minimap.png.flags create mode 100644 raw/railgun.ase create mode 100644 raw/railgun.png create mode 100644 raw/simple_bullet.ase create mode 100644 raw/simple_bullet.png diff --git a/Asteroid.gd b/Asteroid.gd index 6fd94ea..2135355 100644 --- a/Asteroid.gd +++ b/Asteroid.gd @@ -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 diff --git a/AsteroidSpawner.gd b/AsteroidSpawner.gd index ac1e090..4646376 100644 --- a/AsteroidSpawner.gd +++ b/AsteroidSpawner.gd @@ -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) diff --git a/Drawer.gd b/Drawer.gd index ed65024..96af121 100644 --- a/Drawer.gd +++ b/Drawer.gd @@ -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 - 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)) \ No newline at end of file + 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)) \ No newline at end of file diff --git a/EnemyGrunt.gd b/EnemyGrunt.gd new file mode 100644 index 0000000..28f5129 --- /dev/null +++ b/EnemyGrunt.gd @@ -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" diff --git a/EnemyGrunt.tscn b/EnemyGrunt.tscn index 8c359af..374132c 100644 --- a/EnemyGrunt.tscn +++ b/EnemyGrunt.tscn @@ -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 ) diff --git a/EnemySpawner.gd b/EnemySpawner.gd new file mode 100644 index 0000000..38c4d54 --- /dev/null +++ b/EnemySpawner.gd @@ -0,0 +1,4 @@ +extends Node + +func _ready(): + pass diff --git a/EnemySpawner.tscn b/EnemySpawner.tscn new file mode 100644 index 0000000..89d8edb --- /dev/null +++ b/EnemySpawner.tscn @@ -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 ) + + diff --git a/Minimap.tscn b/Minimap.tscn index 1d6c9f6..460447c 100644 --- a/Minimap.tscn +++ b/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 ) diff --git a/Player.gd b/Player.gd index e062ea9..b173e4f 100644 --- a/Player.gd +++ b/Player.gd @@ -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) diff --git a/Player.tscn b/Player.tscn index e5c390d..c5c334b 100644 --- a/Player.tscn +++ b/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 diff --git a/raw/exhaust.ase b/raw/exhaust.ase new file mode 100644 index 0000000..4325c63 --- /dev/null +++ b/raw/exhaust.ase @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:54841502f0584b2ca2afefa8a154f7b38d2325bd8bace3a269e489b344f1b9d9 +size 556 diff --git a/raw/exhaust.png b/raw/exhaust.png new file mode 100644 index 0000000000000000000000000000000000000000..20254afffa8804610bf28be9a88dd8c4e6b639db GIT binary patch literal 93 zcmeAS@N?(olHy`uVBq!ia0vp^EFjFm1|(O0oL2{=R6JcALpWw8Cjh~Z?=~O*?|i(bw;`On-yDTJbe1~?P=8= zap#<0nW{#-irf5e>rE>=@4w5VSf5S`ekS#G{n=|DBTt)fP6&PwmHO7RY3<|Fn%OsY zCCksBxA_16@8{hYPg~>s{-f=bJu6Gj%sTb$$Co*88ZKm4%@xj(jX!xbM~-P)SjZ*I zbG7k`mse-J-W}Gl_ObTc$x4hx+B$D#`rj`pbpNX2xb{a<>a#2Joj+STkj^kc5z?FTWlZ)fK2uHG$tCC7jDjdjyM7tGF$Qho9DRdfED zM?d_f%H_?2geLr{oiHikkKyG#d`s0-D&b6&!CCdhVos;E#tqPSW9zpUGrA!O+0ETnC zA}z(tM<3pC(6BeZU^%H?B&fVe{yCeK`=@?4pC;jx*Ax7jc3U!>v^P`aw6F-`;p=O$ zMs*O-h~{GER-h4yKocc^+%^PP<{U4JFf4qKg33lm_rd46u8VAqwHu!PWLP8cu6g?P z?d#VpO_1X&wCS49Z_ujW_Dgl@?0~$p#SI^~H+ftzw{-rT8?)iwH_y8J5tH9PXK60Z zJ@)68z1`cl$JdzNzO1$F^-~)jUGEH}#SAa+RMu*RKt%%dFY@ z>ij~F1}WLBw@a4J4gNH5@p1EIFI5a&R!y#weZTgL-2BJ})$KC{R3BZVKxZj9aC{oz9xIoQm50=UT+=2_gw=6QX>JbW+#F)}6h6E$^_sK>8lPklBv^fn@@N Mr>mdKI;Vst03T}JTL1t6 literal 0 HcmV?d00001 diff --git a/raw/minimap.png.flags b/raw/minimap.png.flags new file mode 100644 index 0000000..efb2b8c --- /dev/null +++ b/raw/minimap.png.flags @@ -0,0 +1 @@ +filter=false diff --git a/raw/power_station.png b/raw/power_station.png index f01d44ec6ae8a9652d8fec0346415d30e32eaa0e..7ec24d2ac10401b88d7e1152f4b1e7eaf8f402f9 100644 GIT binary patch delta 1230 zcmV;<1Tp*g3E~NmB!8(%L_t(|ob6jZYa2lj9f{Pc3_(@Qfzt#`3RNluA^HPqjq894 z7w*&;BhmcfM}#WQV*);%-0Yz1!QF z-J5NI5og1jt+j3yc$khFmU^a2XTzKAaz2Bjc1D(4uX45w2Y*Q$>s1b&Uf(2wx`LEE z8iwT-g9&sWuV8b3OV(+fUlwKkHn_elA~ZFHHRN4v?r#f15=eydan#OWIiIOtO|bx0 z@(2wfEqR1R1d#w`$=3<32&@39$+ylgP4_g=h(HQZ#gktQCPAV&`K5wXgmv^G)ocSb;{kY*C%$}ZGaHh<(Pn|%9XUm^!PE5x zz*qX|Q~j)0xp@*7M}nb_UK6bLu_GX)s@sWGjMMSm?kga)BX%!lABU&_+;A%6n|*iq zbbSGxar{F{sBMjX)T30|01l#eP8c`Af9WdX<~L3v~P6wrIFd4iVca z@dK(?`%S_A+nQe;v=LmoLdAEu*5r`NAt1V2TlEVShDY(W#?Z$^bi1b<6j zewDyPFU#qYVh+%V5KB5d1l%k)EqMTM5|oMnU_YUe658WCp(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00iap`}Xm4D0v`I0O0@meEu&WKL9SjV|H@@ O0000t47#&%4ZuA_@Jhahvvqb;fnMW-qsO_n&>wkFmbM*|a3%#yli)|Kk^mC^i qSKKU_sCD0F|8WJSl}8%Ru`!fCF(`?PpRpEbK7*&LpUXO@geCxccr)z) literal 0 HcmV?d00001 diff --git a/raw/simple_bullet.ase b/raw/simple_bullet.ase new file mode 100644 index 0000000..2a4f26e --- /dev/null +++ b/raw/simple_bullet.ase @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e527fef8ec783c4d0fe4da31c38011107940600b9db3df77621c815f35166e0a +size 578 diff --git a/raw/simple_bullet.png b/raw/simple_bullet.png new file mode 100644 index 0000000000000000000000000000000000000000..34ae7d63a923f00339cfd8ab1dc77f3dbb3c361d GIT binary patch literal 149 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFqF`h1tArezt`*#aADDXJMXS{hU z({#@1SfY`60q;x6Lw)nuRuqY!x2_D;(~oD&@PET_N0On5{Xp*W6Yg43DXG4#v$)LE x-`?8ob-HLx+97_w^33DfeDhvTG^#FU$hfIi`gX#*2|#-oJYD@<);T3K0RZ7*Gi3k( literal 0 HcmV?d00001