sbischoff-ai / pygase Goto Github PK
View Code? Open in Web Editor NEWA Python package that contains a high-performance, versatile UDP-based game server, client and network protocol with a simple API.
License: MIT License
A Python package that contains a high-performance, versatile UDP-based game server, client and network protocol with a simple API.
License: MIT License
Is this still being developed? Eg Python 3.12 compatibility
Line 26 in 0fc262f
It seams in this line a minimal delay is necessary on my hardware. Adding something like the following fixed:
time.sleep(0.00015)
do you think there's a better solution??
Hi,
I just tried the getting started tutorial but I have a bug, it seems the serialized GameState object returned by client.access_game_state()
doesn't expose the additional attributes (position and hp) added into the initial game state.
While calling
with client.access_game_state() as game_state:
print(game_state.position)
print(game_state.hp)
I got:
Traceback (most recent call last):
File "client.py", line 10, in <module>
print(game_state.position)
AttributeError: 'GameState' object has no attribute 'position'
I typed dir(game_state)
, no position or hp attributes...
Thanks!
Python version: 3.7
Pygase version: 0.3.1
Hi,
I hope you'll see this issue this time :D (no worries)
In my game using pygase I had the feeling it was a little too fast compared to the local version. For example I have a counter which add 10 points every second and definitively it happens faster than every second.
So I added a check in time_step to see how much time was elapsed since the last call (which should be equal to dt
meaning 0.02)
But as expected it looks to be around 0.016 in average.
So time_step
is called 50x in 0.80s in average and not 1s so 20% faster
Here is the code I added in the chase example to check:
last_call = 0
# Define the game loop iteration function.
def time_step(game_state, dt):
global last_call
current_time = time.time()
interval = current_time - last_call
print(f"interval: {interval} vs {dt} => delta {dt-interval} => {interval*50}")
last_call = time.time()
Results
interval: 0.02029275894165039 vs 0.02 => delta -0.0002927589416503902 => 1.0146379470825195
interval: 0.01049351692199707 vs 0.02 => delta 0.00950648307800293 => 0.5246758460998535
interval: 0.01621699333190918 vs 0.02 => delta 0.0037830066680908207 => 0.810849666595459
interval: 0.016791343688964844 vs 0.02 => delta 0.0032086563110351567 => 0.8395671844482422
interval: 0.01358938217163086 vs 0.02 => delta 0.006410617828369141 => 0.679469108581543
interval: 0.01653909683227539 vs 0.02 => delta 0.00346090316772461 => 0.8269548416137695
interval: 0.015427112579345703 vs 0.02 => delta 0.004572887420654297 => 0.7713556289672852
interval: 0.015175819396972656 vs 0.02 => delta 0.004824180603027344 => 0.7587909698486328
interval: 0.016242504119873047 vs 0.02 => delta 0.0037574958801269535 => 0.8121252059936523
interval: 0.014711618423461914 vs 0.02 => delta 0.005288381576538086 => 0.7355809211730957
interval: 0.016119003295898438 vs 0.02 => delta 0.003880996704101563 => 0.8059501647949219
interval: 0.015097618103027344 vs 0.02 => delta 0.004902381896972657 => 0.7548809051513672
interval: 0.016288280487060547 vs 0.02 => delta 0.0037117195129394535 => 0.8144140243530273
Did I misunderstand something ?
Moreover, could you add in the Backend run()
method the interval (if not 0.02 by default) ?
Thanks !
Can this be used as a backbone for an MMO built using Unity3D or Unreal Engine?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.