Merge branch 'master' of https://github.com/not-surt/godot into snapping2
Conflicts: tools/editor/plugins/canvas_item_editor_plugin.cpp tools/editor/plugins/canvas_item_editor_plugin.h2.0
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
@ -0,0 +1,4 @@
|
||||
[application]
|
||||
|
||||
name="Area 2D Input Events"
|
||||
main_scene="res://input.scn"
|
||||
@ -0,0 +1,16 @@
|
||||
|
||||
extends Area2D
|
||||
|
||||
#virtual from CollisionObject2D (also available as signal)
|
||||
func _input_event(viewport, event, shape_idx):
|
||||
#convert event to local coordinates
|
||||
if (event.type==InputEvent.MOUSE_MOTION):
|
||||
event = make_input_local( event )
|
||||
get_node("label").set_text(str(event.pos))
|
||||
|
||||
#virtual from CollisionObject2D (also available as signal)
|
||||
func _mouse_exit():
|
||||
get_node("label").set_text("")
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
::res://::1422910453
|
||||
floor.png::ImageTexture::1422910453::
|
||||
fog.gd::GDScript::1422910025::
|
||||
fog.png::ImageTexture::1422908128::
|
||||
fog.scn::PackedScene::1422909435::
|
||||
fog.xml::TileSet::1422909324::
|
||||
icon.png::ImageTexture::1422811193::
|
||||
tile_edit.scn::PackedScene::1422909313::
|
||||
troll.gd::GDScript::1422909940::
|
||||
troll.png::ImageTexture::1418669358::
|
||||
troll.scn::PackedScene::1418669358::
|
||||
@ -0,0 +1,12 @@
|
||||
[application]
|
||||
|
||||
name="Fog of War"
|
||||
main_scene="res://fog.scn"
|
||||
icon="icon.png"
|
||||
|
||||
[input]
|
||||
|
||||
move_up=[key(Up)]
|
||||
move_bottom=[key(Down)]
|
||||
move_left=[key(Left)]
|
||||
move_right=[key(Right)]
|
||||
|
After Width: | Height: | Size: 572 B |
@ -0,0 +1,86 @@
|
||||
|
||||
extends TileMap
|
||||
|
||||
# member variables here, example:
|
||||
# var a=2
|
||||
# var b="textvar"
|
||||
|
||||
# boundarys for the fog rectangle
|
||||
var x_min = -20 # left start tile
|
||||
var x_max = 20 # right end tile
|
||||
var y_min = -20 # top start tile
|
||||
var y_max = 20 # bottom end tile
|
||||
|
||||
var position # players position
|
||||
|
||||
# iteration variables
|
||||
var x
|
||||
var y
|
||||
|
||||
# variable to check if player moved
|
||||
var x_old
|
||||
var y_old
|
||||
|
||||
# array to build up the visible area like a square
|
||||
# first value determines the width/height of the tip
|
||||
# here it would be 2*2 + 1 = 5 tiles wide/high
|
||||
# second value determines the total squares size
|
||||
# here it would be 5*2 + 1 = 10 tiles wide/high
|
||||
var l = range(2,5)
|
||||
|
||||
# process that runs in realtime
|
||||
func _fixed_process(delta):
|
||||
position = get_node("../troll").get_pos()
|
||||
|
||||
# calculate the corresponding tile
|
||||
# from the players position
|
||||
x = int(position.x/get_cell_size().x)
|
||||
# switching from positive to negative tile positions
|
||||
# causes problems because of rounding problems
|
||||
if position.x < 0:
|
||||
x -= 1 # correct negative values
|
||||
|
||||
y = int(position.y/get_cell_size().y)
|
||||
if position.y < 0:
|
||||
y -= 1
|
||||
|
||||
# check if the player moved one tile further
|
||||
if (x_old != x) or (y_old != y):
|
||||
|
||||
# create the transparent part (visited area)
|
||||
var end = l.size()-1
|
||||
var start = 0
|
||||
for steps in range(l.size()):
|
||||
for m in range(x-l[end]-1,x+l[end]+2):
|
||||
for n in range(y-l[start]-1,y+l[start]+2):
|
||||
if get_cell(m,n) != 0:
|
||||
set_cell(m,n,1,0,0)
|
||||
end -= 1
|
||||
start += 1
|
||||
|
||||
# create the actual and active visible part
|
||||
var end = l.size()-1
|
||||
var start = 0
|
||||
for steps in range(l.size()):
|
||||
for m in range(x-l[end],x+l[end]+1):
|
||||
for n in range(y-l[start],y+l[start]+1):
|
||||
set_cell(m,n,-1)
|
||||
end -= 1
|
||||
start += 1
|
||||
|
||||
x_old = x
|
||||
y_old = y
|
||||
|
||||
pass
|
||||
|
||||
func _ready():
|
||||
# Initalization here
|
||||
|
||||
# create a square filled with the 100% opaque fog
|
||||
for x in range(x_min,x_max):
|
||||
for y in range(y_min,y_max):
|
||||
set_cell(x,y,0,0,0)
|
||||
set_fixed_process(true)
|
||||
pass
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 31 KiB |
@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<resource_file type="TileSet" subresource_count="3" version="1.0" version_name="Godot Engine v1.0.stable.custom_build">
|
||||
<ext_resource path="res://floor.png" type="Texture"></ext_resource>
|
||||
<ext_resource path="res://fog.png" type="Texture"></ext_resource>
|
||||
<main_resource>
|
||||
<string name="0/name"> "fog opaque" </string>
|
||||
<resource name="0/texture" resource_type="Texture" path="res://fog.png"> </resource>
|
||||
<vector2 name="0/tex_offset"> -48, -48 </vector2>
|
||||
<vector2 name="0/shape_offset"> 0, 0 </vector2>
|
||||
<rect2 name="0/region"> 0, 0, 144, 144 </rect2>
|
||||
<array name="0/shapes" len="0" shared="false">
|
||||
</array>
|
||||
<string name="1/name"> "fog transparent" </string>
|
||||
<resource name="1/texture" resource_type="Texture" path="res://fog.png"> </resource>
|
||||
<vector2 name="1/tex_offset"> -48, -48 </vector2>
|
||||
<vector2 name="1/shape_offset"> 0, 0 </vector2>
|
||||
<rect2 name="1/region"> 144, 0, 144, 144 </rect2>
|
||||
<array name="1/shapes" len="0" shared="false">
|
||||
</array>
|
||||
<string name="2/name"> "floor" </string>
|
||||
<resource name="2/texture" resource_type="Texture" path="res://floor.png"> </resource>
|
||||
<vector2 name="2/tex_offset"> 0, 0 </vector2>
|
||||
<vector2 name="2/shape_offset"> 0, 0 </vector2>
|
||||
<rect2 name="2/region"> 0, 0, 0, 0 </rect2>
|
||||
<array name="2/shapes" len="0" shared="false">
|
||||
</array>
|
||||
|
||||
</main_resource>
|
||||
</resource_file>
|
||||
|
After Width: | Height: | Size: 8.5 KiB |
@ -0,0 +1 @@
|
||||
gen_mipmaps=true
|
||||
@ -0,0 +1,43 @@
|
||||
|
||||
extends KinematicBody2D
|
||||
|
||||
# This is a simple collision demo showing how
|
||||
# the kinematic cotroller works.
|
||||
# move() will allow to move the node, and will
|
||||
# always move it to a non-colliding spot,
|
||||
# as long as it starts from a non-colliding spot too.
|
||||
|
||||
|
||||
#pixels / second
|
||||
const MOTION_SPEED=160
|
||||
|
||||
func _fixed_process(delta):
|
||||
|
||||
var motion = Vector2()
|
||||
|
||||
if (Input.is_action_pressed("move_up")):
|
||||
motion+=Vector2(0,-1)
|
||||
if (Input.is_action_pressed("move_bottom")):
|
||||
motion+=Vector2(0,1)
|
||||
if (Input.is_action_pressed("move_left")):
|
||||
motion+=Vector2(-1,0)
|
||||
if (Input.is_action_pressed("move_right")):
|
||||
motion+=Vector2(1,0)
|
||||
|
||||
motion = motion.normalized() * MOTION_SPEED * delta
|
||||
motion = move(motion)
|
||||
|
||||
#make character slide nicely through the world
|
||||
var slide_attempts = 4
|
||||
while(is_colliding() and slide_attempts>0):
|
||||
motion = get_collision_normal().slide(motion)
|
||||
motion=move(motion)
|
||||
slide_attempts-=1
|
||||
|
||||
|
||||
func _ready():
|
||||
# Initalization here
|
||||
set_fixed_process(true)
|
||||
pass
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 7.1 KiB |
@ -0,0 +1,26 @@
|
||||
|
||||
extends Node2D
|
||||
|
||||
# member variables here, example:
|
||||
# var a=2
|
||||
# var b="textvar"
|
||||
const CAVE_LIMIT=1000
|
||||
|
||||
func _input(ev):
|
||||
if (ev.type==InputEvent.MOUSE_MOTION and ev.button_mask&1):
|
||||
var rel_x = ev.relative_x
|
||||
var cavepos = get_node("cave").get_pos()
|
||||
cavepos.x+=rel_x
|
||||
if (cavepos.x<-CAVE_LIMIT):
|
||||
cavepos.x=-CAVE_LIMIT
|
||||
elif (cavepos.x>0):
|
||||
cavepos.x=0
|
||||
get_node("cave").set_pos(cavepos)
|
||||
|
||||
|
||||
func _ready():
|
||||
set_process_input(true)
|
||||
# Initialization here
|
||||
pass
|
||||
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
[application]
|
||||
|
||||
name="HDR for 2D"
|
||||
main_scene="res://beach_cave.scn"
|
||||
|
||||
[display]
|
||||
|
||||
width=1080
|
||||
height=720
|
||||
|
||||
[rasterizer]
|
||||
|
||||
blur_buffer_size=128
|
||||
|
After Width: | Height: | Size: 433 KiB |
@ -0,0 +1 @@
|
||||
tolinear=true
|
||||
|
After Width: | Height: | Size: 728 KiB |
@ -0,0 +1 @@
|
||||
tolinear=true
|
||||
@ -0,0 +1,96 @@
|
||||
|
||||
extends KinematicBody2D
|
||||
|
||||
# member variables here, example:
|
||||
# var a=2
|
||||
# var b="textvar"
|
||||
|
||||
const MAX_SPEED = 300.0
|
||||
const IDLE_SPEED = 10.0
|
||||
const ACCEL=5.0
|
||||
const VSCALE=0.5
|
||||
const SHOOT_INTERVAL=0.3
|
||||
|
||||
var speed=Vector2()
|
||||
var current_anim=""
|
||||
var current_mirror=false
|
||||
|
||||
var shoot_countdown=0
|
||||
|
||||
func _input(ev):
|
||||
if (ev.type==InputEvent.MOUSE_BUTTON and ev.button_index==1 and ev.pressed and shoot_countdown<=0):
|
||||
var pos = get_canvas_transform().affine_inverse() * ev.pos
|
||||
var dir = (pos-get_global_pos()).normalized()
|
||||
var bullet = preload("res://shoot.scn").instance()
|
||||
bullet.advance_dir=dir
|
||||
bullet.set_pos( get_global_pos() + dir * 60 )
|
||||
get_parent().add_child(bullet)
|
||||
shoot_countdown=SHOOT_INTERVAL
|
||||
|
||||
|
||||
|
||||
|
||||
func _fixed_process(delta):
|
||||
|
||||
shoot_countdown-=delta
|
||||
var dir = Vector2()
|
||||
if (Input.is_action_pressed("up")):
|
||||
dir+=Vector2(0,-1)
|
||||
if (Input.is_action_pressed("down")):
|
||||
dir+=Vector2(0,1)
|
||||
if (Input.is_action_pressed("left")):
|
||||
dir+=Vector2(-1,0)
|
||||
if (Input.is_action_pressed("right")):
|
||||
dir+=Vector2(1,0)
|
||||
|
||||
if (dir!=Vector2()):
|
||||
dir=dir.normalized()
|
||||
speed = speed.linear_interpolate(dir*MAX_SPEED,delta*ACCEL)
|
||||
var motion = speed * delta
|
||||
motion.y*=VSCALE
|
||||
motion=move(motion)
|
||||
|
||||
if (is_colliding()):
|
||||
var n = get_collision_normal()
|
||||
motion=n.slide(motion)
|
||||
move(motion)
|
||||
|
||||
var next_anim=""
|
||||
var next_mirror=false
|
||||
|
||||
if (dir==Vector2() and speed.length()<IDLE_SPEED):
|
||||
next_anim="idle"
|
||||
next_mirror=false
|
||||
elif (speed.length()>IDLE_SPEED*0.1):
|
||||
var angle = atan2(abs(speed.x),speed.y)
|
||||
|
||||
next_mirror = speed.x>0
|
||||
if (angle<PI/8):
|
||||
next_anim="bottom"
|
||||
next_mirror=false
|
||||
elif (angle<PI/4+PI/8):
|
||||
next_anim="bottom_left"
|
||||
elif (angle<PI*2/4+PI/8):
|
||||
next_anim="left"
|
||||
elif (angle<PI*3/4+PI/8):
|
||||
next_anim="top_left"
|
||||
else:
|
||||
next_anim="top"
|
||||
next_mirror=false
|
||||
|
||||
|
||||
if (next_anim!=current_anim or next_mirror!=current_mirror):
|
||||
get_node("frames").set_flip_h(next_mirror)
|
||||
get_node("anim").play(next_anim)
|
||||
current_anim=next_anim
|
||||
current_mirror=next_mirror
|
||||
|
||||
|
||||
|
||||
func _ready():
|
||||
# Initialization here
|
||||
set_fixed_process(true)
|
||||
set_process_input(true)
|
||||
pass
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 7.0 KiB |
|
After Width: | Height: | Size: 7.0 KiB |
|
After Width: | Height: | Size: 7.0 KiB |
|
After Width: | Height: | Size: 7.0 KiB |
|
After Width: | Height: | Size: 7.0 KiB |
|
After Width: | Height: | Size: 7.1 KiB |
|
After Width: | Height: | Size: 7.1 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 7.1 KiB |
|
After Width: | Height: | Size: 7.1 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 7.1 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 7.3 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 7.1 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 7.3 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 7.1 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 7.1 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 7.1 KiB |