kubernetes will be made into a 3D shooting game, fun can not stop, with source code

Hello, I'm xiaowantang. Today I'm demonstrating a project that uses Unity to do scenes and C# to do interactive logic to make k8s a 3D shooting game. I happen to be learning Unity recently, so it's appropriate to start with this project.

kube-chaos It is a shmup game based on chaotic engineering style.

Shmup: a shooting game that can control a plane ✈️, Or characters, the game of fighting the enemy, usually rolling horizontally or vertically in the air.

This game is combined with kubernetes cluster, allowing you to enter the cluster node to explore the Pod, fire bullets and destroy the Pod running on the node. Game interaction logic is c# written and driven by Unity engine.

prerequisite

  • You need to have a kubernetes cluster in advance
  • The namespace can be destroyed at will as a battlefield
  • The hardware resources on the local machine use the Unity engine to run the game
  • Unity 2019.4 or later

Start practice

~ /. On current Mac machine kube/config contains two cluster context s:

# kubectl config get-contexts 
CURRENT   NAME               CLUSTER          AUTHINFO         NAMESPACE
*         context-cluster1   cluster1         admin            
          docker-desktop     docker-desktop   docker-desktop

The context corresponding to cluster1 is context cluster1. It is a test cluster with more nodes and pods. It is more exciting to play, but it is risky.

The context corresponding to docker desktop is docker desktop. It is a local cluster with fewer pods, which is more secure.

from Project Releases Page to download the Windows or MacOS version. Here's an example on the Mac.

After downloading the compressed package of MacOS, unzip it, enter the executable directory and run KubeChaos:

wget https://github.com/Shogan/kube-chaos/releases/download/1.0.0/KubeChaos_macOS_1.0.0.zip
unzip KubeChaos_macOS_1.0.0.zip
cd KubeChaosmacOS/Contents/MacOS
./KubeChaos 

You will enter such an interface and enter the cluster namespace, cluster context and kubectl (which must be in System Path) from top to bottom:

Then run Start to enter the game interface.

Build your own program

If you want to add your own functional inspiration on the shoulders of predecessors, then compile the source code, build your own executable files, build multiple platforms and run on Win, Linux and macOS, you can follow the following steps.

Start Unity Hub, click Add Project on the project page, and select the root folder of the project.

On the first load, Unity will generate library assets, which may be slow.

Enter file - > Build settings, or use the shortcut key: Windows: Ctrl+Shift+B; Mac: Command+Shift+B. Ensure that the settings and scenarios in Build are as shown in the following figure:

Configure the Target Platform as the platform you want to build. The options in the drop-down box here, such as Windows/macOs/Linux, need to check the Target Platform when installing Unity:

Other configurations in the Player Settings button can remain the default.

Click Build and select a Build output location where you can output to the project root directory:

After that, the executable file will be output to this location, and the construction will take some time, depending on the machine performance:

This actually generates a Kube chaos me App Directory:

# ls -l                  
-rw-r--r--   1 smallsoup  test  53894 Jan 18 17:46 Assembly-CSharp.csproj
drwxr-xr-x  14 smallsoup  test    448 Jan 18 15:22 Assets
drwxr-xr-x  41 smallsoup  test   1312 Jan 18 19:08 Library
drwxr-xr-x   3 smallsoup  test     96 Jan 18 17:29 Logs
drwxr-xr-x   4 smallsoup  test    128 Jan 18 17:32 Packages
drwxr-xr-x  23 smallsoup  test    736 Jan 18 19:05 ProjectSettings
-rw-r--r--   1 smallsoup  test   3797 Jan 18 15:22 README.md
drwxr-xr-x  44 smallsoup  test   1408 Jan 18 19:08 Temp
drwxr-xr-x   6 smallsoup  test    192 Jan 18 15:22 docs
drwxr-xr-x   3 smallsoup  test     96 Jan 18 19:08 kube-chaos-me.app
-rw-r--r--   1 smallsoup  test    712 Jan 18 17:46 kube-chaos.sln
drwxr-xr-x   3 smallsoup  test     96 Jan 18 18:48 obj
# cd kube-chaos-me.app/Contents/MacOS 

# ls
KubeChaos

#  ./KubeChaos

Run the KubeChaos executable to start the game.

Video tutorials and source code can sweep left code concern WeChat official account [my small bowl soup]

original text

This article starts with WeChat official account, my small bowl soup, scan the left side code, pay more attention to more consultation, and have more free resources for you to learn.

Keywords: Kubernetes Unity Unity3d

Added by Destruction on Sat, 22 Jan 2022 08:51:34 +0200