Skip to content

Commit

Permalink
feat: hide controls on non-touch devices
Browse files Browse the repository at this point in the history
  • Loading branch information
lbovet committed Aug 2, 2021
1 parent 255bb34 commit caa8c17
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ data_*/
android/
*.apk
*.apk.idsig
*.pck

*.exe
html/
4 changes: 4 additions & 0 deletions Game.gd
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ func _ready():
c.queue_free()
node.show()
$GameOver.hide()
if not OS.has_touchscreen_ui_hint():
$Controls.queue_free()

func _process(delta):
if Input.is_action_just_pressed("reset"):
Expand All @@ -29,6 +31,8 @@ func _on_Timer_timeout():
$GameOver.show()

func _on_Field_tank_removed(tank):
if $Controls == null:
return
if(tank == 1):
$Controls/Controls1.queue_free()
if(tank == 2):
Expand Down
10 changes: 5 additions & 5 deletions Game.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ script = ExtResource( 3 )
z_index = -3

[node name="ColorRect" type="ColorRect" parent="Node2D"]
margin_left = -5.6123
margin_top = -5.61231
margin_right = 34.3877
margin_bottom = 34.3877
rect_scale = Vector2( 25.9835, 15.3862 )
margin_left = -60.3407
margin_top = -60.3407
margin_right = -20.3407
margin_bottom = -20.3407
rect_scale = Vector2( 28.963, 18.1261 )
color = Color( 0.619608, 0.576471, 0.576471, 1 )
__meta__ = {
"_edit_use_anchors_": false
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
# zimboom
A single-device muliplayer tank game

## Play

- [Web Browser](https://lbovet.github.io/zimboom/index.html)
- [Windows](https://github.com/lbovet/zimboom/releases/)
- [Android](ihttps://github.com/lbovet/zimboom/releases/) (coming soon on Google Play)
- OS X, iOS: please help me, I have no such devices
4 changes: 4 additions & 0 deletions Tank.gd
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,7 @@ func _on_InitTimer_timeout():
func _on_TankButton_pressed():
if virgin:
die()

func _on_MouseButton_pressed():
if virgin:
die()
14 changes: 13 additions & 1 deletion Tank.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,24 @@ position = Vector2( -32.7036, -38.7104 )
scale = Vector2( 3.27957, 3.6002 )
shape = SubResource( 3 )

[connection signal="timeout" from="Muzzle/MuzzleFire/Timer" to="." method="_on_Timer_timeout"]
[node name="MouseButton" type="Button" parent="."]
modulate = Color( 1, 1, 1, 0 )
margin_left = -21.3315
margin_top = -25.832
margin_right = 23.6685
margin_bottom = 21.168
rect_scale = Vector2( 0.939053, 1.05825 )
__meta__ = {
"_edit_use_anchors_": false
}

[connection signal="timeout" from="Muzzle/MuzzleFire/Timer" to="Muzzle/MuzzleFire/Timer" method="_on_Timer_timeout"]
[connection signal="timeout" from="Muzzle/MuzzleFire/Timer" to="." method="_on_Timer_timeout"]
[connection signal="timeout" from="LoadTimer" to="." method="_on_LoadTimer_timeout"]
[connection signal="timeout" from="Life/Fade" to="." method="_on_Fade_timeout"]
[connection signal="timeout" from="Label/Hide" to="." method="_on_Hide_timeout"]
[connection signal="timeout" from="Camera2D/FocusTimer" to="." method="_on_Timer_timeout"]
[connection signal="timeout" from="Camera2D/FocusTimer" to="." method="_on_FocusTimer_timeout"]
[connection signal="timeout" from="InitTimer" to="." method="_on_InitTimer_timeout"]
[connection signal="pressed" from="Button" to="." method="_on_TankButton_pressed"]
[connection signal="pressed" from="MouseButton" to="." method="_on_MouseButton_pressed"]
2 changes: 1 addition & 1 deletion project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ reset={

[input_devices]

pointing/emulate_touch_from_mouse=true
pointing/emulate_mouse_from_touch=false

[physics]

Expand Down

0 comments on commit caa8c17

Please sign in to comment.