New answers tagged

1

Have you considered a 2D array? Visual representation: Faction -> | A | B | C | | | | | | V | | | | ---------------------------------- A thinks... | --- | 15% | 89% | ---------------------------------- B thinks... | 12% | --- | 40% | ---------------------------------- C thinks... | 92% ...


1

You could keep the factions in a dictionary inside your scenario/map/level instance, using ("groupA", "groupB") tuples as keys to store the relations between groups. In case relations are always symmetrical/bilateral (I'm an ally for my allies, an enemy for my enemies), you could subclass dict and change it in a way that sorted tuples would be used to ...


3

Data-Driven Design I submitted something like this question to code review recently. After some suggestions and improvements, the result was a simple code that would allow some relative flexibility on weapon creation based on a dictionary (or JSON). The data is interpreted at runtime and simple verifications are done by the Weapon class itself, without the ...


0

As other already said, the sprite.Group iterator yield its members in an unordered way (like a dict, not like a a list). So if you're after a simple unordered list (not properly shuffled with a random method - if you want that follow user744's answer), just get what it gives by default. The "problem" here is quite the contrary: how to get an ordered list ...


0

As others have already said, you should probably refer to a sprite by something else then its order of addition to the group. I'll try to give some examples of uses both using a group and a regular list. sprite.Group You can iterate over sprite.Group (or sprite.Group.sprites() - both give you the same) and check each sprite against some criteria. Should ...


2

The Pygame Rect already comes with a few collision detection functions that may just do what you need: pygame.Rect.contains: test if one rectangle is inside another pygame.Rect.collidepoint: test if a point is inside a rectangle pygame.Rect.colliderect: test if two rectangles overlap pygame.Rect.collidelist: test if one rectangle in a list intersects ...


1

The Singleton pattern is sometimes(!) by some(!) people considered an anti-pattern because it takes measures to make it impossible for more than one object of the class to exist and also provides access to that object from everywhere turning it into a global variable in disguise. This does not mean that it is bad when you have an object where you usually ...


1

Thinking of something like ROTK series, every scenario has a starting date and would benefit from holding the game time as one of its attributes, considering that many of its methods would need to access it. Also, if you think of saving/loading a game, the time should belong to the scenario on the data file - a scenario would then represent the whole game ...


3

Create two separate applications: Your actual game and a launcher. Configure your installer to create shortcuts for the launcher, not the actual game. When the launcher is executed, it first goes online and checks if there is an update for your game. When there is, it downloads it and patches the copy of the actual game. A lightweight way to do this is to ...


0

As Krom Stern pointed out in the comments, the issues with my shadow mapping stemmed from two issues in the pass 2 fragment shader. First, I needed to divide the v_shadowCoord by the w component in addition to performing the correct bias model-view-projection multiplication. This division would normalize my coordinates between 0 and 1 and provide valid ...


0

I am not an expert on python either, but for some reason tick.clock(3) gives problems. I also removed str() as it is useless. (Cleaner code is always better) Try without that line: # Asks for a name def CC(): print "..." print "Welcome...\ What is your name, scared one?" name = raw_input("What is your name?").lower() # For debugging ...


0

If you don't need to process something every single turn/year for every character (though you might do for other reasons) you could just store the birthdate of each character, then when you need to know or display the age, subtract this from the current date. This lets you know the age of every character without having to constantly process and update all of ...


-1

Although I think this is a bit off topic, I know of several places where you can get starting making small games with Unity3D, JavaScript, and Python. Zenva Corp has a plethora of tutorials regarding game development for free, the website to view them is GameDevAcademy.org and it is a great starting resource. Youtube has tons of videos regarding game ...



Top 50 recent answers are included