traverseda / pycraft

A fork of "Minecraft in 500 lines of python" intended to someday be used as a real engine, instead of as a learning example.
MIT License
1.09k stars 96 forks source link

Support for the first game state - RUNNING #72

Closed marquesVF closed 8 years ago

marquesVF commented 8 years ago

I made some changes to support Game States and made the logic code inside the Window class to be a Game State named RUNNING.

traverseda commented 8 years ago

Hey, we prefer 4 spaces to tabs. You can use autopep8 to fix that automatically.

I'll merge it now if you want, but it seems easier to fix it on your branch.

marquesVF commented 8 years ago

I'm gonna fixed and request another pull

coveralls commented 8 years ago

Coverage Status

Coverage decreased (-0.2%) to 5.586% when pulling 57fe5165dc08bfc4ff3bb29d969a3cb30189be0a on marquesVF:master into 43d073b01be9d2f59927878233da5394c523a15e on traverseda:master.

marquesVF commented 8 years ago

I think it is ok now

nitori commented 8 years ago

I get this error when trying to place a block:

Traceback (most recent call last):
  File "/home/nitori/.venv/pycraft/bin/pycraft", line 9, in <module>
    load_entry_point('pycraft', 'console_scripts', 'pycraft')()
  File "/home/nitori/source/python/pycraft/pycraft/main.py", line 30, in main
    pyglet.app.run()
  File "/home/nitori/.venv/pycraft/lib/python3.5/site-packages/pyglet/app/__init__.py", line 143, in run
    event_loop.run()
  File "/home/nitori/.venv/pycraft/lib/python3.5/site-packages/pyglet/app/base.py", line 136, in run
    self._run_estimated()
  File "/home/nitori/.venv/pycraft/lib/python3.5/site-packages/pyglet/app/base.py", line 175, in _run_estimated
    if not platform_event_loop.step(estimate) and estimate != 0.0 and \
  File "/home/nitori/.venv/pycraft/lib/python3.5/site-packages/pyglet/app/xlib.py", line 124, in step
    device.select()
  File "/home/nitori/.venv/pycraft/lib/python3.5/site-packages/pyglet/canvas/xlib.py", line 165, in select
    dispatch(e)
  File "/home/nitori/.venv/pycraft/lib/python3.5/site-packages/pyglet/window/xlib/__init__.py", line 900, in dispatch_platform_event_view
    event_handler(e)
  File "/home/nitori/.venv/pycraft/lib/python3.5/site-packages/pyglet/window/xlib/__init__.py", line 1212, in _event_button
    x, y, button, modifiers)
  File "/home/nitori/.venv/pycraft/lib/python3.5/site-packages/pyglet/window/__init__.py", line 1154, in dispatch_event
    if EventDispatcher.dispatch_event(self, *args) != False:
  File "/home/nitori/.venv/pycraft/lib/python3.5/site-packages/pyglet/event.py", line 369, in dispatch_event
    event_type, args, getattr(self, event_type))
  File "/home/nitori/.venv/pycraft/lib/python3.5/site-packages/pyglet/event.py", line 365, in dispatch_event
    if getattr(self, event_type)(*args):
  File "/home/nitori/source/python/pycraft/pycraft/window.py", line 53, in on_mouse_press
    self.gamestatemanager.peek().on_mouse_press(x, y, button, modifiers)
  File "/home/nitori/source/python/pycraft/pycraft/gs_running.py", line 48, in on_mouse_press
    self.world.add_block(previous, self.world.get_block(self.player.block))
TypeError: get_block() takes 1 positional argument but 2 were given
coveralls commented 8 years ago

Coverage Status

Coverage decreased (-0.1%) to 5.593% when pulling 6ae15b48ef5467b1338b086e0db7c7a6db3b4c24 on marquesVF:master into 43d073b01be9d2f59927878233da5394c523a15e on traverseda:master.

marquesVF commented 8 years ago

Fixed

brianbruggeman commented 8 years ago

Some general thoughts here:

  1. Shouldn't some of this be configurable with default values?
  2. Shouldn't we emit events rather than keystrokes?
  3. Shouldn't game state be segregated from UI state?
marquesVF commented 8 years ago

These are thing for us to discuss. I only changed the structure of the actual code to support a Game State Stack approach. The game state classes should definitely be changed according with the contributors decision.