lot of work on 2D lighting and isometric maps
added a new demo, isometric_light that does full isometric sorting, lights, shadows, etc.
|
@ -21,3 +21,7 @@
|
|||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
**********************************************************************
|
||||
|
||||
|
|
BIN
demos/2d/isometric_light/character_shder.res
Normal file
BIN
demos/2d/isometric_light/column.scn
Normal file
96
demos/2d/isometric_light/cubio.gd
Normal file
|
@ -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
|
||||
|
||||
|
BIN
demos/2d/isometric_light/cubio.scn
Normal file
BIN
demos/2d/isometric_light/cubio/idle0001.png
Normal file
After Width: | Height: | Size: 7 KiB |
BIN
demos/2d/isometric_light/cubio/idle0002.png
Normal file
After Width: | Height: | Size: 7 KiB |
BIN
demos/2d/isometric_light/cubio/idle0003.png
Normal file
After Width: | Height: | Size: 7 KiB |
BIN
demos/2d/isometric_light/cubio/idle0004.png
Normal file
After Width: | Height: | Size: 7 KiB |
BIN
demos/2d/isometric_light/cubio/idle0005.png
Normal file
After Width: | Height: | Size: 7 KiB |
BIN
demos/2d/isometric_light/cubio/idle0006.png
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
demos/2d/isometric_light/cubio/idle0007.png
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
demos/2d/isometric_light/cubio/idle0008.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
demos/2d/isometric_light/cubio/idle0009.png
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
demos/2d/isometric_light/cubio/idle0010.png
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
demos/2d/isometric_light/cubio/idle0011.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
demos/2d/isometric_light/cubio/idle0012.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
demos/2d/isometric_light/cubio/idle0013.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
demos/2d/isometric_light/cubio/idle0014.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
demos/2d/isometric_light/cubio/idle0015.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
demos/2d/isometric_light/cubio/idle0016.png
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
demos/2d/isometric_light/cubio/idle0017.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
demos/2d/isometric_light/cubio/idle0018.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
demos/2d/isometric_light/cubio/idle0019.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
demos/2d/isometric_light/cubio/idle0020.png
Normal file
After Width: | Height: | Size: 7.3 KiB |
BIN
demos/2d/isometric_light/cubio/idle0021.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
demos/2d/isometric_light/cubio/idle0022.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
demos/2d/isometric_light/cubio/idle0023.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
demos/2d/isometric_light/cubio/idle0024.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
demos/2d/isometric_light/cubio/idle0025.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
demos/2d/isometric_light/cubio/idle0026.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
demos/2d/isometric_light/cubio/idle0027.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
demos/2d/isometric_light/cubio/idle0028.png
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
demos/2d/isometric_light/cubio/idle0029.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
demos/2d/isometric_light/cubio/idle0030.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
demos/2d/isometric_light/cubio/idle0031.png
Normal file
After Width: | Height: | Size: 7.3 KiB |
BIN
demos/2d/isometric_light/cubio/idle0032.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
demos/2d/isometric_light/cubio/idle0033.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
demos/2d/isometric_light/cubio/idle0034.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
demos/2d/isometric_light/cubio/idle0035.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
demos/2d/isometric_light/cubio/idle0036.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
demos/2d/isometric_light/cubio/idle0037.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
demos/2d/isometric_light/cubio/idle0038.png
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
demos/2d/isometric_light/cubio/idle0039.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
demos/2d/isometric_light/cubio/idle0040.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
demos/2d/isometric_light/cubio/idle0041.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
demos/2d/isometric_light/cubio/idle0042.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
demos/2d/isometric_light/cubio/idle0043.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
demos/2d/isometric_light/cubio/idle0044.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
demos/2d/isometric_light/cubio/idle0045.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
demos/2d/isometric_light/cubio/idle0046.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
demos/2d/isometric_light/cubio/idle0047.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
demos/2d/isometric_light/cubio/idle0048.png
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
demos/2d/isometric_light/cubio/idle0049.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
demos/2d/isometric_light/cubio/idle0050.png
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
demos/2d/isometric_light/cubio/idle0051.png
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
demos/2d/isometric_light/cubio/idle0052.png
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
demos/2d/isometric_light/cubio/idle0053.png
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
demos/2d/isometric_light/cubio/idle0054.png
Normal file
After Width: | Height: | Size: 7 KiB |
BIN
demos/2d/isometric_light/cubio/idle0055.png
Normal file
After Width: | Height: | Size: 7 KiB |
BIN
demos/2d/isometric_light/cubio/idle0056.png
Normal file
After Width: | Height: | Size: 7 KiB |
BIN
demos/2d/isometric_light/cubio/idle0057.png
Normal file
After Width: | Height: | Size: 7 KiB |
BIN
demos/2d/isometric_light/cubio/idle0058.png
Normal file
After Width: | Height: | Size: 7 KiB |
BIN
demos/2d/isometric_light/cubio/idle0059.png
Normal file
After Width: | Height: | Size: 7 KiB |
BIN
demos/2d/isometric_light/cubio/idle0060.png
Normal file
After Width: | Height: | Size: 7 KiB |
BIN
demos/2d/isometric_light/cubio/norm-b-0001.png
Normal file
After Width: | Height: | Size: 6.9 KiB |
BIN
demos/2d/isometric_light/cubio/norm-b-0002.png
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
demos/2d/isometric_light/cubio/norm-b-0003.png
Normal file
After Width: | Height: | Size: 7.5 KiB |
BIN
demos/2d/isometric_light/cubio/norm-b-0004.png
Normal file
After Width: | Height: | Size: 7.8 KiB |
BIN
demos/2d/isometric_light/cubio/norm-b-0005.png
Normal file
After Width: | Height: | Size: 7.9 KiB |
BIN
demos/2d/isometric_light/cubio/norm-b-0006.png
Normal file
After Width: | Height: | Size: 7.8 KiB |
BIN
demos/2d/isometric_light/cubio/norm-b-0007.png
Normal file
After Width: | Height: | Size: 7.6 KiB |
BIN
demos/2d/isometric_light/cubio/norm-b-0008.png
Normal file
After Width: | Height: | Size: 7.3 KiB |
BIN
demos/2d/isometric_light/cubio/norm-b-0009.png
Normal file
After Width: | Height: | Size: 6.9 KiB |
BIN
demos/2d/isometric_light/cubio/norm-b-0010.png
Normal file
After Width: | Height: | Size: 6.8 KiB |
BIN
demos/2d/isometric_light/cubio/norm-b-0011.png
Normal file
After Width: | Height: | Size: 6.8 KiB |
BIN
demos/2d/isometric_light/cubio/norm-b-0012.png
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
demos/2d/isometric_light/cubio/norm-b-0013.png
Normal file
After Width: | Height: | Size: 7.4 KiB |
BIN
demos/2d/isometric_light/cubio/norm-b-0014.png
Normal file
After Width: | Height: | Size: 7.7 KiB |
BIN
demos/2d/isometric_light/cubio/norm-b-0015.png
Normal file
After Width: | Height: | Size: 7.8 KiB |
BIN
demos/2d/isometric_light/cubio/norm-b-0016.png
Normal file
After Width: | Height: | Size: 7.8 KiB |
BIN
demos/2d/isometric_light/cubio/norm-b-0017.png
Normal file
After Width: | Height: | Size: 7.7 KiB |
BIN
demos/2d/isometric_light/cubio/norm-b-0018.png
Normal file
After Width: | Height: | Size: 7.4 KiB |
BIN
demos/2d/isometric_light/cubio/norm-b-0019.png
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
demos/2d/isometric_light/cubio/norm-b-0020.png
Normal file
After Width: | Height: | Size: 6.9 KiB |
BIN
demos/2d/isometric_light/cubio/norm-bl-0001.png
Normal file
After Width: | Height: | Size: 6.9 KiB |
BIN
demos/2d/isometric_light/cubio/norm-bl-0002.png
Normal file
After Width: | Height: | Size: 6.9 KiB |
BIN
demos/2d/isometric_light/cubio/norm-bl-0003.png
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
demos/2d/isometric_light/cubio/norm-bl-0004.png
Normal file
After Width: | Height: | Size: 7.6 KiB |
BIN
demos/2d/isometric_light/cubio/norm-bl-0005.png
Normal file
After Width: | Height: | Size: 7.5 KiB |
BIN
demos/2d/isometric_light/cubio/norm-bl-0006.png
Normal file
After Width: | Height: | Size: 8 KiB |
BIN
demos/2d/isometric_light/cubio/norm-bl-0007.png
Normal file
After Width: | Height: | Size: 8.1 KiB |
BIN
demos/2d/isometric_light/cubio/norm-bl-0008.png
Normal file
After Width: | Height: | Size: 8.5 KiB |
BIN
demos/2d/isometric_light/cubio/norm-bl-0009.png
Normal file
After Width: | Height: | Size: 8.6 KiB |
BIN
demos/2d/isometric_light/cubio/norm-bl-0010.png
Normal file
After Width: | Height: | Size: 8.6 KiB |
BIN
demos/2d/isometric_light/cubio/norm-bl-0011.png
Normal file
After Width: | Height: | Size: 8.6 KiB |
BIN
demos/2d/isometric_light/cubio/norm-bl-0012.png
Normal file
After Width: | Height: | Size: 8.4 KiB |
BIN
demos/2d/isometric_light/cubio/norm-bl-0013.png
Normal file
After Width: | Height: | Size: 8.5 KiB |
BIN
demos/2d/isometric_light/cubio/norm-bl-0014.png
Normal file
After Width: | Height: | Size: 8.2 KiB |
BIN
demos/2d/isometric_light/cubio/norm-bl-0015.png
Normal file
After Width: | Height: | Size: 8 KiB |