Skip to content

Commit 04583bb

Browse files
committed
change buttons for campus tour
1 parent 670fc9c commit 04583bb

File tree

3 files changed

+72
-16
lines changed

3 files changed

+72
-16
lines changed

project.godot

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,54 @@ window/stretch/aspect="keep"
3939

4040
shoot_0={
4141
"deadzone": 0.5,
42-
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777232,"unicode":0,"echo":false,"script":null)
42+
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"unicode":0,"echo":false,"script":null)
4343
]
4444
}
4545
shoot_1={
4646
"deadzone": 0.5,
47-
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777234,"unicode":0,"echo":false,"script":null)
47+
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":84,"unicode":0,"echo":false,"script":null)
4848
]
4949
}
50-
shield_red={
50+
shield_red_on={
5151
"deadzone": 0.5,
52-
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":81,"unicode":0,"echo":false,"script":null)
52+
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":80,"unicode":0,"echo":false,"script":null)
53+
]
54+
}
55+
shield_blue_on={
56+
"deadzone": 0.5,
57+
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":85,"unicode":0,"echo":false,"script":null)
58+
]
59+
}
60+
shield_red_off={
61+
"deadzone": 0.5,
62+
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":88,"unicode":0,"echo":false,"script":null)
63+
]
64+
}
65+
shield_blue_off={
66+
"deadzone": 0.5,
67+
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":73,"unicode":0,"echo":false,"script":null)
5368
]
5469
}
55-
shield_blue={
70+
walk_right_on={
5671
"deadzone": 0.5,
5772
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":69,"unicode":0,"echo":false,"script":null)
5873
]
5974
}
75+
walk_right_off={
76+
"deadzone": 0.5,
77+
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":82,"unicode":0,"echo":false,"script":null)
78+
]
79+
}
80+
walk_left_on={
81+
"deadzone": 0.5,
82+
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":81,"unicode":0,"echo":false,"script":null)
83+
]
84+
}
85+
walk_left_off={
86+
"deadzone": 0.5,
87+
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"unicode":0,"echo":false,"script":null)
88+
]
89+
}
6090

6191
[rendering]
6292

sheep/sheep.gd

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,44 @@ const TWOSHOT_INTERVAL = 0.1
1414
var timeout_cannons = [0, 0]
1515
var last_projectile
1616

17+
var is_moving_left = false
18+
var is_moving_right = false
19+
1720
func _ready():
1821
$Shield.connect("blocked", self, "emit_signal", ["blocked"])
1922

20-
func process_input():
23+
func _move():
2124
velocity = Vector2()
2225
var left_border = Global.PLAYER_PADDING_HORIZONTAL.x
2326
var right_border = get_viewport_rect().size.x - Global.PLAYER_PADDING_HORIZONTAL.y
2427

25-
if Input.is_action_pressed('ui_right') && position.x < right_border:
28+
if is_moving_right && position.x < right_border:
2629
velocity.x += 1
27-
if Input.is_action_pressed('ui_left') && position.x > left_border:
30+
31+
if is_moving_left && position.x > left_border:
2832
velocity.x -= 1
2933

30-
if (Input.is_action_pressed('ui_right') && position.x >= right_border) || (Input.is_action_pressed('ui_left') && position.x <= left_border):
34+
velocity = velocity.normalized() * speed
35+
36+
if (is_moving_right && position.x >= right_border) || (is_moving_left && position.x <= left_border):
3137
if not $RobotSheepPlayer.playing:
3238
$RobotSheepPlayer.play()
39+
40+
func _input(_event):
41+
if Input.is_action_just_pressed("walk_right_on"):
42+
is_moving_right = true
43+
elif Input.is_action_just_pressed('walk_right_off'):
44+
is_moving_right = false
45+
46+
if Input.is_action_just_pressed('walk_left_on'):
47+
is_moving_left = true
48+
elif Input.is_action_just_pressed('walk_left_off'):
49+
is_moving_left = false
3350

3451
if Input.is_action_just_pressed("shoot_0"):
3552
shoot(0)
3653
if Input.is_action_just_pressed("shoot_1") and not Global.useAutoCrits:
3754
shoot(1)
38-
39-
velocity = velocity.normalized() * speed
4055

4156
func was_shot_recently(cannon_index):
4257
return Global.useAutoCrits or timeout_cannons[cannon_index] >= CANNON_TIMEOUT - TWOSHOT_INTERVAL
@@ -68,8 +83,7 @@ func shoot(cannon_index):
6883

6984

7085
func _physics_process(delta):
71-
process_input()
72-
86+
_move()
7387
timeout_cannons[0] -= delta
7488
timeout_cannons[1] -= delta
7589

sheep/shield.gd

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ var colors = [1, 4] if Global.useFourColors else [1, 2.5, 4]
1010
signal shield_changed
1111
signal blocked
1212

13+
var shield_red_on = false
14+
var shield_blue_on = false
15+
1316
func is_blocked(projectile):
1417
var projectile_color = projectile.get_modulate()
1518
var color = get_modulate()
@@ -24,10 +27,19 @@ func is_blocked(projectile):
2427
func block_registered():
2528
emit_signal("blocked")
2629

27-
func _process(_delta):
30+
func _input(_delta):
31+
if Input.is_action_just_pressed("shield_red_on"):
32+
shield_red_on = true
33+
if Input.is_action_just_pressed("shield_red_off"):
34+
shield_red_on =false
35+
if Input.is_action_just_pressed("shield_blue_on"):
36+
shield_blue_on = true
37+
if Input.is_action_just_pressed("shield_blue_off"):
38+
shield_blue_on = false
39+
2840
if Global.useFourColors:
29-
r_index = 1 if Input.is_action_pressed("shield_red") else 0
30-
b_index = 1 if Input.is_action_pressed("shield_blue") else 0
41+
r_index = 1 if shield_red_on else 0
42+
b_index = 1 if shield_blue_on else 0
3143
$"../..".emit_signal("shield_changed", true, r_index)
3244
$"../..".emit_signal("shield_changed", false, b_index)
3345
else:

0 commit comments

Comments
 (0)