Coder Social home page Coder Social logo

sbischoff-ai / pygase Goto Github PK

View Code? Open in Web Editor NEW
42.0 2.0 7.0 1.04 MB

A Python package that contains a high-performance, versatile UDP-based game server, client and network protocol with a simple API.

License: MIT License

Python 100.00%
networking network-protocol udp online-games game-development client-server

pygase's People

Contributors

sbischoff-ai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pygase's Issues

Getting started / Gamestate doesn't expose position and hp

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

time_step doesn't look like to be called every 50Hz

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 !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.