End of LD38

This commit is contained in:
Kienan Stewart 2017-04-23 15:34:18 -04:00
parent 25d57d572d
commit 2f8a1d3f3e
29 changed files with 1026 additions and 88 deletions

BIN
assets/black.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 B

BIN
assets/grass.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
assets/main_menu_bg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 367 KiB

BIN
assets/poop.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
assets/raw/black.xcf Normal file

Binary file not shown.

BIN
assets/raw/grass.xcf Normal file

Binary file not shown.

BIN
assets/raw/main_menu_bg.xcf Normal file

Binary file not shown.

BIN
assets/raw/poop.xcf Normal file

Binary file not shown.

Binary file not shown.

BIN
assets/raw/title.xcf Normal file

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 716 B

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
assets/title.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

@ -1,7 +1,7 @@
[application]
name="Black Sheep"
main_scene="res://game.tscn"
main_scene="res://menu.tscn"
icon="res://icon.png"
[display]
@ -10,6 +10,7 @@ driver="GLES2"
[input]
ui_button_2=[key(2)]
ui_button_1=[key(1)]
[locale]

282
export.cfg Normal file
View File

@ -0,0 +1,282 @@
[convert_images]
action="none"
compress_quality=0.7
formats="png"
shrink=1.0
[convert_samples]
action="none"
max_hz=44100
trim=false
[convert_scenes]
convert_text_scenes=true
[export_filter]
filter=""
filter_exclude=""
type="resources"
[platform:Android]
apk_expansion/SALT=""
apk_expansion/enable=false
apk_expansion/public_key=""
architecture/arm=true
architecture/x86=false
command_line/extra_args=""
custom_package/debug=""
custom_package/release=""
debug/debugging_enabled=true
keystore/release=""
keystore/release_password=""
keystore/release_user=""
one_click_deploy/clear_previous_install=true
package/icon=""
package/name=""
package/signed=true
package/unique_name="org.godotengine.$genname"
permissions/access_checkin_properties=false
permissions/access_coarse_location=false
permissions/access_fine_location=false
permissions/access_location_extra_commands=false
permissions/access_mock_location=false
permissions/access_network_state=false
permissions/access_surface_flinger=false
permissions/access_wifi_state=false
permissions/account_manager=false
permissions/add_voicemail=false
permissions/authenticate_accounts=false
permissions/battery_stats=false
permissions/bind_accessibility_service=false
permissions/bind_appwidget=false
permissions/bind_device_admin=false
permissions/bind_input_method=false
permissions/bind_nfc_service=false
permissions/bind_notification_listener_service=false
permissions/bind_print_service=false
permissions/bind_remoteviews=false
permissions/bind_text_service=false
permissions/bind_vpn_service=false
permissions/bind_wallpaper=false
permissions/bluetooth=false
permissions/bluetooth_admin=false
permissions/bluetooth_privileged=false
permissions/brick=false
permissions/broadcast_package_removed=false
permissions/broadcast_sms=false
permissions/broadcast_sticky=false
permissions/broadcast_wap_push=false
permissions/call_phone=false
permissions/call_privileged=false
permissions/camera=false
permissions/capture_audio_output=false
permissions/capture_secure_video_output=false
permissions/capture_video_output=false
permissions/change_component_enabled_state=false
permissions/change_configuration=false
permissions/change_network_state=false
permissions/change_wifi_multicast_state=false
permissions/change_wifi_state=false
permissions/clear_app_cache=false
permissions/clear_app_user_data=false
permissions/control_location_updates=false
permissions/delete_cache_files=false
permissions/delete_packages=false
permissions/device_power=false
permissions/diagnostic=false
permissions/disable_keyguard=false
permissions/dump=false
permissions/expand_status_bar=false
permissions/factory_test=false
permissions/flashlight=false
permissions/force_back=false
permissions/get_accounts=false
permissions/get_package_size=false
permissions/get_tasks=false
permissions/get_top_activity_info=false
permissions/global_search=false
permissions/hardware_test=false
permissions/inject_events=false
permissions/install_location_provider=false
permissions/install_packages=false
permissions/install_shortcut=false
permissions/internal_system_window=false
permissions/internet=false
permissions/kill_background_processes=false
permissions/location_hardware=false
permissions/manage_accounts=false
permissions/manage_app_tokens=false
permissions/manage_documents=false
permissions/master_clear=false
permissions/media_content_control=false
permissions/modify_audio_settings=false
permissions/modify_phone_state=false
permissions/mount_format_filesystems=false
permissions/mount_unmount_filesystems=false
permissions/nfc=false
permissions/persistent_activity=false
permissions/process_outgoing_calls=false
permissions/read_calendar=false
permissions/read_call_log=false
permissions/read_contacts=false
permissions/read_external_storage=false
permissions/read_frame_buffer=false
permissions/read_history_bookmarks=false
permissions/read_input_state=false
permissions/read_logs=false
permissions/read_phone_state=false
permissions/read_profile=false
permissions/read_sms=false
permissions/read_social_stream=false
permissions/read_sync_settings=false
permissions/read_sync_stats=false
permissions/read_user_dictionary=false
permissions/reboot=false
permissions/receive_boot_completed=false
permissions/receive_mms=false
permissions/receive_sms=false
permissions/receive_wap_push=false
permissions/record_audio=false
permissions/reorder_tasks=false
permissions/restart_packages=false
permissions/send_respond_via_message=false
permissions/send_sms=false
permissions/set_activity_watcher=false
permissions/set_alarm=false
permissions/set_always_finish=false
permissions/set_animation_scale=false
permissions/set_debug_app=false
permissions/set_orientation=false
permissions/set_pointer_speed=false
permissions/set_preferred_applications=false
permissions/set_process_limit=false
permissions/set_time=false
permissions/set_time_zone=false
permissions/set_wallpaper=false
permissions/set_wallpaper_hints=false
permissions/signal_persistent_processes=false
permissions/status_bar=false
permissions/subscribed_feeds_read=false
permissions/subscribed_feeds_write=false
permissions/system_alert_window=false
permissions/transmit_ir=false
permissions/uninstall_shortcut=false
permissions/update_device_stats=false
permissions/use_credentials=false
permissions/use_sip=false
permissions/vibrate=false
permissions/wake_lock=false
permissions/write_apn_settings=false
permissions/write_calendar=false
permissions/write_call_log=false
permissions/write_contacts=false
permissions/write_external_storage=false
permissions/write_gservices=false
permissions/write_history_bookmarks=false
permissions/write_profile=false
permissions/write_secure_settings=false
permissions/write_settings=false
permissions/write_sms=false
permissions/write_social_stream=false
permissions/write_sync_settings=false
permissions/write_user_dictionary=false
screen/immersive_mode=true
screen/orientation=0
screen/support_large=true
screen/support_normal=true
screen/support_small=true
screen/support_xlarge=true
screen/use_32_bits_view=true
user_permissions/0=""
user_permissions/1=""
user_permissions/10=""
user_permissions/11=""
user_permissions/12=""
user_permissions/13=""
user_permissions/14=""
user_permissions/15=""
user_permissions/16=""
user_permissions/17=""
user_permissions/18=""
user_permissions/19=""
user_permissions/2=""
user_permissions/3=""
user_permissions/4=""
user_permissions/5=""
user_permissions/6=""
user_permissions/7=""
user_permissions/8=""
user_permissions/9=""
version/code=1
version/name="1.0"
[platform:BlackBerry 10]
debug/debugging_enabled=true
package/category="core.games"
package/custom_template=""
package/description="Game made with Godot Engine"
package/icon=""
package/name=""
package/unique_name="com.godot.noname"
release/author="Cert. Name"
release/author_id="Cert. ID"
version/code=1
version/name="1.0"
[platform:HTML5]
browser/enable_run=false
custom_package/debug=""
custom_package/release=""
debug/debugging_enabled=true
html/controls_enabled=true
html/font_family="arial,sans-serif"
html/head_include=""
html/style_include=""
html/title=""
options/memory_size=3
[platform:Linux X11]
binary/64_bits=true
custom_binary/debug=""
custom_binary/release=""
debug/debugging_enabled=true
resources/bundle_dependencies_(for_optical_disc)=true
resources/pack_mode=0
[platform:Mac OSX]
application/bits_mode=0
application/copyright=""
application/icon=""
application/identifier="org.godotengine.macgame"
application/info="Made with Godot Engine"
application/name=""
application/short_version="1.0"
application/signature="godotmacgame"
application/version="1.0"
custom_package/debug=""
custom_package/release=""
debug/debugging_enabled=true
display/high_res=false
[platform:Windows Desktop]
binary/64_bits=true
custom_binary/debug=""
custom_binary/release=""
debug/debugging_enabled=true
resources/bundle_dependencies_(for_optical_disc)=false
resources/pack_mode=1
[script]
action="compile"
encrypt_key=""

View File

@ -66,9 +66,9 @@ focus/stop_mouse = true
size_flags/horizontal = 2
size_flags/vertical = 0
margin/left = -18.0
margin/top = -15.0
margin/top = -20.0
margin/right = 22.0
margin/bottom = 1.0
margin/bottom = -4.0
range/min = 0.0
range/max = 50.0
range/step = 1.0

145
game.gd
View File

@ -6,7 +6,12 @@ signal player_action(action)
# Consts
const TIME_LIMIT = 60.0
const TimeLeftTooltipFormat = "Shearing in %fm%ds"
const FLOCK_SIZE = 18
const FLOCK_MIN_TIME = 5
const FLOCK_MAX_TIME = 20
const MIN_GRASS = 5
const MAX_GRASS = 9
const SUSPICION_AWAY_FROM_FLOCK = 0.015
# Member variables
#var screen_size
var time_to_shearing = TIME_LIMIT # Time left in seconds
@ -14,39 +19,149 @@ var suspicion = 0
var max_suspicion = 100
var highest_suspicion = 0
var suspicion_loss = 1 # per second
var flock_timer = 0
var flock_destination = Vector2()
var process_logic = true
func _ready():
get_node("TimeLeftBar").set_max(TIME_LIMIT)
get_node("TimeLeftBar").set_value(TIME_LIMIT)
get_node("SuspicionBar").set_max(max_suspicion)
get_node("SuspicionBar").set_value(suspicion)
get_node("ToolBar/RamButton").connect("pressed", self, "_on_ram_pressed")
set_process(true)
randomize()
get_node("HUD/TimeLeftBar").set_max(TIME_LIMIT)
get_node("HUD/TimeLeftBar").set_value(TIME_LIMIT)
get_node("HUD/SuspicionBar").set_max(max_suspicion)
get_node("HUD/SuspicionBar").set_value(suspicion)
get_node("HUD/ToolBar/RamButton").connect("pressed", self, "_on_ram_pressed")
get_node("HUD/ToolBar/EatButton").connect("pressed", self, "_on_eat_pressed")
var i = 0
var sheep = preload("res://sheep.tscn")
var grass = preload("res://grass.tscn")
var pen_tl = get_node("Level/Pen/Spawn-TL")
var pen_br = get_node("Level/Pen/Spawn-BR")
while i < FLOCK_SIZE:
var node = sheep.instance()
node.set_pos(spawn_in_area(pen_tl, pen_br))
node.add_to_group('flock')
get_node("Actors").add_child(node)
i += 1
i = 0
while i < int(rand_range(MIN_GRASS, MAX_GRASS)):
var node = grass.instance()
node.set_pos(spawn_in_area(pen_tl, pen_br))
node.add_to_group('grass')
get_node("Level").add_child(node)
i += 1
set_process(true)
func spawn_in_area(tl, br):
var min_x = tl.get_global_pos().x
var max_x = br.get_global_pos().x
var min_y = tl.get_global_pos().y
var max_y = br.get_global_pos().y
return Vector2(rand_range(min_x, max_x), rand_range(min_y, max_y))
func _process(delta):
if not process_logic:
return
time_to_shearing -= delta
var time_left = get_node("TimeLeftBar")
var time_left = get_node("HUD/TimeLeftBar")
time_left.set_value(time_to_shearing)
var time_left_minute = floor(time_to_shearing / 60)
var time_left_second = time_to_shearing - (time_left_minute * 60)
var tooltip = TimeLeftTooltipFormat % [time_left_minute, time_left_second]
time_left.set_tooltip(tooltip)
if time_to_shearing < 0:
game_over("Too late : the shearing is upon us!")
update_suspicion(-delta * suspicion_loss)
var suspicion_bar = get_node('SuspicionBar')
suspicion_bar.set_value(suspicion)
var d_suspicion = -delta * suspicion_loss
if flock_timer > 0:
var suspicion_per_pixel = SUSPICION_AWAY_FROM_FLOCK
var d = get_node("Actors/player").get_global_pos().distance_to(flock_destination)
var flock_distance = get_node("Actors/player").get_global_pos().distance_to(avg_flock_location())
#print("Distance from point: ", d)
#print("Distance from flock center: ", flock_distance)
d_suspicion += suspicion_per_pixel * (flock_distance-200) * delta
update_suspicion(d_suspicion)
if flock_timer > 0:
flock_timer -= delta
if flock_timer < 0:
flock(false)
flock_timer = 0
if int(time_to_shearing) % 15 == 0 && flock_timer == 0:
#print("Starting flock")
flock(true)
func _on_ram_pressed():
emit_signal("player_action", "ram")
func _on_eat_pressed():
emit_signal("player_action", "eat")
func update_suspicion(amount):
suspicion += amount
var suspicion_bar = get_node('HUD/SuspicionBar')
suspicion_bar.set_value(suspicion)
if (suspicion > highest_suspicion):
highest_suspicion = suspicion
if suspicion < 0:
suspicion = 0
if (suspicion > max_suspicion):
print("argh")
get_node("PostGameMessage/Label").set_text("Oh no!\n You were too suspicious and the farmer came for you :o")
get_node("PostGameMessage").show()
set_process(false)
game_over('You were too suspicious: the farmer came for you!')
func game_over(message, failure = true):
var n = get_node("HUD/Panel/PostGameMessage/Label")
if failure:
n.set_text("Oh no!\n%s" %[message])
else:
n.set_text("YEAH!!!\n%s" %[message])
get_node("HUD/Panel").show()
get_node("Actors/player").set_fixed_process(false)
process_logic = false
flock(false)
func avg_flock_location():
var p = null
for i in get_tree().get_nodes_in_group('flock'):
if p == null:
p = i.get_global_pos()
continue
p += i.get_global_pos()
return p / get_tree().get_nodes_in_group('flock').size()
func flock(enable = true):
if not enable:
#print("Flocking stopped")
for i in get_tree().get_nodes_in_group('flock'):
i.flock(null, false)
return
var p = randf()
var i = 0
var d = Vector2()
var points = get_node("Level/FlockPoints").get_children();
var point_count = get_node("Level/FlockPoints").get_child_count()
#print(p)
for point in points:
if p >= (float(i)/float(point_count)) and p <= (float((i+1)) / float(point_count)):
d = point.get_global_pos()
flock_destination = d
#print("Flocking to ", d)
i += 1
for i in get_tree().get_nodes_in_group('flock'):
i.flock(d)
flock_timer = rand_range(FLOCK_MIN_TIME, FLOCK_MAX_TIME)
func _on_Replay_released():
#print('replay pressed')
get_tree().change_scene("res://game.tscn")
func _on_Quit_released():
#print('quit pressed')
get_tree().quit()
func _on_Quit_pressed():
_on_Quit_released()
func _on_Replay_pressed():
_on_Replay_released()

217
game.tscn
View File

@ -1,39 +1,37 @@
[gd_scene load_steps=8 format=1]
[gd_scene load_steps=9 format=1]
[ext_resource path="res://game.gd" type="Script" id=1]
[ext_resource path="res://player.tscn" type="PackedScene" id=2]
[ext_resource path="res://sheep.tscn" type="PackedScene" id=3]
[ext_resource path="res://pen.tscn" type="PackedScene" id=4]
[ext_resource path="res://assets/progress.png" type="Texture" id=5]
[ext_resource path="res://scripts/button_ram.gd" type="Script" id=6]
[ext_resource path="res://assets/progress_suspicion.png" type="Texture" id=7]
[ext_resource path="res://assets/black.png" type="Texture" id=2]
[ext_resource path="res://assets/progress.png" type="Texture" id=3]
[ext_resource path="res://assets/progress_suspicion.png" type="Texture" id=4]
[ext_resource path="res://scripts/button_ram.gd" type="Script" id=5]
[ext_resource path="res://scripts/eat_button.gd" type="Script" id=6]
[ext_resource path="res://pen.tscn" type="PackedScene" id=7]
[ext_resource path="res://player.tscn" type="PackedScene" id=8]
[node name="game" type="Node2D"]
transform/pos = Vector2( 31.9212, 31.9212 )
script/script = ExtResource( 1 )
[node name="player" parent="." instance=ExtResource( 2 )]
[node name="HUD" type="CanvasLayer" parent="."]
[node name="KinematicBody2D" parent="." instance=ExtResource( 3 )]
layer = 2
offset = Vector2( 0, 0 )
rotation = 0.0
scale = Vector2( 1, 1 )
transform/pos = Vector2( 357.813, 107.447 )
[node name="Node2D" parent="." instance=ExtResource( 4 )]
transform/pos = Vector2( 143.027, 243.104 )
[node name="TimeLeftBar" type="TextureProgress" parent="."]
[node name="TimeLeftBar" type="TextureProgress" parent="HUD"]
rect/scale = Vector2( 1, 10 )
focus/ignore_mouse = false
focus/stop_mouse = true
size_flags/horizontal = 2
size_flags/vertical = 2
margin/left = 932.0
margin/top = 23.0
margin/right = 982.0
margin/bottom = 73.0
margin/left = 967.0
margin/top = 96.0
margin/right = 1017.0
margin/bottom = 146.0
range/min = 0.0
range/max = 100.0
range/step = 0.1
@ -41,14 +39,39 @@ range/page = 0.0
range/value = 100.0
range/exp_edit = false
range/rounded = false
texture/under = null
texture/under = ExtResource( 2 )
texture/over = null
texture/progress = ExtResource( 5 )
texture/progress = ExtResource( 3 )
mode = 3
radial_fill/fill_degrees = 360.0
radial_fill/center_offset = Vector2( 0, 0 )
[node name="ToolBar" type="HButtonArray" parent="."]
[node name="SuspicionBar" type="TextureProgress" parent="HUD"]
visibility/behind_parent = true
focus/ignore_mouse = false
focus/stop_mouse = true
size_flags/horizontal = 2
size_flags/vertical = 2
margin/left = 966.0
margin/top = 25.0
margin/right = 1016.0
margin/bottom = 75.0
range/min = 0.0
range/max = 100.0
range/step = 0.1
range/page = 0.0
range/value = 100.0
range/exp_edit = false
range/rounded = false
texture/under = ExtResource( 2 )
texture/over = null
texture/progress = ExtResource( 4 )
mode = 3
radial_fill/fill_degrees = 360.0
radial_fill/center_offset = Vector2( 0, 0 )
[node name="ToolBar" type="HButtonArray" parent="HUD"]
anchor/left = 3
anchor/right = 3
@ -56,16 +79,16 @@ focus/ignore_mouse = false
focus/stop_mouse = false
size_flags/horizontal = 2
size_flags/vertical = 2
margin/left = -216.0
margin/top = 522.0
margin/right = -702.0
margin/bottom = 562.0
margin/left = 232.079
margin/top = 553.921
margin/right = -253.921
margin/bottom = 593.921
flat = false
button/count = 0
button/min_button_size = -1.0
button/align = 112
[node name="RamButton" type="ToolButton" parent="ToolBar"]
[node name="RamButton" type="ToolButton" parent="HUD/ToolBar"]
focus/ignore_mouse = false
focus/stop_mouse = true
@ -80,52 +103,134 @@ enabled_focus_mode = 2
shortcut = null
text = "Ram"
flat = true
script/script = ExtResource( 6 )
script/script = ExtResource( 5 )
[node name="SuspicionBar" type="TextureProgress" parent="."]
[node name="EatButton" type="ToolButton" parent="HUD/ToolBar"]
rect/scale = Vector2( 1, 10 )
focus/ignore_mouse = false
focus/stop_mouse = true
size_flags/horizontal = 2
size_flags/vertical = 2
margin/left = -30.0
margin/top = 16.0
margin/right = 20.0
margin/bottom = 66.0
range/min = 0.0
range/max = 100.0
range/step = 0.1
range/page = 0.0
range/value = 100.0
range/exp_edit = false
range/rounded = false
texture/under = null
texture/over = null
texture/progress = ExtResource( 7 )
mode = 3
radial_fill/fill_degrees = 360.0
radial_fill/center_offset = Vector2( 0, 0 )
margin/left = 58.0
margin/top = 1.0
margin/right = 89.0
margin/bottom = 23.0
toggle_mode = false
enabled_focus_mode = 2
shortcut = null
text = "Eat"
flat = true
script/script = ExtResource( 6 )
[node name="PostGameMessage" type="Node2D" parent="."]
[node name="Panel" type="Panel" parent="HUD"]
visibility/visible = false
transform/pos = Vector2( 474.838, 236.982 )
focus/ignore_mouse = false
focus/stop_mouse = true
size_flags/horizontal = 2
size_flags/vertical = 2
margin/left = 312.0
margin/top = 200.0
margin/right = 712.0
margin/bottom = 400.0
[node name="Label" type="Label" parent="PostGameMessage"]
[node name="PostGameMessage" type="Node2D" parent="HUD/Panel"]
transform/pos = Vector2( 32, 32 )
[node name="Label" type="Label" parent="HUD/Panel/PostGameMessage"]
focus/ignore_mouse = true
focus/stop_mouse = true
size_flags/horizontal = 2
size_flags/vertical = 0
margin/left = 0.0
margin/top = 0.0
margin/right = 40.0
margin/bottom = 14.0
margin/left = -27.0
margin/top = -27.0
margin/right = 363.0
margin/bottom = 63.0
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[connection signal="player_action" from="." to="player" method="_on_game_player_action"]
[node name="Replay" type="Button" parent="HUD/Panel"]
focus/ignore_mouse = false
focus/stop_mouse = true
size_flags/horizontal = 2
size_flags/vertical = 2
margin/left = 0.0
margin/top = 100.0
margin/right = 200.0
margin/bottom = 200.0
toggle_mode = false
enabled_focus_mode = 2
shortcut = null
text = "Replay"
flat = false
[node name="Quit" type="Button" parent="HUD/Panel"]
focus/ignore_mouse = false
focus/stop_mouse = true
size_flags/horizontal = 2
size_flags/vertical = 2
margin/left = 200.0
margin/top = 100.0
margin/right = 400.0
margin/bottom = 200.0
toggle_mode = false
enabled_focus_mode = 2
shortcut = null
text = "Quit"
flat = false
[node name="Level" type="Node" parent="."]
[node name="Pen" parent="Level" instance=ExtResource( 7 )]
transform/pos = Vector2( 174.948, 275.025 )
[node name="FlockPoints" type="Node2D" parent="Level"]
editor/display_folded = true
transform/pos = Vector2( 31.9212, 31.9212 )
[node name="1" type="Node2D" parent="Level/FlockPoints"]
transform/pos = Vector2( 475.346, 230.471 )
[node name="2" type="Node2D" parent="Level/FlockPoints"]
transform/pos = Vector2( 842.105, 103.047 )
[node name="3" type="Node2D" parent="Level/FlockPoints"]
transform/pos = Vector2( 844.321, 387.812 )
[node name="4" type="Node2D" parent="Level/FlockPoints"]
transform/pos = Vector2( 88.6427, 390.028 )
[node name="5" type="Node2D" parent="Level/FlockPoints"]
transform/pos = Vector2( 84.2105, 96.3989 )
[node name="Actors" type="Node" parent="."]
[node name="player" parent="Actors" groups=[
"Player",
] instance=ExtResource( 8 )]
transform/pos = Vector2( 500.917, 367.093 )
[connection signal="player_action" from="." to="Actors/player" method="_on_game_player_action"]
[connection signal="pressed" from="HUD/Panel/Replay" to="." method="_on_Replay_pressed"]
[connection signal="released" from="HUD/Panel/Replay" to="." method="_on_Replay_released"]
[connection signal="pressed" from="HUD/Panel/Quit" to="." method="_on_Quit_pressed"]
[connection signal="released" from="HUD/Panel/Quit" to="." method="_on_Quit_released"]

18
grass.gd Normal file
View File

@ -0,0 +1,18 @@
extends Node2D
# class member variables go here, for example:
# var a = 2
# var b = "textvar"
func _ready():
# Called every time the node is added to the scene.
# Initialization here
pass
func is_eatable():
return true
func eat(eater):
eater.turd_count += 1
eater.strength += 1
queue_free()

37
grass.tscn Normal file
View File

@ -0,0 +1,37 @@
[gd_scene load_steps=4 format=1]
[ext_resource path="res://grass.gd" type="Script" id=1]
[ext_resource path="res://assets/grass.png" type="Texture" id=2]
[sub_resource type="RectangleShape2D" id=1]
custom_solver_bias = 0.0
extents = Vector2( 10, 10 )
[node name="Node2D" type="Node2D"]
script/script = ExtResource( 1 )
[node name="Area2D" type="Area2D" parent="."]
input/pickable = true
shapes/0/shape = SubResource( 1 )
shapes/0/transform = Matrix32( 1, 0, 0, 1, 0, 0 )
shapes/0/trigger = false
gravity_vec = Vector2( 0, 1 )
gravity = 98.0
linear_damp = 0.1
angular_damp = 1.0
monitoring = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
shape = SubResource( 1 )
trigger = false
_update_shape_index = 0
[node name="Sprite" type="Sprite" parent="."]
texture = ExtResource( 2 )

18
menu.gd Normal file
View File

@ -0,0 +1,18 @@
extends Node
# class member variables go here, for example:
# var a = 2
# var b = "textvar"
func _ready():
# Called every time the node is added to the scene.
# Initialization here
pass
func _on_Quit_released():
get_tree().quit()
func _on_Play_released():
get_tree().change_scene("res://game.tscn")

194
menu.tscn Normal file
View File

@ -0,0 +1,194 @@
[gd_scene load_steps=4 format=1]
[ext_resource path="res://menu.gd" type="Script" id=1]
[ext_resource path="res://assets/main_menu_bg.png" type="Texture" id=2]
[ext_resource path="res://assets/title.png" type="Texture" id=3]
[node name="Node" type="Node"]
script/script = ExtResource( 1 )
[node name="Background" type="CanvasLayer" parent="."]
layer = 1
offset = Vector2( 0, 0 )
rotation = 0.0
scale = Vector2( 1, 1 )
[node name="TextureFrame" type="TextureFrame" parent="Background"]
focus/ignore_mouse = true
focus/stop_mouse = true
size_flags/horizontal = 2
size_flags/vertical = 2
margin/left = -1.0
margin/top = 0.0
margin/right = 1023.0
margin/bottom = 600.0
texture = ExtResource( 2 )
stretch_mode = 0
[node name="Foreground" type="CanvasLayer" parent="."]
layer = 2
offset = Vector2( 0, 0 )
rotation = 0.0
scale = Vector2( 1, 1 )
[node name="Title" type="TextureFrame" parent="Foreground"]
focus/ignore_mouse = true
focus/stop_mouse = true
size_flags/horizontal = 2
size_flags/vertical = 2
margin/left = 312.0
margin/top = 50.0
margin/right = 712.0
margin/bottom = 250.0
texture = ExtResource( 3 )
stretch_mode = 0
[node name="Play" type="Button" parent="Foreground"]
focus/ignore_mouse = false
focus/stop_mouse = true
size_flags/horizontal = 2
size_flags/vertical = 2
margin/left = 362.0
margin/top = 275.0
margin/right = 662.0
margin/bottom = 375.0
toggle_mode = false
click_on_press = true
enabled_focus_mode = 2
shortcut = null
text = "Play"
flat = false
[node name="Quit" type="Button" parent="Foreground"]
focus/ignore_mouse = false
focus/stop_mouse = true
size_flags/horizontal = 2
size_flags/vertical = 2
margin/left = 362.0
margin/top = 400.0
margin/right = 662.0
margin/bottom = 500.0
toggle_mode = false
click_on_press = true
enabled_focus_mode = 2
shortcut = null
text = "Quit"
flat = false
[node name="Panel" type="Panel" parent="Foreground"]
focus/ignore_mouse = false
focus/stop_mouse = true
size_flags/horizontal = 2
size_flags/vertical = 2
margin/left = 836.0
margin/top = 106.0
margin/right = 986.0
margin/bottom = 416.0
[node name="Label" type="Label" parent="Foreground/Panel"]
focus/ignore_mouse = true
focus/stop_mouse = true
size_flags/horizontal = 2
size_flags/vertical = 0
margin/left = 45.0
margin/top = 20.0
margin/right = 98.0
margin/bottom = 51.0
text = "Controls"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Label1" type="Label" parent="Foreground/Panel"]
focus/ignore_mouse = true
focus/stop_mouse = true
size_flags/horizontal = 2
size_flags/vertical = 0
margin/left = 40.0
margin/top = 135.0
margin/right = 108.0
margin/bottom = 166.0
text = "Conditions"
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Label 2" type="Label" parent="Foreground/Panel"]
focus/ignore_mouse = true
focus/stop_mouse = true
size_flags/horizontal = 2
size_flags/vertical = 0
margin/left = 5.0
margin/top = 50.0
margin/right = 145.0
margin/bottom = 95.0
text = "(1) Ram : Damage fences"
autowrap = true
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Label3" type="Label" parent="Foreground/Panel"]
focus/ignore_mouse = true
focus/stop_mouse = true
size_flags/horizontal = 2
size_flags/vertical = 0
margin/left = 5.0
margin/top = 85.0
margin/right = 145.0
margin/bottom = 130.0
text = "(2) Eat : Grass make you stronger"
autowrap = true
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Label4" type="Label" parent="Foreground/Panel"]
focus/ignore_mouse = true
focus/stop_mouse = true
size_flags/horizontal = 2
size_flags/vertical = 0
margin/left = 5.0
margin/top = 155.0
margin/right = 145.0
margin/bottom = 230.0
text = "Don't become too suspicious - the farmer will come for you. Act like a sheep."
autowrap = true
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Label5" type="Label" parent="Foreground/Panel"]
focus/ignore_mouse = true
focus/stop_mouse = true
size_flags/horizontal = 2
size_flags/vertical = 0
margin/left = 5.0
margin/top = 235.0
margin/right = 145.0
margin/bottom = 310.0
text = "Get out of the pen and off the screen before the time runs out."
autowrap = true
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[connection signal="released" from="Foreground/Play" to="." method="_on_Play_released"]
[connection signal="released" from="Foreground/Quit" to="." method="_on_Quit_released"]

View File

@ -250,4 +250,12 @@ transform/rot = -90.0
transform/pos = Vector2( 715.607, 194.462 )
transform/rot = -90.0
[node name="Spawn-TL" type="Node2D" parent="."]
transform/pos = Vector2( -54.2938, -152.909 )
[node name="Spawn-BR" type="Node2D" parent="."]
transform/pos = Vector2( 689.199, 142.937 )

View File

@ -56,4 +56,12 @@ shape = SubResource( 2 )
trigger = false
_update_shape_index = 0
[node name="VisibilityNotifier2D" type="VisibilityNotifier2D" parent="."]
rect = Rect2( -10, -10, 20, 20 )
[connection signal="exit_screen" from="VisibilityNotifier2D" to="." method="_on_VisibilityNotifier2D_exit_screen"]
[connection signal="exit_viewport" from="VisibilityNotifier2D" to="." method="_on_VisibilityNotifier2D_exit_viewport"]

11
poop.tscn Normal file
View File

@ -0,0 +1,11 @@
[gd_scene load_steps=2 format=1]
[ext_resource path="res://assets/poop.png" type="Texture" id=1]
[node name="Node2D" type="Node2D"]
[node name="Sprite" type="Sprite" parent="."]
texture = ExtResource( 1 )

14
scripts/eat_button.gd Normal file
View File

@ -0,0 +1,14 @@
extends ToolButton
# class member variables go here, for example:
# var a = 2
# var b = "textvar"
func _ready():
# Called every time the node is added to the scene.
# Initialization here
set_fixed_process(true)
func _fixed_process(delta):
if(Input.is_action_pressed("ui_button_2")):
emit_signal('pressed')

View File

@ -11,8 +11,12 @@ var health = 50
func _ready():
# Called every time the node is added to the scene.
# Initialization here
randomize()
get_node('HealthBar').set_max(max_health)
get_node('HealthBar').set_value(max_health)
if randf() <= 0.1:
set_hp(rand_range(max_health * 0.5, max_health))
else:
set_hp(max_health)
pass
func heal(amount):
@ -22,19 +26,24 @@ func damage(amount):
change_hp(-amount)
func change_hp(amount):
var previous_health = health;
health += amount
if (health > max_health):
health = max_health
if (previous_health != health):
var previous_health = health
var next_health = previous_health + amount
if (next_health > max_health):
next_health = max_health
if (previous_health != next_health):
set_hp(next_health)
emit_signal('hp_changed', self)
if (health <= min_health):
if (next_health <= min_health):
emit_signal('hp_empty', self)
queue_free()
func set_hp(h):
health = h
get_node('HealthBar').set_value(health)
if (health < max_health):
if (get_global_rot() != 0):
get_node('HealthBar').set_rotation(-get_rot())
get_node('HealthBar').set_pos(Vector2(-18,15))
get_node('HealthBar').show()
else:
get_node('HealthBar').hide()

View File

@ -15,7 +15,13 @@ var cooldowns = {
'default': 1,
'current': 0,
},
'eat' : {
'default': 0.5,
'current': 0,
}
}
var strength = 1
var turd_count = 0
var facing_collisions = Dictionary()
func _ready():
@ -69,18 +75,37 @@ func _can_do_action(action):
return true
func _do_action(action):
print('Doing: ', action)
#print('Doing: ', action)
if action in cooldowns:
cooldowns[action]['current'] = cooldowns[action]['default']
if action == 'ram':
_do_ram()
elif action == 'eat':
_do_eat()
func _do_ram():
# Ram Distance?
var bodies = get_node('ActionArea').get_overlapping_bodies()
print(bodies)
#print(bodies)
for b in bodies:
if b.has_method('damage'):
b.damage(1)
b.damage(strength)
if get_node('/root/game').has_method('update_suspicion'):
get_node('/root/game').update_suspicion(5)
get_node('/root/game').update_suspicion(5)
func _do_eat():
var areas = get_node('ActionArea').get_overlapping_areas()
#print(areas)
for a in areas:
var n = a.get_parent()
if n.has_method('is_eatable'):
if n.is_eatable():
n.eat(self)
func _on_VisibilityNotifier2D_exit_screen():
get_node('/root/game').game_over("You made it to sweet sweet freedom :)", false)
func _on_VisibilityNotifier2D_exit_viewport( viewport ):
get_node('/root/game').game_over("You made it to sweet sweet freedom :)", false)

69
sheep.gd Normal file
View File

@ -0,0 +1,69 @@
extends KinematicBody2D
# class member variables go here, for example:
# var a = 2
# var b = "textvar"
const STATE_IDLE = "idle"
const STATE_FLOCKING = "flock"
const STATE_ROAM = "roam"
var destination = Vector2()
var state = STATE_IDLE
var blocked_move = Vector2(0, 0)
var turd_count = 0
var strength = 0
func _ready():
# Called every time the node is added to the scene.
# Initialization here
set_process(true)
func _process(delta):
for i in get_node("Area2D").get_overlapping_areas():
var n = i.get_parent();
if n.has_method('is_eatable'):
n.eat(self)
if state == STATE_IDLE:
if randf() < 0.05:
var d = pick_random_destination()
#print("I want wander to ", d)
destination = d
state = STATE_ROAM
if state == STATE_ROAM:
if destination.distance_to(get_global_pos()) < 50:
#print("I have arrived")
state = STATE_IDLE
if state == STATE_ROAM or state == STATE_FLOCKING:
var dir = (destination - get_global_pos()).normalized()
var motion = dir * rand_range(20, 100) * delta
var blocked = move(motion)
if blocked - blocked_move != Vector2(0, 0):
#print(blocked - blocked_move)
if state == STATE_ROAM:
state = STATE_IDLE
#print("I think I might be stuck")
blocked_move = blocked
if turd_count > 0:
poop()
func flock(d, enable = true):
if not enable:
state = STATE_ROAM
destination = pick_random_destination()
return
destination = d
state = STATE_FLOCKING
func pick_random_destination():
var v = get_viewport_rect()
return Vector2(rand_range(v.pos.x, v.end.x), rand_range(v.pos.y, v.end.y))
func poop():
turd_count -= 1
var t = preload("res://poop.tscn")
var n = t.instance()
n.set_global_pos(get_global_pos())
get_node('/root/game/Level').add_child(n)

View File

@ -1,12 +1,18 @@
[gd_scene load_steps=3 format=1]
[gd_scene load_steps=5 format=1]
[ext_resource path="res://assets/sheep.png" type="Texture" id=1]
[ext_resource path="res://sheep.gd" type="Script" id=1]
[ext_resource path="res://assets/sheep.png" type="Texture" id=2]
[sub_resource type="CircleShape2D" id=1]
custom_solver_bias = 0.0
radius = 25.0
[sub_resource type="CircleShape2D" id=2]
custom_solver_bias = 0.0
radius = 15.0
[node name="KinematicBody2D" type="KinematicBody2D"]
input/pickable = false
@ -16,6 +22,7 @@ shapes/0/trigger = false
collision/layers = 1
collision/mask = 1
collision/margin = 0.08
script/script = ExtResource( 1 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
@ -25,6 +32,23 @@ _update_shape_index = 0
[node name="Sprite" type="Sprite" parent="."]
texture = ExtResource( 1 )
texture = ExtResource( 2 )
[node name="Area2D" type="Area2D" parent="."]
input/pickable = true
shapes/0/shape = SubResource( 2 )
shapes/0/transform = Matrix32( 1, 0, 0, 1, 0, 0 )
shapes/0/trigger = false
gravity_vec = Vector2( 0, 1 )
gravity = 98.0
linear_damp = 0.1
angular_damp = 1.0
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
shape = SubResource( 2 )
trigger = false
_update_shape_index = 0