diff options
Diffstat (limited to 'demos/2d/pong')
-rw-r--r-- | demos/2d/pong/ball.png | bin | 203 -> 0 bytes | |||
-rw-r--r-- | demos/2d/pong/engine.cfg | 22 | ||||
-rw-r--r-- | demos/2d/pong/icon.png | bin | 956 -> 0 bytes | |||
-rw-r--r-- | demos/2d/pong/left_pallete.png | bin | 200 -> 0 bytes | |||
-rw-r--r-- | demos/2d/pong/pong.gd | 67 | ||||
-rw-r--r-- | demos/2d/pong/pong.tscn | 33 | ||||
-rw-r--r-- | demos/2d/pong/right_pallete.png | bin | 202 -> 0 bytes | |||
-rw-r--r-- | demos/2d/pong/separator.png | bin | 203 -> 0 bytes |
8 files changed, 0 insertions, 122 deletions
diff --git a/demos/2d/pong/ball.png b/demos/2d/pong/ball.png Binary files differdeleted file mode 100644 index c0f6da4f6f..0000000000 --- a/demos/2d/pong/ball.png +++ /dev/null diff --git a/demos/2d/pong/engine.cfg b/demos/2d/pong/engine.cfg deleted file mode 100644 index 418f02c06b..0000000000 --- a/demos/2d/pong/engine.cfg +++ /dev/null @@ -1,22 +0,0 @@ -[application] - -name="Pong" -main_scene="pong.tscn" -icon="res://icon.png" - -[display] - -width=640 -height=400 -stretch_2d=true - -[input] - -left_move_up=[key(A)] -left_move_down=[key(Z)] -right_move_up=[key(Up)] -right_move_down=[key(Down)] - -[render] - -default_clear_color=#ff000000 diff --git a/demos/2d/pong/icon.png b/demos/2d/pong/icon.png Binary files differdeleted file mode 100644 index eab34de53d..0000000000 --- a/demos/2d/pong/icon.png +++ /dev/null diff --git a/demos/2d/pong/left_pallete.png b/demos/2d/pong/left_pallete.png Binary files differdeleted file mode 100644 index f0d4b549d0..0000000000 --- a/demos/2d/pong/left_pallete.png +++ /dev/null diff --git a/demos/2d/pong/pong.gd b/demos/2d/pong/pong.gd deleted file mode 100644 index 81afbd9961..0000000000 --- a/demos/2d/pong/pong.gd +++ /dev/null @@ -1,67 +0,0 @@ - -extends Node2D - -# Member variables -const INITIAL_BALL_SPEED = 80 -var ball_speed = INITIAL_BALL_SPEED -var screen_size = Vector2(640, 400) - -# Default ball direction -var direction = Vector2(-1, 0) -var pad_size = Vector2(8, 32) -const PAD_SPEED = 150 - - -func _process(delta): - # Get ball position and pad rectangles - var ball_pos = get_node("ball").get_pos() - var left_rect = Rect2(get_node("left").get_pos() - pad_size*0.5, pad_size) - var right_rect = Rect2(get_node("right").get_pos() - pad_size*0.5, pad_size) - - # Integrate new ball postion - ball_pos += direction*ball_speed*delta - - # Flip when touching roof or floor - if ((ball_pos.y < 0 and direction.y < 0) or (ball_pos.y > screen_size.y and direction.y > 0)): - direction.y = -direction.y - - # Flip, change direction and increase speed when touching pads - if ((left_rect.has_point(ball_pos) and direction.x < 0) or (right_rect.has_point(ball_pos) and direction.x > 0)): - direction.x = -direction.x - ball_speed *= 1.1 - direction.y = randf()*2.0 - 1 - direction = direction.normalized() - - # Check gameover - if (ball_pos.x < 0 or ball_pos.x > screen_size.x): - ball_pos = screen_size*0.5 - ball_speed = INITIAL_BALL_SPEED - direction = Vector2(-1, 0) - - get_node("ball").set_pos(ball_pos) - - # Move left pad - var left_pos = get_node("left").get_pos() - - if (left_pos.y > 0 and Input.is_action_pressed("left_move_up")): - left_pos.y += -PAD_SPEED*delta - if (left_pos.y < screen_size.y and Input.is_action_pressed("left_move_down")): - left_pos.y += PAD_SPEED*delta - - get_node("left").set_pos(left_pos) - - # Move right pad - var right_pos = get_node("right").get_pos() - - if (right_pos.y > 0 and Input.is_action_pressed("right_move_up")): - right_pos.y += -PAD_SPEED*delta - if (right_pos.y < screen_size.y and Input.is_action_pressed("right_move_down")): - right_pos.y += PAD_SPEED*delta - - get_node("right").set_pos(right_pos) - - -func _ready(): - screen_size = get_viewport_rect().size # Get actual size - pad_size = get_node("left").get_texture().get_size() - set_process(true) diff --git a/demos/2d/pong/pong.tscn b/demos/2d/pong/pong.tscn deleted file mode 100644 index 95aecc60f3..0000000000 --- a/demos/2d/pong/pong.tscn +++ /dev/null @@ -1,33 +0,0 @@ -[gd_scene load_steps=6 format=1] - -[ext_resource path="res://pong.gd" type="Script" id=1] -[ext_resource path="res://left_pallete.png" type="Texture" id=2] -[ext_resource path="res://right_pallete.png" type="Texture" id=3] -[ext_resource path="res://separator.png" type="Texture" id=4] -[ext_resource path="res://ball.png" type="Texture" id=5] - -[node name="game" type="Node2D"] - -script/script = ExtResource( 1 ) - -[node name="left" type="Sprite" parent="."] - -transform/pos = Vector2( 67.6875, 183.208 ) -texture = ExtResource( 2 ) - -[node name="right" type="Sprite" parent="."] - -transform/pos = Vector2( 577, 187 ) -texture = ExtResource( 3 ) - -[node name="separator" type="Sprite" parent="."] - -transform/pos = Vector2( 320, 200 ) -texture = ExtResource( 4 ) - -[node name="ball" type="Sprite" parent="."] - -transform/pos = Vector2( 320.283, 188 ) -texture = ExtResource( 5 ) - - diff --git a/demos/2d/pong/right_pallete.png b/demos/2d/pong/right_pallete.png Binary files differdeleted file mode 100644 index 3cdb673a5b..0000000000 --- a/demos/2d/pong/right_pallete.png +++ /dev/null diff --git a/demos/2d/pong/separator.png b/demos/2d/pong/separator.png Binary files differdeleted file mode 100644 index 56874a59cb..0000000000 --- a/demos/2d/pong/separator.png +++ /dev/null |