boskee / Minecraft

Simple Minecraft-inspired program using Python and Pyglet
MIT License
207 stars 33 forks source link

User-settable parameters proposals #52

Closed BertrandBordage closed 11 years ago

BertrandBordage commented 11 years ago

The goal of this proposal is to have more consistent settings. Settings that we change once and for all should be in game.cfg. Settings more likely to be changed should be changed in the menu, and for the moment using command-line parameters.

Proposals for game.cfg:

Proposals for the command-line parameters:

boskee commented 11 years ago

Key bindings can (will) be adjusted in the menu. Sounds good otherwise.

BertrandBordage commented 11 years ago

Great :) I start working on it right now! I will however implement key bindings with names, since it's fairly easy. Something like:

default_key_bindings = {
    'move_forward': key.W,
    'move_backward': key.S,
    […]
}
for control, default in default_key_bindings.items():
    key_name = config.get('Controls', control)
    key_code = getattr(key, key_name, None)
    if key_code is None:
        # Handles cases like pyglet.window.key._1
        key_code = getattr(key, '_' + key_name, default)

OK?

boskee commented 11 years ago

Do it!

BertrandBordage commented 11 years ago

Two first steps achieved with 961a1ed9f3f4d7b40e10d86dea32e59d7a0039ce and cc1de5872ebeb3b904848b9ebe281937803f476b.

I also found out why some parameters were ignored (like "disable-save" or "game-mode") since a few days. Overriding global variables was messy. I fixed it. The lesson I learned is to never use the "global" keyword or "from globals import *" again.

boskee commented 11 years ago

global keyword is bad in pretty much every language (that I used), hence why I tried to move as much as I could into config object. Not sure about "from globals import *" tho?

tfaris commented 11 years ago

Only reason I can think of is if you import * you can't then set the imported variables, because they'll only be set in the local scope instead of at the globals.py module level.

boskee commented 11 years ago

Yeah, just figured it out. You basically import everything from global into the local scope, so what was globals.SOME_VARIABLE is now local_scope.SOME_VARIABLE. Makes sense.

BertrandBordage commented 11 years ago

@tfaris is right. That's why we lost all the settings that were using global. And if we consider that we can use from globals import * to read variables and import globals to set them, this makes 2 ways to use these variables, which will mislead everyone (as it was the case).

BertrandBordage commented 11 years ago

One more step achieved with 98d77474df0c5ad65c34976e20b1cbdbdc48c313 and dd1e3e7e5047937ee876bce83900ba077de450c7.

ronmurphy commented 11 years ago

Damn. ok, so should i start editing like crazy on my end, or ... yeah, i want to keep the blocks that i did today, and toolset, but how can i update to what you have here?

Or should i just wait a it more?

BertrandBordage commented 11 years ago

I'm still working on this whole issue. Have you committed your changes? If not, do it. Then you can fetch my changes to your repository using git pull. If there is a conflict, you will have to fix the changes to merge our changes. Then, test the game. If it doesn't work, try to fix it. If you don't know how to fix it or even if it works, do a pull request, so we can see what to do. You know, maybe you should ask for a PyCharm license (or at least try it for 30 days). PyCharm tells you when you make obvious mistakes and eases git a lot. This could really help you.

BertrandBordage commented 11 years ago

(Oh god, the last part of my previous message looked like I was trying to convince you to go to a retirement home ^^")

ronmurphy commented 11 years ago

LOL! No, it is ok! I have PyCharm installed now, going to use it for a week to see hwow i like it :D

boskee commented 11 years ago

Sorry, I can't help you as I only use command line. I find it easier than any 3rd party client. You just do:

git pull (to fetch the latest revision) git commit -a -m "Commit message" (to commit your changes) git push origin master (to push changes to github)

BertrandBordage commented 11 years ago

Two more steps: cf0ccd62f8fce1539aa7ef3c5b41da7a43d22316 & a5e6a9813efb928e32c101671d921ab8589a53ca

BertrandBordage commented 11 years ago

One major step: 3b666503d46ed61b9319c4bc81e673787ce992e0.

Only one thing left: move command-line parameters width, height, show-gui, draw-distance, fullscreen, save-mode & motion-blur to game.cfg.

BertrandBordage commented 11 years ago

More steps: 1c56c4b46f6ae8b74eab9414318368bed6e8a71f, 7d49348baf1ee4d698c03e7bca29ddeed86774ef, 579dfd6ea2035d2b3d7454fe4101bf98c0fa3496, 8699a6e51bd528c9114020ca969f40cb1b10666b, 6adee7650bf020f8970b589980b00eec2d033ab3, 103781ba8b071c53d6d64ba0fc9504239bd6c972 & 8a60d990872e1255a33bfc938760df51ee0e975f.

BertrandBordage commented 11 years ago

Final steps: 688c50ecaf36f2dc22a4d1a4dad9165a4adfdb55 & d2f95f6bb1d772f27506713b000d362bec320d38.