From 96bd9674bd8f0675375ef8587fca14b2c37a0b9c Mon Sep 17 00:00:00 2001 From: bholifie Date: Thu, 20 May 2021 13:14:54 -0500 Subject: [PATCH 1/3] dockerfile builds, runs, and hosts game --- Dockerfile | 14 ++++++++++++++ Dockerfile.fedora | 23 +++++++++++++++++++++++ export_presets.cfg | 9 +++++---- project.godot | 2 +- 4 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 Dockerfile create mode 100644 Dockerfile.fedora diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..20d579c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM barichello/godot-ci:3.3 + +WORKDIR /ghosted + +RUN mkdir -v -p ~/.local/share/godot/templates +RUN mkdir -v -p build/web ~/.local/share/godot/templates + +ADD . . +RUN godot -v --export "HTML5" ./build/web/index.html + +WORKDIR /ghosted/build/web + +CMD ["python", "-m", "SimpleHTTPServer", "7777"] + diff --git a/Dockerfile.fedora b/Dockerfile.fedora new file mode 100644 index 0000000..e8425bd --- /dev/null +++ b/Dockerfile.fedora @@ -0,0 +1,23 @@ +FROM fedora:33 + +WORKDIR /root + +RUN dnf -y upgrade --setopt=install_weak_deps=False && \ + dnf -y install --setopt=install_weak_deps=False \ + bash bzip2 curl git make nano patch pkgconfig python-unversioned-command python3-pip unzip which xz && \ + pip install scons==4.1.0 + +RUN dnf install -y scons pkgconfig libX11-devel libXcursor-devel libXrandr-devel libXinerama-devel \ + libXi-devel mesa-libGL-devel mesa-libGLU-devel alsa-lib-devel pulseaudio-libs-devel \ + libudev-devel yasm gcc-c++ libstdc++-static xorg-x11-apps + + +WORKDIR /ghosted + +ADD . . + +# RUN scons -f /root/SConstruct -j8 platform=server tools=no target=release +RUN scons -f /root/Sconstruct platform=x11 tools=no target=release_debug bits=64 + +CMD ["/ghosted/ghosted.x86_64"] + diff --git a/export_presets.cfg b/export_presets.cfg index c4159dc..8955529 100644 --- a/export_presets.cfg +++ b/export_presets.cfg @@ -7,7 +7,8 @@ custom_features="" export_filter="all_resources" include_filter="" exclude_filter="" -export_path="exported/creep/index.html" +export_path="build/web/index.html" +patch_list=PoolStringArray( ) script_export_mode=1 script_encryption_key="" @@ -27,12 +28,12 @@ html/experimental_virtual_keyboard=false name="Linux/X11" platform="Linux/X11" -runnable=true +runnable=false custom_features="" export_filter="all_resources" include_filter="" exclude_filter="" -export_path="" +export_path="./ghosted.x86_64" script_export_mode=1 script_encryption_key="" @@ -41,7 +42,7 @@ script_encryption_key="" custom_template/debug="" custom_template/release="" binary_format/64_bits=true -binary_format/embed_pck=false +binary_format/embed_pck=true texture_format/bptc=false texture_format/s3tc=true texture_format/etc=false diff --git a/project.godot b/project.godot index 1e597ab..96df5d5 100644 --- a/project.godot +++ b/project.godot @@ -20,7 +20,7 @@ _global_script_class_icons={ [application] -config/name="Dodge the Creeps" +config/name="Ghosted" config/description="This is a simple game where your character must move and avoid the enemies for as long as possible." run/main_scene="res://MainMenu.tscn" From cb20c9f04366343c8f4af638063240cb75665281 Mon Sep 17 00:00:00 2001 From: bholifie Date: Thu, 20 May 2021 13:54:54 -0500 Subject: [PATCH 2/3] oc deploy template --- deploy/deployment.yaml | 44 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 deploy/deployment.yaml diff --git a/deploy/deployment.yaml b/deploy/deployment.yaml new file mode 100644 index 0000000..88d45e6 --- /dev/null +++ b/deploy/deployment.yaml @@ -0,0 +1,44 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: ghosted +spec: + replicas: 1 + selector: + matchLabels: + app: ghosted + template: + metadata: + labels: + app: ghosted + spec: + containers: + - name: ghosted + image: quay.io/bholifie/ghosted:latest + ports: + - containerPort: 7777 + resources: + requests: + memory: "500Mi" + cpu: "500m" + limits: + memory: "2Gi" + cpu: "2" + +--- +apiVersion: v1 +kind: Service +metadata: + labels: + app: ghosted + name: ghosted-service +spec: + ports: + - name: 7777-tcp + port: 7777 + protocol: TCP + targetPort: 7777 + selector: + app: ghosted + sessionAffinity: None + type: ClusterIP From b18ce1a1b68f8f62a0759923c296cc39171f3cbc Mon Sep 17 00:00:00 2001 From: bholifie Date: Thu, 20 May 2021 15:19:05 -0500 Subject: [PATCH 3/3] use requests to get score --- Dockerfile | 5 +++++ Main.gd | 19 +++++++++++++------ Main.tscn | 2 ++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 20d579c..de3b340 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,18 @@ FROM barichello/godot-ci:3.3 +RUN useradd -ms /bin/bash node + WORKDIR /ghosted RUN mkdir -v -p ~/.local/share/godot/templates RUN mkdir -v -p build/web ~/.local/share/godot/templates + ADD . . +# RUN chown -R node:node /ghosted RUN godot -v --export "HTML5" ./build/web/index.html +COPY scores.json /ghosted/build/web/scores.json WORKDIR /ghosted/build/web CMD ["python", "-m", "SimpleHTTPServer", "7777"] diff --git a/Main.gd b/Main.gd index 466e80f..c8da8a2 100644 --- a/Main.gd +++ b/Main.gd @@ -51,20 +51,27 @@ func new_round(): func save_score(score): if $HUD/PlayerList/LocalPlayer.text != "": var file = File.new() +# var file = $HTTPRequest.request("localhost:7777/scores.json") if score > get_player_high_score($HUD/PlayerList/LocalPlayer.text): - file.open("scores.json", File.WRITE) + file.open("./scores.json", File.WRITE) highScores[$HUD/PlayerList/LocalPlayer.text] = score file.store_string(JSON.print(highScores)) file.close() func load_scores(): - var file = File.new() - if file.file_exists("scores.json"): - file.open("scores.json", File.READ) - var json_records = JSON.parse(file.get_as_text()) - file.close() + var file + var request = $HTTPRequest.request("localhost:7777/scores.json") + if request == OK: + var json_records = JSON.parse(request.get_as_text()) return json_records.result + else: + file = File.new() + if file.file_exists("./scores.json"): + file.open("./scores.json", File.READ) + var json_records = JSON.parse(file.get_as_text()) + file.close() + return json_records.result func get_player_high_score(name): diff --git a/Main.tscn b/Main.tscn index 5f8c2c5..c441813 100644 --- a/Main.tscn +++ b/Main.tscn @@ -138,6 +138,8 @@ position = Vector2( 4363.53, 1302.94 ) [node name="HellSpawn3" parent="." instance=ExtResource( 8 )] position = Vector2( 1030.77, 1210.74 ) +[node name="HTTPRequest" type="HTTPRequest" parent="."] + [connection signal="bonus_points" from="Player" to="." method="_on_Player_bonus_points"] [connection signal="hit" from="Player" to="." method="game_over"] [connection signal="timeout" from="MobTimer" to="." method="_on_MobTimer_timeout"]