Jump to content
  • Advertisement
Sign in to follow this  
RidiculousName

Drawing Windows

This topic is 668 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to make a basic mock-up of the combat system in a game I'm designing. There are too many stats for me to really want to use the input function over and over again.

 

So my question is, is it possible to draw a window in python without online mods? If so, where can I learn about it?

 

Secondly, if it's not possible, what graphics mods would you recommend? I'd like something that I could use to make a full-fledged game with.

Edited by RidiculousName

Share this post


Link to post
Share on other sites
Advertisement
What do you mean with "online mods"?
In python there is Tkinter as default graphic library but it's pretty slow.
The best is to use Pygame or pySFML.

Share this post


Link to post
Share on other sites

I want to make a basic mock-up of the combat system in a game I'm designing. There are too many stats for me to really want to use the input function over and over again.
This sounds like you just want to enter some values and then run some computation.

 

If so, why not use Python itself?

Nobody said you cannot have small experimental code in a throw-away program.

 

 

For example, I wanted to check this lua statement last week.

if not (map:getCellFlags(x, y, flags).buildable or flags.passable or flags.owner == player_id ) or
   not (flags[flag_names[1]] and flags[flag_names[2]]) then return false end

There are way too many negations in there to understand what it is doing, so I needed to rewrite it. However, do you check that the rewrite result is actually the same as this monster?

 

Easy, you make an abstract version of the above in a Python function:

def orig(buildable, passable, owned, name1, name2):
    if not (buildable or passable or owned) or not (name1 and name2):
        return False
    return True

and then you throw a check against it:

def valid(buildable, passable, owned, name1, name2):
    return ...  # Unfortunately, I lost my first rewrite attempt as it was completely wrong

for buildable in [True, False]:
    for passable in [True, False]:
        for owned in [True, False]:
            for name1 in [True, False]:
                for name2 in [True, False]:
                    v = orig(buildable, passable, owned, name1, name2)
                    w = valid(buildable, passable, owned, name1, name2)
                    if v and not w: x = "<"
                    elif v and w: x = "=="
                    elif not v and w: x = ">"
                    else: x = "=="
                    print(buildable, passable, owned, name1, name2, v, w, x)

The "valid" function contained my rewrite result, and then the remaining code runs a test whether both functions give the same answer for every possible combination of inputs.

 

This gave me the answer that my first try was completely wrong. It is ieasy to tweak the "valid" function a bit, and rerun this program to check how it works after the change.

After a few iterations, I got what I needed, and applied that in the Lua program. At that point, this Python program had done its job, and could be deleted. Luckily, I don't do that very often, so I still had it to answer this question :)

 

What happens here is that the program also contains the inputs, and you modify the inputs by modifying the program. After being happy, you take out the result you want to keep, and throw away everything else.

 

In my case, I wanted to try all combinations of values, for-loops work best for that. If I wanted to test certain value combinations, I might have written something like

buildable = False
passable = True
owned = False
name1 = True
name2 = False
print(orig(buildable, passable, owned, name1, name2))

And now I can change individual values easily, and see what happens.

Since you have all the power of Python here, it's easy to write some simple code to test things.

 

If you want to keep your values separately in a file, you can use for example JSON, the standard library has a parser for that.

Share this post


Link to post
Share on other sites

What do you mean with "online mods"?
In python there is Tkinter as default graphic library but it's pretty slow.
The best is to use Pygame or pySFML.

 

I just mean with mods that don't come with python when you download it.

Share this post


Link to post
Share on other sites
Hidden

What do you mean with "online mods"?
In python there is Tkinter as default graphic library but it's pretty slow.
The best is to use Pygame or pySFML.

 

I mean mods that aren't included with the base install of Python.

Share this post


Link to post

 

I want to make a basic mock-up of the combat system in a game I'm designing. There are too many stats for me to really want to use the input function over and over again.
This sounds like you just want to enter some values and then run some computation.

 

If so, why not use Python itself?

Nobody said you cannot have small experimental code in a throw-away program.

 

 

For example, I wanted to check this lua statement last week.

if not (map:getCellFlags(x, y, flags).buildable or flags.passable or flags.owner == player_id ) or
   not (flags[flag_names[1]] and flags[flag_names[2]]) then return false end

There are way too many negations in there to understand what it is doing, so I needed to rewrite it. However, do you check that the rewrite result is actually the same as this monster?

 

Easy, you make an abstract version of the above in a Python function:

def orig(buildable, passable, owned, name1, name2):
    if not (buildable or passable or owned) or not (name1 and name2):
        return False
    return True

and then you throw a check against it:

def valid(buildable, passable, owned, name1, name2):
    return ...  # Unfortunately, I lost my first rewrite attempt as it was completely wrong

for buildable in [True, False]:
    for passable in [True, False]:
        for owned in [True, False]:
            for name1 in [True, False]:
                for name2 in [True, False]:
                    v = orig(buildable, passable, owned, name1, name2)
                    w = valid(buildable, passable, owned, name1, name2)
                    if v and not w: x = "<"
                    elif v and w: x = "=="
                    elif not v and w: x = ">"
                    else: x = "=="
                    print(buildable, passable, owned, name1, name2, v, w, x)

The "valid" function contained my rewrite result, and then the remaining code runs a test whether both functions give the same answer for every possible combination of inputs.

 

This gave me the answer that my first try was completely wrong. It is ieasy to tweak the "valid" function a bit, and rerun this program to check how it works after the change.

After a few iterations, I got what I needed, and applied that in the Lua program. At that point, this Python program had done its job, and could be deleted. Luckily, I don't do that very often, so I still had it to answer this question :)

 

What happens here is that the program also contains the inputs, and you modify the inputs by modifying the program. After being happy, you take out the result you want to keep, and throw away everything else.

 

In my case, I wanted to try all combinations of values, for-loops work best for that. If I wanted to test certain value combinations, I might have written something like

buildable = False
passable = True
owned = False
name1 = True
name2 = False
print(orig(buildable, passable, owned, name1, name2))

And now I can change individual values easily, and see what happens.

Since you have all the power of Python here, it's easy to write some simple code to test things.

 

If you want to keep your values separately in a file, you can use for example JSON, the standard library has a parser for that.

 

Thanks!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!