Files
blessfrey-bottle/src/views/games-sl.tpl
T
2025-01-06 20:26:27 -06:00

81 lines
2.4 KiB
Smarty
Executable File

% rebase('frame.tpl')
<div class="content-grid"><div class="center">
<h2>Stoplight</h2>
<iframe frameborder="0" src="https://itch.io/embed-upload/6263420?color=333333" allowfullscreen="" width="800" height="620"><a href="https://chimchooree.itch.io/stoplight">Play stoplight on itch.io</a></iframe>
<h3>game guide</h3>
<p>Co-routines give you the power to change the light! Watch how player input disrupts the stoplight's schedule. Push the walk button to skip a phase. Or wait until the phase times out. </p>
<p>This is just a small project to get more comfortable with yields in Godot Engine.
<p>This game was released June 5, 2019.</p>
<h3>code</h3>
<h4>node hierarchy</h4>
<a target="_blank" href="/static/img/game/SL_GodotEngine.png">
<img src="/static/img/game/SL_GodotEngine.png" alt="Screenshot: Godot Engine editor">
</a>
<h4>Main.gd</h4>
<pre><code>
extends Node
onready var stoplight = $Stoplight
func _ready():
stoplight.play()
var result = wait(5, 'green')
$WalkButton/TextureButton.connect('pressed', result, 'resume', ['interrupted on green'], CONNECT_ONESHOT)
yield(result, 'completed')
result = wait(5, 'yellow')
$WalkButton/TextureButton.connect('pressed', result, 'resume', ['interrupted on yellow'], CONNECT_ONESHOT)
yield(result, 'completed')
result = wait(5, 'red')
$WalkButton/TextureButton.connect('pressed', result, 'resume', ['interrupted on red'], CONNECT_ONESHOT)
yield(result, 'completed')
func wait(time, color):
print('waiting for: ' + color)
var result = yield(get_tree().create_timer(time), 'timeout')
if result:
print(result)
stoplight.animation = color
print('done: ' + color)
func _on_completed():
print('completed')
func _on_WalkButton_gui_input(event):
if event is InputEventMouseButton and event.pressed:
print ("Walk Button not functioning.")
</code></pre>
<h4>Label.gd</h4>
<pre><code>
extends Label
var time_start = 0
var time_now = 0
func _ready():
time_start = OS.get_unix_time()
set_process(true)
func _process(delta):
time_now = OS.get_unix_time()
var elapsed = time_now - time_start
var minutes = elapsed / 60
var seconds = elapsed % 60
var str_elapsed = "%02d" % [seconds]
text = str(str_elapsed)
</code></pre>
<h3>Credits</h3>
<ul>
<li>coding + art by chimchooree</li>
<li>Tools: Godot Engine 3.0.6, Krita</li>
<li>Hosting: itch.io</li>
<li>Thumbnail Font: Alpha Flowers by Chloe5972</li>
</ul>
</div></div>