Skip to content

Commit

Permalink
Merge pull request #16 from ErkMkd/main
Browse files Browse the repository at this point in the history
Fix network mode
  • Loading branch information
ErkMkd authored Jun 17, 2022
2 parents f424986 + 0944600 commit 7960b34
Show file tree
Hide file tree
Showing 16 changed files with 482 additions and 459 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/source/__pycache__
/source/assets_compiled
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ The "Network" mode allows you to control the planes from a third party machine.
| Fast speed 3 | Right Ctrl + move |

## Contributors
* Code & design:
* Code, design, music / sfx:
* Eric Kernin
* 3D graphics:
* Jean-Marie Lamarche
Expand Down
Binary file not shown.
Binary file modified network_client_example/__pycache__/socket_lib.cpython-310.pyc
Binary file not shown.
19 changes: 0 additions & 19 deletions network_client_example/client.py

This file was deleted.

4 changes: 0 additions & 4 deletions network_client_example/client_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Dogfight Sandbox client example
# This script show how to use the network mode to controls aircrafts.
# Before starts this script, Dogfight Sandbox must be running in "Network mode"
3
# dogfight_client.py is the library needed to communicate with DogFight sandbox

import dogfight_client as df
Expand Down Expand Up @@ -125,9 +124,6 @@ def print_fps():
# Renderless mode OFF
df.set_renderless_mode(False)


df.set_machine_custom_physics_mode(plane_id, False)

# Wait while Renderless mode setting up
f = False
while not f:
Expand Down
10 changes: 5 additions & 5 deletions network_client_example/client_sample_custom_physics.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
x, y, z = plane_state["position"][0], plane_state["position"][1], plane_state["position"][2]

# Put aircraft at altitude 25 m
y = 25
y = 45

# Model matrix 3 * 4
plane_matrix = [1, 0, 0,
Expand All @@ -54,23 +54,23 @@

# Custom missile movements
t = 0
while not plane_state["wreck"]:
#plane_state = df.get_plane_state(plane_id)
while (not plane_state["wreck"]) and t < 500 * frame_time_step:
time.sleep(1/60)
plane_state = df.get_plane_state(plane_id)
plane_matrix[9] = x
plane_matrix[10] = y
plane_matrix[11] = z
df.update_machine_kinetics(plane_id, plane_matrix, plane_speed_vector)
df.update_scene()
x = 5 * sin(t*5)
y = 25 + (sin(t)) * 5
y = 45 + (sin(t)) * 5
z = 60 + cos(t*1.256) * 50

# Compute speed vector
plane_speed_vector = [(x-plane_matrix[9]) / frame_time_step, (y - plane_matrix[10]) / frame_time_step, (z - plane_matrix[11]) / frame_time_step]

t += frame_time_step


# Custom physics off
df.set_machine_custom_physics_mode(plane_id, False)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@
# Custom missile movements
t = 0
while not missile_state["wreck"]:
time.sleep(1/60)
missile_state = df.get_missile_state(missile_id)
print(str(y))
missile_matrix[9] = x
missile_matrix[10] = y
missile_matrix[11] = z
Expand Down
2 changes: 1 addition & 1 deletion network_client_example/dogfight_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def enable_log():
def get_running():
socket_lib.send_message(str.encode(json.dumps({"command": "GET_RUNNING", "args": {}})))
return json.loads((socket_lib.get_answer()).decode())


def set_timestep(t):
socket_lib.send_message(str.encode(json.dumps({"command": "SET_TIMESTEP", "args": {"timestep": t}})))
Expand Down
2 changes: 1 addition & 1 deletion source/Machines.py
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,7 @@ def update_kinetics(self, dts):

if self.activated:

self.update_devices(dts) # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
self.update_devices(dts)

self.life_cptr += dts

Expand Down
Loading

0 comments on commit 7960b34

Please sign in to comment.