On 2/03/22 12:02 pm, Irv Kalb wrote:> I'm wondering if my code to check
if an element is within the viewable area, is actually doing more work
than not bothering to check at all.
If the drawing of each object is just a blit call, then your checks are
probably just duplicating what pygame is
On 5/04/21 9:29 am, Irv Kalb wrote:
If I load a font like the system font using None with a call to
pygame.font.font, it happens almost immediately.
But if I load a font by name using pygame.font.SysFont, it's taking over 7
seconds on my Mac to load. It doesn't seem to matter which font I
On 26/12/20 10:57 pm, Pavils Jurjans wrote:
As you can see, in my case the channels point to different addresses,
but still behave as if they are linked. Maybe it is important on what
platform I am running this code?
Perhaps. I suspect they still refer to the same channel id, even
though
On 26/12/20 3:38 am, Pavils Jurjans wrote:
I first play a sound (get the channel object in return), and let it play
until the end. channel.get_sound() returns None, as it should. Then I
play this sound a second time (storing the returned channel object in
another variable). While the sound is
On 15/12/20 4:00 pm, Michael Baca wrote:
The following code, when run, causes an issue where the circle starts to
tear as it moves across the screen
You could try
screen = pg.display.set_mode((600, 400),
flags = pg.HWSURFACE | pg.DOUBLEBUF)
According to the docs, this will cause
You might like to look at these:
https://pythonhosted.org/tale/
https://github.com/lordmauve/adventurelib
--
Greg
On 18/06/20 12:40 pm, pjfarl...@earthlink.net wrote:
Is it possible to use the pygame infrastructure to implement text-mode-only
games? Without having to pick window sizes and resolutions and set fonts
and font sizes, etc., etc., on a graphical surface?
Or am I just looking at the wrong
On 24/03/20 5:52 pm, Irv Kalb wrote:
But I've read here that Python 3.8 doesn't, or at least didn't, work
with the current version of Pygame. Is this still true?
I've just been through the process of trying to get pygame 1.9.6
working with python 3.8 (mainly because they're the current
On 20/02/20 8:57 am, Nuno Maltez wrote:
when I run my test program, Machine B reports FPS > 200, and
pygame.display.flip taking 0.002 per call,
while machine A reports FPS < 60, and pygame.display.flip taking 0.016
per call.
This looks to me like machine A is synchronising its flips
with the
Irv Kalb wrote:
I hadn't thought of the extra "Session" object, it sounds like an interesting
approach. However, I'm looking for a clear solution that I can teach to
students who are just learning about OOP.
Don't think of it as an extra session object, rather think
of it as creating a new
mspaintmaes...@gmail.com wrote:
class ApplicationContext:
def __init__(self):
self.session = GameSession()
def reset(self):
self.session = GameSession()
Nope, this doesn't solve your fundamental problem of getting rid of a
duplicate assignment,
I'd probably do it like this:
You could also try PyWeek competition entries.
--
Greg
Alec Bennett wrote:
16 bit wav files. 1411 kbps. About 5 megs each but one is very long (a
13 minute medley of all of them, 133 megs).
Okay, I didn't realise they were that big -- I was thinking
short horn sounds, not substantial pieces of music!
You bring up a good point, I can certainly
Alec Bennett wrote:
since it needs to load each of the 20 sounds on startup
it takes about 30 seconds to load. I'm running it on a Raspberry Pi,
which doesn't help of course.
How big are the sound files? Unless they're really enormous,
that sounds excessive, even for an R. Pi.
What format
Pablo Moleri wrote:
import time
import pygame
pygame.mixer.init()
sound = pygame.mixer.Sound("my_sound_file.wav")
sound.play()
time.sleep(10)
sound.play()
If that's you're entire program, I'd say it's finishing before
the second sound gets a chance to play. The
gmail aprekates wrote:
The problem i get with the following code is that
the rect moves as if i pressed a key more than one
times.
For me, it works the way I would expect from the code,
i.e. the rect continues to move as long as an arrow key
is held down.
If instead you want it to move one
Russell Jones wrote:
IDK about physics, but AIUI, Z points from side to side, Y points down
and X points diagonally; it's Λ that points up.
Only if your computer screen is oriented vertically.
If you're using a tablet in your lap, Λ points forward
and Y points backwards.
So obviously the code
René Dudfield wrote:
Length is also confusing because... length of the container.
Yes, in Python terms the "length" of a vector should
really be the number of components it has.
(BTW, there's a similar problem in Python itself with using
len() for the size of containers in general. I find
René Dudfield wrote:
So it might be nice to return the length(magnitude) there?
BTW, I don't really like the name "length" for a function
that returns the magnitude of an arbitrary vector. It only
makes sense for vectors representing a physical distance;
it's nonsense for anything else
Daniel Pope wrote:
Y points up in real physics?
No, no, no. Z points up in real physics!
--
Greg
Alex Nordlund wrote:
No, that's the toolbox, the toolbox app is free.
It's also confusingly named :-)
But does it do anything on its own? According to the web
page about it, it's just something for managing their
other tools, which are not free.
If I'm wrong about that, and it actually has
Alex Nordlund wrote:
The toolbox app from jetbrains already does that but better :-)
Also a LOT more expensively, from the looks of their web site.
--
Greg
Leif Theden wrote:
you could maybe create a context menu helper
(i'm not familar enough with os x to advise how to do that) that
launches pycharm with the correct path appended to the pycharm launcher.
It looks like you should be able to do this using Automator:
Ian Mallett wrote:
Hmm I didn't know this, never really viewing Macs as suitable for
development.
Classic MacOS wasn't great for development, but MacOSX is
a flavour of Unix, so you get all the usual developer comforts.
--
Greg
Irv Kalb wrote:
I started working in that environment in the days of Mac
OS9. At that time, the Mac folder separator character was the ":" colon
character.
Yes, in those days it was vitally necessary to use the os.path
functions for cross-platform code.
VMS is another example of a system
Ian Mallett wrote:
As far as I know, the os.path version does a string conversion to the
platform-preferred way of specifying paths.
No, it doesn't -- that only happens if you use normpath():
>>> os.path.join("abc/def", "ghi")
'abc/def\\ghi'
>>> os.path.normpath('abc/def\\ghi')
Irv Kalb wrote:
But then I point out how Python solves this issue by
allowing programmers to use the "/" character as the folder separator
character - and how Python maps that character into the appropriate
character for the operating system on which the program is running.
This is WRONG.
gabrielslo...@gmail.com wrote:
Hey, supose i have a Rect and a Line, i just want to see if the line
intercepts the rect, is that possible somehow in a kind of optimized way
For axis-aligned rectangles you probably want the Cohen-Sutherland
algorithm:
Роман Мещеряков wrote:
I instruct pygame to not use X Window
server (which, if I understand right, should set $DISPLAY environment
variable), but to use framebuffer.
Probably the framebuffer device is owned by root and only allows
access by root. Changing the permissions on /dev/fb might
Martin Kühne wrote:
There appears to be a glReadPixels(0, 0, width, height, GL_RGB,
GL_UNSIGNED_BYTE, pixels) function for that purpose in the OpenGL C
library, maybe pyopengl has an equivalent function?
That will only give you a snapshot of your own OpenGL
drawing area, not anything else on
Lenard Lindstrom wrote:
I was certain I had read about restrictions regarding a window's surface
and a renderer. But I can't find anything in the SDL API docs.
I don't know about SDL, but as far as OpenGL goes, usually
the way it works is that a context can only be bound to one
window (or part
Lenard Lindstrom wrote:
Unfortunately,
the special parser machinery to support Cython includes is only
implemented at the module level. It was never generalized to work in any
code block.
The include statement in Pyrex was something of a hack that I
used for sharing declarations before the
Ian Mallett wrote:
I like this idea a lot, modulo that you should also store the reference
to the window.
The Renderer would hold a reference to the window itself,
so you would only need to keep a separate reference to the
window if you wanted to use different renderers with it
at different
Leif Theden wrote:
While I have not personally tested it, there seems to be more evidence
that windows can contain (use? manage?) more than one Renderer:
If that's true, then it might make sense for the Renderer to have
a 'window' attribute. The Renderer would then be the thing you
keep a
Lenard Lindstrom wrote:
However, after a bit of experimenting I find a window can have both a
renderer and a display surface.
In that case, I'd suggest the Window object should have
'renderer' and 'surface' attributes. If the Renderer or
Surface keeps a reference back to the window, it should
Lenard Lindstrom wrote:
Extension type WindowSurface would add an SDL window C pointer to its
pygame.Surface parent. This window pointer cannot be factored out into a
separate WindowBase parent class. And any methods which access that
pointer will be specific to WindowSurface's C structure
Ian Mallett wrote:
I mean this in a fundamental, mathematical sense. With O(n) rectangles,
you can produce O(n^2) regions that cannot be decomposed into fewer than
O(n^2) disjoint rectangles.
True, but that's a worst case, unlikely to be approached in practice.
Also, for this application,
Ian Mallett wrote:
Unfortunately, computing those rectangles is annoying, and
also O(n^2) in the number of rectangles
With the right data structures and algorithms, it doesn't have to be.
Apple's Quickdraw had some very efficient ways of representing and
operating on regions made up of
Leif Theden wrote:
For those just reading the thread and haven't voiced your opinion,
please do so now.
It would be nice if pygame 2 could have a pygame 1 compatible
subset, because of the aforementioned tutorial materal etc.
out there, and in the interests of users not having to relearn
more
Irv Kalb wrote:
So, my specific question is this: Is there any way for an object to create a
timer, that results to a callback within the same object?
There's nothing built into pygame for doing that as far as
I know. You'll have to build something yourself.
--
Greg
Luke Paireepinart wrote:
Regarding Angular, it's a bit of a mischaraterization to say there's
equivalence between an angular search of content and ctrl+f. For one,
with angular only matching content could be shown, and different
metadata could be used for searching (search on title,
Ian Mallett wrote:
As has been explained before, the reason is due to a
historical deluge of spam.
Perhaps some explanation of the reason could be included
in the message? As it is, this looks like a bug, so you
can't blame people for reporting it as such, or for
getting a bit frustrated when
Ian Mallett wrote:
I think the point is that in the case where you have a lot of small
blits, the proportional overhead of the checks is more significant.
If you have a lot of small blits, I'd expect the general
overhead of Python code overhead to swamp everything else.
--
Greg
Leif Theden wrote:
The fast_blit method would with the barest minimum of checking before
calling the sdl blitting functions.
Have you performed any measurements to find out whether
the checking overhead is significant in the cases where
the formats do match? Without evidence, I'm skeptical
Stuart Laatsc wrote:
Well I don't really /need/ the __dict__ functionality, but it would be
/convenient/ to have /and it is included/ in the official documentation.
Are you sure you're not using an older version of pygame?
If I remember rightly, Event used not to have '__dict__',
only 'dict'.
jcup...@gmail.com wrote:
Have you looked at cffi? It's a modern replacement for ctypes which
automates a lot of this stuff.
Other possible approaches:
* Write a C wrapper around the C++ API and call that
using ctypes.
* Use Cython to wrap the C++ API.
--
Greg
mspaintmaes...@gmail.com wrote:
I'm not an expert, but I think the idea is that you're not supposed to
worry about having to scale your game up for people with super high
resolution displays, which is why it does this. i.e. picking something
that looks comfortable on your display will look
Yann Thorimbert wrote:
As many people did, I have been looking for a GUI for pygame. Naturally, I
have found this page : http://www.pygame.org/tags/gui.
Did you look at Albow? It doesn't seem to be listed
on that page:
http://www.cosc.canterbury.ac.nz/greg.ewing/python/Albow/
--
Greg
Philip Le Riche wrote:
Well, this is strange. In
/usr/lib/python2.7/dist-packages/pygame/examples there is sound.py. This
must have worked for someone once,
It still works for me, using pygame 1.9.2 with
Python 2.7 on MacOSX 10.6.
--
Greg
On 04/08/2015 05:53 PM, JeffreyDanowitz wrote:
However, in my PATH I have /usr/local/lib and both libpng.dylib and
libjpeg.dylib are there.
In that case I would expect things to be able to find it
without any help.
I'm out of ideas at the moment, sorry, other than my
earlier suggestion to try
JeffreyDanowitz wrote:
When I remove the stuff from Homebrew I get:
Using Darwin configuration...
sh: sdl-config: command not found
sh: sdl-config: command not found
sh: sdl-config: command not found
WARNING: sdl-config failed!
/usr/local/bin/smpeg-config: line 45:
JeffreyDanowitz wrote:
When I look at config.py and config_darwin.py and setup and setup.py, there
are references to includes and stuff from where the SDL was installed by
brew. However, there are references to the Framework in /Library/Framework.
Can you show us the output you got from
JeffreyDanowitz wrote:
IMAGE : found
Framework SDL_image found
PNG : found
JPEG: found
It seems to be finding both the framework and non-framework
versions of the SDL libraries. Maybe that's confusing it?
You could try removing the non-framework SDL libraries and
see if that helps.
Mikhail V wrote:
1. It turns out that 32 bit surfaces is an overkill in most cases. Good
that there is 8 bit mode.
What evidence do you have of that? Have you done any
benchmarking?
- how does the indexed image is generally rendered? Is it like: it sends
index array to video card and the
Bo Jangeborg wrote:
According to the documentation
one should be able to pass an object as a parameter
but I am not sure if I am doing it the right way.
I think it means a file object, not the file contents:
file_path = 07-Boabdil, Bulerías.ogg
fi = open(file_path, 'rb')
Bo Jangeborg wrote:
file_path = 07-Boabdil, Bulerías.ogg
fi = open(file_path, 'rb').read()
pygame.mixer.music.load(fi)
But that gets me the Error:
File path 'OggS' contains null characters
music.load() expects to be passed the name of a file,
not the contents of the file. Just do this:
Brian Madden wrote:
I'm
seeing that that when blitting, Pygame will use the source surface's
palette to get the 24-bit entry for each pixel, then look for that
24-bit value in the destination surface's palette, and then write the
8-bit integer value from the destination surface's palette as
Lorenz Quack wrote:
I guess, using PyQt4 lately I followed their convention.
Also using methods makes it more explicit that the values are read-only.
I think that in a pure Python library it's more important to
follow Python conventions than those of some other language
or library. If PyQT has
Lorenz Quack wrote:
* you cannot access the components x/y/z directly...
use ... new accessor methods x()/y()/z()
Is this change really necessary? It will be a big backward
step for code readability.
There shouldn't be any reason you can't provide read-only
access using attribute notation.
Berlioz Silver wrote:
You want pixels2d, which gives you a variable which _references_ the
data.
Yes, sorry, I got it the wrong way round. You need to start
with a normal surface that you can blit into, and then use
pixels2d to create a numpy view of it that you can pass
directly to OpenGL.
sylvain.boussekey wrote:
I managed to do it in opengl but perfs are poor.
A few things to consider:
textureData = pygame.image.tostring(textureSurface, RGBA, 1)
* You're creating an extra copy of the texture data here.
To avoid that, you could use surfarray to create a surface
backed
Jeffrey Kleykamp wrote:
On my not so fast computer, I acheive 400FPS, which is useless but a
good indicator to know how many sprites I can draw simultaneously.
Are you clearing and redrawing the whole screen each frame,
or just drawing the areas where sprites have moved?
If the
diliup gabadamudalige wrote:
for event in pygame.event.get([KEYDOWN, KEYUP, MOUSEMOTION, MOUSEBUTTONUP]):
so far works well. I also noted a slight increase in speed. Is that my
imagination or could specifying the events looked at speed up the process?
It's almost certainly your imagination.
diliup gabadamudalige wrote:
Can someone please explain why
if event.type is KEYUP:
is bad and
if event.type == KEYUP:
is correct?
The 'is' operator tests whether two expressions refer to
the *same* object. It's possible for two different int
objects to have the same value, in which case
is correct. You should just be doing
if x:
...
There might be some very rare cases where comparing
something directly with True or False is justified,
but then whether to use 'is' or '==' will depend
on why you are doing it.
--
Greg
On Mon, Jun 23, 2014 at 11:34 AM, Greg Ewing
Sam Bull wrote:
I don't know if SDL/Pygame is supposed to guarantee these events or
not, it could also be possible that it's just overflowing the keyboard
buffer or something.
Also keep in mind that computer keyboards often don't
handle multiple keys being pressed at once very well,
Jeffrey Kleykamp wrote:
Although it looks like the KEYUP events don't
have a unicode
That is very true, which means this won't work at all:
if event.type is KEYUP:
x = event.unicode
Also, it's a bad idea to use 'is' to compare ints. It
may appear to work in this case, but it's
Al Sweigart wrote:
Oh, also, we should keep the Pygame logo. It's familiar branding, and it
doesn't look bad at all.
I second that. The old site design has an air of
playfulness about it that the new one currently lacks.
It looks bland and doesn't convey that pygame is
about having *fun*.
--
Lenard Lindstrom wrote:
If the bytecode is exposed at the Python end then any expression can be
encoded, a different one for each channel if desired. Conceivably, a
Python expression, or function, could be compiled into a blit operation.
That would be even more awesome!
--
Greg
Lenard Lindstrom wrote:
A Pygame level production blitter would extend the simple bytecode
language to support basic arithmetic operations, different integer
sizes, as well as higher level operations such as pixel
encoding/decoding and alpha blitting. It would replace code in
alphablit.c,
Jason Marshall wrote:
pygamers, which computer operating system(s) have you used this year?
70% MacOSX 10.6, for fun
25% Windows (various flavours), not for fun
5% Fedora Linux, for moderately cool stuff
--
Greg
I don't think I like the stripes. They make it look
to me like the whole thing is flying through the air
in an awkward manner.
If that's not what you're trying to convey, maybe
a solid shadow would be better.
--
Greg
Paul Vincent Craven wrote:
If you are not using sprites, you can just iterate through a list
If you are using sprites, you can create an update() method
Or you can directly move them in a loop
Another approach is not to move the rectangles at all, but
leave them relative to some origin and
ALBOW - A Little Bit of Widgetry for PyGame
Version 2.2 is now available.
http://www.cosc.canterbury.ac.nz/greg.ewing/python/Albow/
Highlights of this version:
* Multichoice control
* Powerful new facilities for hot-linking controls to application data
There are also many other
Lin Parkh wrote:
Hi everyone, I'm compiling a list of professional-quality games made
using Pygame.
The Witch's Yarn
--
Greg
Ian Mallett wrote:
At some level, you need to interface with the graphics drivers. Since
Python is an abstraction layer over C, this means either writing in C
(not Python), or using a package that does that for you.
Not necessarily -- you can use ctypes to wrap a C library.
--
Greg
yannisv wrote:
Yes, I am. The problem is when I set the FPS to ~12, and use clock.tick(FPS)
inside the loop, that movement looks terrible (as expected). When I set the
FPS to 30 or 60, the movement does look better, but the frames change
extremely fast.
If you want smooth animation, you will
Ian Mallett wrote:
On Sat, Oct 6, 2012 at 4:13 AM, shane shanevansh...@yahoo.com
mailto:shanevansh...@yahoo.com wrote:
can graphics from shareware etc be imported
Do you mean like pygame.image.load(...)?
To be a bit more explicit, if you can get hold of the graphics
in any of the
Ricardo Franco wrote:
That's why when you are comparing floating point numbers, you always
have to check if they are within some small error value from each
other. How large that value is depends on your particular use case.
It's even better if you can avoid comparing floats for
Ryan Hope wrote:
Can someone explain to me why integrating network packets with pygame
events is a good idea? It was my understanding that the pygame event
buffer can only hold a limited number of events before events get
lost.
If this turns out to be a problem, it could be addressed by
Weeble wrote:
To get the very best positioning of a text cursor, I think you want to
calculate the width of the string on its left, then *subtract* the
overhang of the character immediately to the left, if any.
For the *very* best results with italic fonts,
you really need a slanted cursor.
Brian Bull wrote:
I need to add some GUI elements
and I'm not aware of any resources that make it easy for me to do this
in pgs4a. I don't want to write my own dialogs, choosers, HTML renderers
or scrolling boxes from scratch if I can possibly avoid it.
You could try Albow:
Peter Finlayson wrote:
I expected the default threshold (0,0,0) of this function to have it
match only that the exact color specified (ie within 0 values of the
color). However, it seems that it instead matches NO pixels.
The third comment about that function here seems to explain
what's
Nicholas Seward wrote:
The letters may be different lengths. However, the letters should be
spaced equally. For example,i will be shorter than w but hit
and hot should be the same length.
No, that's not the way it should work. I just tried an experiment:
f = Font(VeraMono.ttf, 12)
Sam Bull wrote:
If this is something of interest to other people, I'm wondering whether
there might be some interest in integrating this code into Pygame
(sometime after GSoC).
I'm interested! This sounds like it could be very useful.
If done properly, it would make it very easy to use
Lee Buckingham wrote:
I think the iphone 5 can see in ultraviolet.
There's some indication that humans might be able to as well
if our lenses didn't filter it out.
I saw a story a while ago about someone who had the lens and
cornea of one eye replaced by a prosthesis. He claimed to be
able to
Christopher Night wrote:
The idea is that if we could
independently stimulate each of the three colors receptors (cones) in
our eyes, then we could reproduce any visual sensation and thereby any
color. The problem is ... there's no such thing as
a wavelength of light that stimulates the
Miriam English wrote:
The red, blue, yellow that
people have been using for centuries are now often called magenta, cyan,
yellow. But many people still call them red, blue, yellow. They aren't
wrong to do so, but it can make color stuff confusing.
Massively confusing, I would say. The
Brian Brown wrote:
Anyways, I think I should just continue being a solo programmer.
lol I'm too wild when it comes to programming that I think I need my
own space.
Writing well-organised code is not just about communicating with
other programmers. It also helps *you* to understand the code
Florian Berger wrote:
Would it be better to have a BLEND_ADD_PREMULT blit mode instead, i.e.
put the premultiplication in the blitting code?
Not sure that would be the best name for it, since it could
be taken as meaning that the image you give it is already
premultiplied.
Also, it would
Zack Baker wrote:
With fink
I'm on OSX, and I find it's generally less hassle in the long run
to compile everything from source myself rather than rely on things
like fink and macports, so I don't have much experience with them.
But you could look into whether there is a fink version of
On 15/12/11 10:51, Zack Baker wrote:
Ok, I have deleted everything pygame I could find an now I'm going to reinstall
it.
Along with python 3.2 because I guess now they are compatible on OSX which
would be great.
Btw in case it doesn't could you point me too a link that shows how to compile
Zack Baker wrote:
Traceback (most recent call last):
File green-car-test.py, line 10, in module
car=pygame.image.load('green-car.png')
pygame.error: File is not a Windows BMP file
It looks to me as though your PyGame installation doesn't have
support for PNG files. It seems to fall back
Russell Jones wrote:
Well, there is jython http://www.jython.org/. It's a version of Python
that runs under the JVM with, roughly, Python 2.5 syntax.
Unfortunately it appears that Android uses a different Java VM
bytecode from everyone else, and Jython would have to be reworked
to generate
Mac Ryan wrote:
Absolutely not sure it fits the bill... but have you had a look at go?
http://golang.org/
I looked at it. My first impression was this is ugly. I'm pretty
sure it's not the language I was talking about.
--
Greg
On 03/11/11 03:45, Sean Wolfe wrote:
I'm getting into the wonderful world of Android which means Java. Dear
lord I remember now why I hate this language. I love the pythonic
philosophy that there should be an obvious way to get things done.
There's at least one project afoot to enable pygame
On 03/11/11 04:28, Sean Wolfe wrote:
I have been thinking that since I want to
eventually port my game to iphone, I'll have to learn obj-c, so why
not java first... how hard can it be? haha.
Can't see how that would help -- ObjC is nothing at all
like Java. Learning Smalltalk would actually be
On 03/11/11 04:31, Ian Mallett wrote:
C++ is a pain to learn, but it's definitely worth it. In my
opinion it's the best compiled language.
I'm afraid I can't share your opinion of C++. I liked it myself
at first, but after 10 years or so of experience I came to
the conclusion that it goes to
Ian Mallett wrote:
Not sampling in a scaling operation
doesn't make sense. You need at least one sample to get a
reconstruction.
Yes, it's a slightly odd way of phrasing it. I take it to mean
that only one source pixel is sampled for each destination
pixel, rather than interpolating between
John Jameson wrote:
Hi,
I would like an efficient way to generate an animated grey-scale
pixellated image... Another
way might be to just generate the image as a 100X100 image but magnified
and thus automatically obtaining the same result. Is this possible?
You could try using
1 - 100 of 481 matches
Mail list logo