summaryrefslogtreecommitdiff
path: root/demos/2d/shower_of_bullets
diff options
context:
space:
mode:
Diffstat (limited to 'demos/2d/shower_of_bullets')
-rw-r--r--demos/2d/shower_of_bullets/bullet.pngbin477 -> 0 bytes
-rw-r--r--demos/2d/shower_of_bullets/bullets.gd71
-rw-r--r--demos/2d/shower_of_bullets/engine.cfg16
-rw-r--r--demos/2d/shower_of_bullets/face_happy.pngbin1243 -> 0 bytes
-rw-r--r--demos/2d/shower_of_bullets/face_sad.pngbin1240 -> 0 bytes
-rw-r--r--demos/2d/shower_of_bullets/icon.pngbin2777 -> 0 bytes
-rw-r--r--demos/2d/shower_of_bullets/shower.gd25
-rw-r--r--demos/2d/shower_of_bullets/shower.tscn51
8 files changed, 0 insertions, 163 deletions
diff --git a/demos/2d/shower_of_bullets/bullet.png b/demos/2d/shower_of_bullets/bullet.png
deleted file mode 100644
index 7466374129..0000000000
--- a/demos/2d/shower_of_bullets/bullet.png
+++ /dev/null
Binary files differ
diff --git a/demos/2d/shower_of_bullets/bullets.gd b/demos/2d/shower_of_bullets/bullets.gd
deleted file mode 100644
index e0eba2682a..0000000000
--- a/demos/2d/shower_of_bullets/bullets.gd
+++ /dev/null
@@ -1,71 +0,0 @@
-
-extends Node2D
-
-# This demo is an example of controling a high number of 2D objects with logic and collision without using scene nodes.
-# This technique is a lot more efficient than using instancing and nodes, but requires more programming and is less visual
-
-# Member variables
-const BULLET_COUNT = 500
-const SPEED_MIN = 20
-const SPEED_MAX = 50
-
-var bullets = []
-var shape
-
-
-# Inner classes
-class Bullet:
- var pos = Vector2()
- var speed = 1.0
- var body = RID()
-
-
-func _draw():
- var t = preload("res://bullet.png")
- var tofs = -t.get_size()*0.5
- for b in bullets:
- draw_texture(t, b.pos + tofs)
-
-
-func _process(delta):
- var width = get_viewport_rect().size.x*2.0
- var mat = Matrix32()
- for b in bullets:
- b.pos.x -= b.speed*delta
- if (b.pos.x < -30):
- b.pos.x += width
- mat.o = b.pos
-
- Physics2DServer.body_set_state(b.body, Physics2DServer.BODY_STATE_TRANSFORM, mat)
-
- update()
-
-
-func _ready():
- shape = Physics2DServer.shape_create(Physics2DServer.SHAPE_CIRCLE)
- Physics2DServer.shape_set_data(shape, 8) # Radius
-
- for i in range(BULLET_COUNT):
- var b = Bullet.new()
- b.speed = rand_range(SPEED_MIN, SPEED_MAX)
- b.body = Physics2DServer.body_create(Physics2DServer.BODY_MODE_KINEMATIC)
- Physics2DServer.body_set_space(b.body, get_world_2d().get_space())
- Physics2DServer.body_add_shape(b.body, shape)
-
- b.pos = Vector2(get_viewport_rect().size * Vector2(randf()*2.0, randf())) # Twice as long
- b.pos.x += get_viewport_rect().size.x # Start outside
- var mat = Matrix32()
- mat.o = b.pos
- Physics2DServer.body_set_state(b.body, Physics2DServer.BODY_STATE_TRANSFORM, mat)
-
- bullets.append(b)
-
- set_process(true)
-
-
-func _exit_tree():
- for b in bullets:
- Physics2DServer.free_rid(b.body)
-
- Physics2DServer.free_rid(shape)
- bullets.clear()
diff --git a/demos/2d/shower_of_bullets/engine.cfg b/demos/2d/shower_of_bullets/engine.cfg
deleted file mode 100644
index 8db2ae9006..0000000000
--- a/demos/2d/shower_of_bullets/engine.cfg
+++ /dev/null
@@ -1,16 +0,0 @@
-[application]
-
-name="Bullet Shower"
-main_scene="res://shower.tscn"
-icon="res://icon.png"
-
-[display]
-
-width=1024
-height=600
-resizable=true
-stretch_aspect="keep"
-
-[physics_2d]
-
-cell_size=64
diff --git a/demos/2d/shower_of_bullets/face_happy.png b/demos/2d/shower_of_bullets/face_happy.png
deleted file mode 100644
index 6ed643b62d..0000000000
--- a/demos/2d/shower_of_bullets/face_happy.png
+++ /dev/null
Binary files differ
diff --git a/demos/2d/shower_of_bullets/face_sad.png b/demos/2d/shower_of_bullets/face_sad.png
deleted file mode 100644
index d6318b20a3..0000000000
--- a/demos/2d/shower_of_bullets/face_sad.png
+++ /dev/null
Binary files differ
diff --git a/demos/2d/shower_of_bullets/icon.png b/demos/2d/shower_of_bullets/icon.png
deleted file mode 100644
index 432c74a5a3..0000000000
--- a/demos/2d/shower_of_bullets/icon.png
+++ /dev/null
Binary files differ
diff --git a/demos/2d/shower_of_bullets/shower.gd b/demos/2d/shower_of_bullets/shower.gd
deleted file mode 100644
index 50c1109489..0000000000
--- a/demos/2d/shower_of_bullets/shower.gd
+++ /dev/null
@@ -1,25 +0,0 @@
-
-extends Node2D
-
-# Member variables
-var touching = 0
-
-func _input(event):
- if (event.type == InputEvent.MOUSE_MOTION):
- get_node("player").set_pos(event.pos - Vector2(0, 16))
-
-
-func _on_player_body_enter_shape(body_id, body, body_shape, area_shape):
- touching += 1
- if (touching == 1):
- get_node("player/sprite").set_frame(1)
-
-
-func _on_player_body_exit_shape(body_id, body, body_shape, area_shape):
- touching -= 1
- if (touching == 0):
- get_node("player/sprite").set_frame(0)
-
-
-func _ready():
- set_process_input(true)
diff --git a/demos/2d/shower_of_bullets/shower.tscn b/demos/2d/shower_of_bullets/shower.tscn
deleted file mode 100644
index 9df555f96a..0000000000
--- a/demos/2d/shower_of_bullets/shower.tscn
+++ /dev/null
@@ -1,51 +0,0 @@
-[gd_scene load_steps=7 format=1]
-
-[ext_resource path="res://shower.gd" type="Script" id=1]
-[ext_resource path="res://bullets.gd" type="Script" id=2]
-[ext_resource path="res://face_happy.png" type="Texture" id=3]
-[ext_resource path="res://face_sad.png" type="Texture" id=4]
-
-[sub_resource type="CircleShape2D" id=1]
-
-custom_solver_bias = 0.0
-radius = 14.0
-
-[sub_resource type="SpriteFrames" id=2]
-
-frames = [ ExtResource( 3 ), ExtResource( 4 ) ]
-
-[node name="shower" type="Node2D"]
-
-script/script = ExtResource( 1 )
-
-[node name="bullets" type="Node2D" parent="."]
-
-script/script = ExtResource( 2 )
-
-[node name="player" type="Area2D" parent="."]
-
-input/pickable = true
-shapes/0/shape = SubResource( 1 )
-shapes/0/transform = Matrix32( 1, 0, 0, 1, 0, 0 )
-shapes/0/trigger = false
-gravity_vec = Vector2( 0, 1 )
-gravity = 98.0
-linear_damp = 0.1
-angular_damp = 1.0
-
-[node name="sprite" type="AnimatedSprite" parent="player"]
-
-transform/scale = Vector2( 0.5, 0.5 )
-frames = SubResource( 2 )
-
-[node name="collision" type="CollisionShape2D" parent="player"]
-
-shape = SubResource( 1 )
-trigger = false
-_update_shape_index = -1
-
-[connection signal="body_enter_shape" from="player" to="." method="_on_player_body_enter_shape"]
-
-[connection signal="body_exit_shape" from="player" to="." method="_on_player_body_exit_shape"]
-
-