Added visual script pong

This commit is contained in:
Juan Linietsky
2017-07-01 07:29:03 -03:00
parent 8919981a59
commit 13eab7d1aa
56 changed files with 327 additions and 257 deletions

View File

@@ -10,7 +10,7 @@ func _process(delta):
# move up and down based on input
if (Input.is_action_pressed(which+"_move_up") and position.y > 0):
position.y -= MOVE_SPEED * delta
if (Input.is_action_pressed(which+"_move_down") and position.y < 640):
if (Input.is_action_pressed(which+"_move_down") and position.y < get_viewport_rect().size.y):
position.y += MOVE_SPEED * delta

View File

@@ -1,20 +0,0 @@
extends ColorPickerButton
func get_drag_data(pos):
# Use another colorpicker as drag preview
var cpb = ColorPickerButton.new()
cpb.set_color(get_color())
cpb.set_size(Vector2(50, 50))
set_drag_preview(cpb)
# Return color as drag data
return get_color()
func can_drop_data(pos, data):
return typeof(data) == TYPE_COLOR
func drop_data(pos, data):
set_color(data)

View File

@@ -1,5 +0,0 @@
[application]
name="Drag &amp; Drop (GUI)"
main_scene="res://drag_and_drop.scn"
icon="res://icon.png"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 806 B

View File

@@ -1,56 +0,0 @@
extends Control
# Note for the reader:
#
# This demo conveniently uses the same names for actions and for the container nodes
# that hold each remapping button. This allow to get back to the button based simply
# on the name of the corresponding action, but it might not be so simple in your project.
#
# A better approach for large-scale input remapping might be to do the connections between
# buttons and wait_for_input through the code, passing as arguments both the name of the
# action and the node, e.g.:
# button.connect("pressed", self, "wait_for_input", [ button, action ])
# Member variables
var player_actions = [ "move_up", "move_down", "move_left", "move_right", "jump" ]
var action # To register the action the UI is currently handling
var button # Button node corresponding to the above action
func wait_for_input(action_bind):
action = action_bind
# See note at the beginning of the script
button = get_node("bindings").get_node(action).get_node("Button")
get_node("contextual_help").set_text("Press a key to assign to the '" + action + "' action.")
set_process_input(true)
func _input(event):
# Handle the first pressed key
if (event.type == InputEvent.KEY):
# Register the event as handled and stop polling
get_tree().set_input_as_handled()
set_process_input(false)
# Reinitialise the contextual help label
get_node("contextual_help").set_text("Click a key binding to reassign it, or press the Cancel action.")
if (not event.is_action("ui_cancel")):
# Display the string corresponding to the pressed key
button.set_text(OS.get_scancode_string(event.scancode))
# Start by removing previously key binding(s)
for old_event in InputMap.get_action_list(action):
InputMap.action_erase_event(action, old_event)
# Add the new key binding
InputMap.action_add_event(action, event)
func _ready():
# Initialise each button with the default key binding from InputMap
var input_event
for action in player_actions:
# We assume that the key binding that we want is the first one (0), if there are several
input_event = InputMap.get_action_list(action)[0]
# See note at the beginning of the script
var button = get_node("bindings").get_node(action).get_node("Button")
button.set_text(OS.get_scancode_string(input_event.scancode))
button.connect("pressed", self, "wait_for_input", [action])

Binary file not shown.

View File

@@ -1,18 +0,0 @@
[application]
name="Input Mapping GUI"
main_scene="res://controls.scn"
icon="res://icon.png"
[display]
width=640
height=480
[input]
move_up=[key(Up)]
move_down=[key(Down)]
move_left=[key(Left)]
move_right=[key(Right)]
jump=[key(Space)]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -1,92 +0,0 @@
Copyright (c) 2009-2011 by Accademia di Belle Arti di Urbino and students of MA course of Visual design. Some rights reserved.
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

View File

@@ -1,5 +0,0 @@
[application]
name="Rich Text Label (BBCode)"
main_scene="res://rich_text_bbcode.scn"
icon="res://icon.png"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

View File

@@ -1,6 +0,0 @@
extends Panel
func _on_RichTextLabel_meta_clicked(meta):
OS.shell_open(meta)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 850 B

View File

@@ -1,9 +0,0 @@
extends Panel
func _on_back_pressed():
var s = load("res://main.scn")
var si = s.instance()
get_parent().add_child(si)
queue_free()

Binary file not shown.

View File

@@ -1,10 +0,0 @@
[application]
name="Translation Demo"
main_scene="res://main.scn"
icon="res://icon.png"
[locale]
translations=["res://translations/text.en.xl", "res://translations/text.es.xl", "res://translations/text.ja.xl"]
translation_remaps={"res://flag_uk.png":["res://flag_spain.png:es", "res://flag_japan.png:ja"]}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

View File

@@ -1,32 +0,0 @@
extends Panel
func _goto_scene():
var s = load("res://controls.scn")
var si = s.instance()
get_parent().add_child(si)
queue_free()
func _on_system_pressed():
# Will autodetect based on system, then fall back
# to english if not found
_goto_scene()
# NOTE: Changing locale will not change the text in the controls,
# The scene must be reloaded for changes to take effect.
func _on_english_pressed():
TranslationServer.set_locale("en")
_goto_scene()
func _on_spanish_pressed():
TranslationServer.set_locale("es")
_goto_scene()
func _on_japanese_pressed():
TranslationServer.set_locale("ja")
_goto_scene()

Binary file not shown.

Binary file not shown.

View File

@@ -1,3 +0,0 @@
,en,es,ja
KEY_HELLO,Hello!,Hola!,こんにちは
KEY_PUSH,Push Me!,Aprétame!,私をプッシュ
1 en es ja
2 KEY_HELLO Hello! Hola! こんにちは
3 KEY_PUSH Push Me! Aprétame! 私をプッシュ

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 B

View File

@@ -0,0 +1,23 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/ball.png-9a4ca347acb7532f6ae347744a6b04f7.stex"
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
stream=false
size_limit=0
detect_3d=true

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 956 B

View File

@@ -0,0 +1,23 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
stream=false
size_limit=0
detect_3d=true

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 B

View File

@@ -0,0 +1,23 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/left_pallete.png-bc33611074a0f886142e37c77bd2545a.stex"
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
stream=false
size_limit=0
detect_3d=true

Binary file not shown.

View File

@@ -0,0 +1,188 @@
[gd_scene load_steps=13 format=2]
[ext_resource path="res://paddle.vs" 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://ball.vs" type="Script" id=4]
[ext_resource path="res://ball.png" type="Texture" id=5]
[ext_resource path="res://separator.png" type="Texture" id=6]
[ext_resource path="res://wall.vs" type="Script" id=7]
[ext_resource path="res://ceiling_floor.vs" type="Script" id=8]
[sub_resource type="RectangleShape2D" id=1]
custom_solver_bias = 0.0
extents = Vector2( 4, 16 )
[sub_resource type="RectangleShape2D" id=2]
custom_solver_bias = 0.0
extents = Vector2( 4, 4 )
[sub_resource type="RectangleShape2D" id=3]
custom_solver_bias = 0.0
extents = Vector2( 10, 200 )
[sub_resource type="RectangleShape2D" id=4]
custom_solver_bias = 0.0
extents = Vector2( 320, 10 )
[node name="game" type="Node2D"]
[node name="left" type="Area2D" parent="."]
position = Vector2( 67.6285, 192.594 )
input_pickable = true
gravity_vec = Vector2( 0, 1 )
gravity = 98.0
linear_damp = 0.1
angular_damp = 1.0
audio_bus_override = false
audio_bus_name = "Master"
script = ExtResource( 1 )
_sections_unfolded = [ "Transform" ]
ball_dir = 1.0
[node name="sprite" type="Sprite" parent="left"]
texture = ExtResource( 2 )
_sections_unfolded = [ "Transform" ]
[node name="collision" type="CollisionShape2D" parent="left"]
shape = SubResource( 1 )
[node name="right" type="Area2D" parent="."]
position = Vector2( 563.815, 188.919 )
input_pickable = true
gravity_vec = Vector2( 0, 1 )
gravity = 98.0
linear_damp = 0.1
angular_damp = 1.0
audio_bus_override = false
audio_bus_name = "Master"
script = ExtResource( 1 )
ball_dir = -1.0
[node name="sprite" type="Sprite" parent="right"]
texture = ExtResource( 3 )
_sections_unfolded = [ "Transform" ]
[node name="collision" type="CollisionShape2D" parent="right"]
shape = SubResource( 1 )
[node name="ball" type="Area2D" parent="."]
position = Vector2( 320.5, 191.124 )
input_pickable = true
gravity_vec = Vector2( 0, 1 )
gravity = 98.0
linear_damp = 0.1
angular_damp = 1.0
audio_bus_override = false
audio_bus_name = "Master"
script = ExtResource( 4 )
_sections_unfolded = [ "Transform" ]
[node name="sprite" type="Sprite" parent="ball"]
texture = ExtResource( 5 )
_sections_unfolded = [ "Transform" ]
[node name="collision" type="CollisionShape2D" parent="ball"]
shape = SubResource( 2 )
[node name="separator" type="Sprite" parent="."]
position = Vector2( 320, 200 )
texture = ExtResource( 6 )
[node name="left_wall" type="Area2D" parent="."]
position = Vector2( -10, 200 )
input_pickable = true
gravity_vec = Vector2( 0, 1 )
gravity = 98.0
linear_damp = 0.1
angular_damp = 1.0
audio_bus_override = false
audio_bus_name = "Master"
script = ExtResource( 7 )
_sections_unfolded = [ "Transform" ]
[node name="collision" type="CollisionShape2D" parent="left_wall"]
shape = SubResource( 3 )
[node name="right_wall" type="Area2D" parent="."]
position = Vector2( 650, 200 )
input_pickable = true
gravity_vec = Vector2( 0, 1 )
gravity = 98.0
linear_damp = 0.1
angular_damp = 1.0
audio_bus_override = false
audio_bus_name = "Master"
script = ExtResource( 7 )
_sections_unfolded = [ "Transform" ]
[node name="collision" type="CollisionShape2D" parent="right_wall"]
shape = SubResource( 3 )
[node name="ceiling" type="Area2D" parent="."]
position = Vector2( 320, -10 )
input_pickable = true
gravity_vec = Vector2( 0, 1 )
gravity = 98.0
linear_damp = 0.1
angular_damp = 1.0
audio_bus_override = false
audio_bus_name = "Master"
script = ExtResource( 8 )
_sections_unfolded = [ "Transform" ]
y_direction = 1.0
[node name="collision" type="CollisionShape2D" parent="ceiling"]
shape = SubResource( 4 )
[node name="floor" type="Area2D" parent="."]
position = Vector2( 320, 410 )
input_pickable = true
gravity_vec = Vector2( 0, 1 )
gravity = 98.0
linear_damp = 0.1
angular_damp = 1.0
audio_bus_override = false
audio_bus_name = "Master"
script = ExtResource( 8 )
_sections_unfolded = [ "Transform" ]
y_direction = -1.0
[node name="collision" type="CollisionShape2D" parent="floor"]
shape = SubResource( 4 )
[connection signal="area_entered" from="left" to="left" method="_on_area_entered"]
[connection signal="area_entered" from="right" to="right" method="_on_area_entered"]
[connection signal="area_entered" from="left_wall" to="left_wall" method="_on_area_entered"]
[connection signal="area_entered" from="right_wall" to="right_wall" method="_on_area_entered"]
[connection signal="area_entered" from="ceiling" to="ceiling" method="_on_area_entered"]
[connection signal="area_entered" from="floor" to="floor" method="_on_area_entered"]

View File

@@ -0,0 +1,23 @@
[application]
icon = "res://icon.png"
main_scene = "pong.tscn"
name = "Visual Pong"
[display]
stretch_2d = true
window/height = 400
window/width = 640
[input]
left_move_down = [ InputEvent(KEY,90) ]
left_move_up = [ InputEvent(KEY,65) ]
right_move_down = [ InputEvent(KEY,16777234) ]
right_move_up = [ InputEvent(KEY,16777232) ]
[rendering]
viewport/default_clear_color = Color( 0, 0, 0, 1 )

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 B

View File

@@ -0,0 +1,23 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/right_pallete.png-fc6e4a6a7c8197834656482b94708e47.stex"
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
stream=false
size_limit=0
detect_3d=true

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 B

View File

@@ -0,0 +1,23 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/separator.png-f981c8489b9148e2e1dc63398273da74.stex"
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
stream=false
size_limit=0
detect_3d=true

Binary file not shown.