summaryrefslogtreecommitdiff
path: root/demos/2d/isometric_light
diff options
context:
space:
mode:
Diffstat (limited to 'demos/2d/isometric_light')
-rw-r--r--demos/2d/isometric_light/column.scnbin1909 -> 2026 bytes
-rw-r--r--demos/2d/isometric_light/cubio.gd117
-rw-r--r--demos/2d/isometric_light/cubio.scnbin7006 -> 6952 bytes
-rw-r--r--demos/2d/isometric_light/map.gd15
-rw-r--r--demos/2d/isometric_light/map.scnbin8661 -> 9352 bytes
-rw-r--r--demos/2d/isometric_light/shoot.gd20
-rw-r--r--demos/2d/isometric_light/shoot.scnbin4561 -> 4111 bytes
-rw-r--r--demos/2d/isometric_light/tileset_scene.scnbin4812 -> 5339 bytes
-rw-r--r--demos/2d/isometric_light/torch.scnbin4416 -> 3861 bytes
9 files changed, 62 insertions, 90 deletions
diff --git a/demos/2d/isometric_light/column.scn b/demos/2d/isometric_light/column.scn
index f0b7683885..03f3c2c976 100644
--- a/demos/2d/isometric_light/column.scn
+++ b/demos/2d/isometric_light/column.scn
Binary files differ
diff --git a/demos/2d/isometric_light/cubio.gd b/demos/2d/isometric_light/cubio.gd
index 30c766936c..508cd3728c 100644
--- a/demos/2d/isometric_light/cubio.gd
+++ b/demos/2d/isometric_light/cubio.gd
@@ -1,96 +1,85 @@
extends KinematicBody2D
-# member variables here, example:
-# var a=2
-# var b="textvar"
-
+# Member variables
const MAX_SPEED = 300.0
const IDLE_SPEED = 10.0
-const ACCEL=5.0
-const VSCALE=0.5
-const SHOOT_INTERVAL=0.3
+const ACCEL = 5.0
+const VSCALE = 0.5
+const SHOOT_INTERVAL = 0.3
+
+var speed = Vector2()
+var current_anim = ""
+var current_mirror = false
-var speed=Vector2()
-var current_anim=""
-var current_mirror=false
+var shoot_countdown = 0
-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()
+func _input(event):
+ if (event.type == InputEvent.MOUSE_BUTTON and event.button_index == 1 and event.pressed and shoot_countdown <= 0):
+ var pos = get_canvas_transform().affine_inverse()*event.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 )
+ bullet.advance_dir = dir
+ bullet.set_pos(get_global_pos() + dir*60)
get_parent().add_child(bullet)
- shoot_countdown=SHOOT_INTERVAL
-
-
-
+ shoot_countdown = SHOOT_INTERVAL
+
func _fixed_process(delta):
-
- shoot_countdown-=delta
+ shoot_countdown -= delta
var dir = Vector2()
if (Input.is_action_pressed("up")):
- dir+=Vector2(0,-1)
+ dir += Vector2(0, -1)
if (Input.is_action_pressed("down")):
- dir+=Vector2(0,1)
+ dir += Vector2(0, 1)
if (Input.is_action_pressed("left")):
- dir+=Vector2(-1,0)
+ 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)
+ 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)
+ motion = n.slide(motion)
move(motion)
- var next_anim=""
- var next_mirror=false
+ 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)
+ 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"
+ 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):
+ 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
-
+ current_anim = next_anim
+ current_mirror = next_mirror
func _ready():
- # Initialization here
set_fixed_process(true)
set_process_input(true)
- pass
-
-
diff --git a/demos/2d/isometric_light/cubio.scn b/demos/2d/isometric_light/cubio.scn
index fc931b0c8d..55e2185247 100644
--- a/demos/2d/isometric_light/cubio.scn
+++ b/demos/2d/isometric_light/cubio.scn
Binary files differ
diff --git a/demos/2d/isometric_light/map.gd b/demos/2d/isometric_light/map.gd
index f712aeeaec..6b790ddf1c 100644
--- a/demos/2d/isometric_light/map.gd
+++ b/demos/2d/isometric_light/map.gd
@@ -1,18 +1,7 @@
extends Node2D
-# member variables here, example:
-# var a=2
-# var b="textvar"
-func _ready():
- # Initialization here
- pass
-
-
-
-
-func _on_prince_area_body_enter( body ):
- if (body.get_name()=="cubio"):
+func _on_prince_area_body_enter(body):
+ if (body.get_name() == "cubio"):
get_node("message").show()
- pass # replace with function body
diff --git a/demos/2d/isometric_light/map.scn b/demos/2d/isometric_light/map.scn
index 89002f991f..da3fc5654f 100644
--- a/demos/2d/isometric_light/map.scn
+++ b/demos/2d/isometric_light/map.scn
Binary files differ
diff --git a/demos/2d/isometric_light/shoot.gd b/demos/2d/isometric_light/shoot.gd
index 0486bbb658..b48d4ad34b 100644
--- a/demos/2d/isometric_light/shoot.gd
+++ b/demos/2d/isometric_light/shoot.gd
@@ -1,27 +1,21 @@
extends KinematicBody2D
-# member variables here, example:
-# var a=2
-# var b="textvar"
-
-var advance_dir=Vector2(1,0)
+# Member variables
const ADVANCE_SPEED = 500.0
-var hit=false
+var advance_dir = Vector2(1, 0)
+var hit = false
+
func _fixed_process(delta):
-
if (hit):
return
- move(advance_dir*delta*ADVANCE_SPEED)
+ move(advance_dir*delta*ADVANCE_SPEED)
if (is_colliding()):
get_node("anim").play("explode")
- hit=true
+ hit = true
+
func _ready():
- # Initialization here
set_fixed_process(true)
- pass
-
-
diff --git a/demos/2d/isometric_light/shoot.scn b/demos/2d/isometric_light/shoot.scn
index 672608810f..6909ae0c71 100644
--- a/demos/2d/isometric_light/shoot.scn
+++ b/demos/2d/isometric_light/shoot.scn
Binary files differ
diff --git a/demos/2d/isometric_light/tileset_scene.scn b/demos/2d/isometric_light/tileset_scene.scn
index 3d0773c9c5..4841cc18a7 100644
--- a/demos/2d/isometric_light/tileset_scene.scn
+++ b/demos/2d/isometric_light/tileset_scene.scn
Binary files differ
diff --git a/demos/2d/isometric_light/torch.scn b/demos/2d/isometric_light/torch.scn
index 3f08b33311..9d6a8e2eae 100644
--- a/demos/2d/isometric_light/torch.scn
+++ b/demos/2d/isometric_light/torch.scn
Binary files differ