# Oluseyi

Members

20657

2103 Excellent

• Rank
Contributor
1. ## Should I drop pygame?

Stick with PyGame. There is a tremendous amount of value in learning to solve problems in your given environment. There is also a tremendous amount of value in learning how to iteratively prototype and develop in languages like Python that offer a REPL (Read-Evaluate-Print Loop). Thirdly, there is a tremendous amount of value in learning different approaches/techniques embodied by different languages. A language like Python is deeply, trivially introspective, whereas a language like C# requires more elaborate reflection libraries to approximate the same; or Python's structural flexibility and preference for composition over inheritance versus C#'s object orientation orthodoxy. Over the course of your studies and, should you continue to pursue this professionally, career, you will need to work with and learn many different languages. Completing reasonably complex projects in different languages is a great way to build competence. Finish your current project in PyGame, then reevaluate and see if you want to move to Unity or something else for your next project. Good luck!
2. ## How to encode h264 video

I did exactly this using what is now libav for MPEG/H.264 encoding 5+ years ago. What encoder are you using, @amtri, x264?
3. ## Create polyline with triangles

Ah, I see what you mean. Is this a 2D strip or a full 3D "tube"? I'll tackle the 2D solution now, and then we can extrapolate to 3D as necessary.   The key is that the red points define a line through the center of your strip, and that at each joint the red point is the center of a cross-cutting line whose adjacent angle is precisely half the deflection between the segments. So, starting from the left of your diagram and numbering the red points p1, p2, p3 and p4: at p1 there is no previous segment, so our strip's ends are perpendicular to the vector <p2 - p1>; at p2 the cross section is at an angle relative to <p2 - p1> that is precisely half the angle between <p2 - p1> and <p2 - p3>; at p3 we have no next segment, so our strip's ends are again perpendicular to the vector, this tome <p3 - p2>. Remember that perpendicular lines have slopes that are the negatives of each other.   Using the above, you should be able to generate the points in your strip. Be careful in your algorithm to maintain the correct vertex order. I'll check back in a couple of days to see how you made out.
4. ## Pygame - time and movement issues

Unfortunately I can't run your demo because PyGame on OS X relies on X11, which I won't install, and my Linux box is temporarily out of commission. Nevertheless, I know what your problem is.     In your main loop, you do two things. You update the player position: player_pos[0] += player_speed player_rect.center = player_pos and you update the frame time, setting an upper bound on refresh frequency: frame_duration = clock.tick(FPS) # 1 frame -> ca. 16 milsecs The former assumes that frame_duration is constant, so it uses a constant increment for player position. The latter obtains the actual duration of the frame, which the PyGame docs tell us: "Note that this function uses SDL_Delay function which is not accurate on every platform…"   Your problem is that you are applying what you think is a constant displacement per constant time, yielding constant velocity, but in actuality your time is variable, making your velocity variable. To smooth it out, normalize your displacement by your actual frame time: FPS = 60 player_speed = 0.8 # pixels per frame basis_frame_time = 1.0 / FPS while 1: # ... frame_duration = clock.tick(FPS) frame_displacement = player_speed * (frame_duration / basis_frame_time) player_pos[0] += frame_displacement #... That should do it.
5. ## The new 'Disallowed topics' rule

The fate of these causes is never "decided," anywhere. Change is individual, aggregated. That's why discussion about them is so important: because it's the vector for that individual change.         The rules are the rules. I shall abide them.
6. ## Python Keyword Arguments for Config files?

Isn't that what is the accepted answer here?   Yours is a dictionary wrapped in a function, isn't it? If you're writing configuration purely for a Python program, why not make Python itself the configuration language? It's only worthwhile to invest in a different configuration format if you have to share it with other environments.
7. ## Create polyline with triangles

I'm confused. Per my understanding, a polyline is a series of connected line segments—a polygonal chain. It can exist in 3D space, but it does not intrinsically define any surface, let alone volume. To want to make one out of triangles them strikes me as impossible, nonsensical (in the literal, non-disparaging sense). I'm sure this is a communication breakdown, so can you elaborate some more on what exactly you are trying to say?
8. ## Is Google Play Game Services or Apple Game Center worth it?

He's talking about beta versions of iOS, not beta versions of apps via testflight. And yes, they did remove the ability to rate any apps while running a beta version of iOS, but they only did so about a week back, in response to the wave of one star app reviews Oluseyi mentions.     Yep.
9. ## Python Keyword Arguments for Config files?

First off, it's generally bad form to embed print statements inside a function that returns a value. What if I want to call it in a non-console context? Given Python's native tuples, you can return both the constructed object and an error string—or, even better, raise an exception on error.       The general use for keyword arguments is cases where some of them are optional. That way you don't have to provide a bunch of None values for parameters you don't care about.

11. ## Parable of the Polygons

You have to look at distribution per unit area. In this case, what percentage of shapes have more than 50% of their neighbors being the other shape. In the real world it's the high degree of ethnic concentration you see in some cities/neighborhoods, plus the low degree of interaction between adjacent ethnicities.   In any case, the essay/experiment establishes its own criteria for "diversity," and so the question is whether the above board fulfills it.
12. ## Parable of the Polygons

In that case, you are agreeing with the Parable of the Polygons that the absence of bias is not sufficient to increase diversity. Whether those "other factors" are an explicit demand for diversity by members of the population or legislative requirements or quota systems—passing no judgments on the morality or efficacies of those approaches—they represent more than the absence of bias as a means of engendering diversity/fairness correctives, even in a world where bias is still routine.     Bias is not inherent negative, it is merely a distinct preference for one outcome. We can consider some biases negative, such as being shape-ist in this example, or racist/ageist/colorist/sexist/etc in the real world. We can consider some biases permissible, as long as they are disclosed, such as my bias toward believing in systemic and structural defects in our society that lead to unequal outcomes.
13. ## Parable of the Polygons

You both make the same argument, but you both gloss over the fact that our communities are, and remain, highly segregated, and that "white flight" remains a very real, present phenomenon. Sure, it's a simplified model, but if its correlations are that strong, perhaps the other "outside forces" that you imagine (which we should enumerate and discussion, if you're up to it) aren't as impactful as you might think?   I freely admit my biases here: my own life and experiences incline me toward believing that the status quo is not just a random outcome of unrelated constraints, that intent and reaction are factors. If you have even a simplified mathematical model that argues otherwise, I'd love to see it.
14. ## for each in: Pythonic?

... that phrase makes no sense. duck-typing is an _application_ of polymorphism, not an alternative to it. It does if you understood swiftcoder's phrase as taking a C++-centric notion of "polymorphic" as "concrete types sharing the same inherited ancestor, which is the locus of said polymorphism," as opposed to "types fulfilling Liskov Substitution Principle for the given context." Above all I was trying to say that these types need only share the interface(s) exercised in the aggregated dispatch context (loop body), and no others. If that wasn't his intent, however, then I apologize and you can ignore my comment.
15. ## for each in: Pythonic?

Not exactly. Remember that Python is an aggressive/enthusiastic user of duck typing, so non-polymorphic types that nevertheless expose the same interface can be operated on as a coherent collection.   #Python 2.7 is still my system default; i should change that... L = [(1, 2, 3), "four", [5, 6], {'seven': 8, 'nine': 10, 0: 11}] for item in L: print len(item) # valid for any sequence type print i[0] # valid for any subscriptable object: implement __getitem__() Presumably you have aggregated your objects into a list because they are somehow conceptually related. That relationship should inform your naming. Their concrete types are not exactly irrelevant, but by far a secondary concern.