games each have their own page
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
% rebase('frame.tpl')
|
||||
<div class="content-grid"><div class="center">
|
||||
<h1>stoplight</h1>
|
||||
<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>
|
||||
|
||||
<h2>game guide</h2>
|
||||
<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>
|
||||
|
||||
<h2>code</h2>
|
||||
<h3>node hierarchy</h3>
|
||||
|
||||
<a target="_blank" href="/static/img/game/SL_GodotEngine.png">
|
||||
<img src="/static/img/game/SL_GodotEngine.png" alt="Screenshot: Godot Engine editor">
|
||||
</a>
|
||||
<h3>Main.gd</h3>
|
||||
<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>
|
||||
|
||||
<h3>Label.gd</h3>
|
||||
<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>
|
||||
<h2>Credits</h2>
|
||||
<ul>
|
||||
<li>coding + art by chimchooree</li>
|
||||
<li>Tools: Godot Engine 3.0.6, Krita</li>
|
||||
<li>Hosting: itch.io</li>
|
||||
</ul>
|
||||
</div></div>
|
||||
Reference in New Issue
Block a user