[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] Custom mousepointer?



> Can I somehow change the mouse pointer? I'd like to change the pointer
> when that game is in a certain state, such as when a movement destination
> is selected, a target is selected etc (this is for a wargame).
> 
> It would be nice to change the pointer to something else, such as a
> crosshair or similar just so that the player knows what is going on. I
> didn't find anything in the docs about that.

this is currently one of the 'holes' in pygame's coverage of sdl.
the main reason is that i haven't determined the best way to do it.

sdl allows you to set the cursor by passing two sequences of of
bits, which represent the AND-mask and XOR-mask. this would be
pretty easy to support, but the problem is it's near impossible 
to create your own cursors with this method. i know visualc has
a cursor editor that creates cursors in this format, i'm pretty
sure xbitmap can create these on the unix side. this is certainly
the easiest method for me, but i'm not sure it's the best.

the other option i'm leaning towards is to store the bitmaps in
a string resource. kind of like the XPM example from the SDL docs.
http://sdldoc.sourceforge.net/current/sdlcreatecursor.html
this is an easy option too, since the code is sitting on the page :]

at this point i think i want to mainly support the "string resource"
type of cursors, but i'll need to have an option to use cursors as the
array of numbers. that is what cursor editors produce. if porting from
SDL to pygame, it would be nice if you didn't have to "hand-render" the
cursor out into a big string :]

what's gonna help you the most jan? i assume if you already have the
crosshair cursor created as the array of numbers then that is all
you'd want. if you have yet to create the cursor then i'm guessing
the string method would be pleasent.

seems like i should be supporting both?



> Another thing, how are Rects supposed to be created? I apparently need to
> send a Rect to Surface.set_clip()? I tried the obvious Rect(x,y,w,h), but
> that didn't work. Passing a tuple [x,y,w,h] to set_clip() gave me a SDL
> segmentation fault.
> 
> Is there somewhere I could read up about the relations between Rect,
> rectstyle and tuples of coords?

sadly, the intro at http://pygame.seul.org/docs/ref/Rect.html is the best
you get for now. it definitely needs to be expanded. i have written better
docs when i created the standalone rect class for pysdl, i just need to get
that stuff merged in. rects are created with pygame.rect(), it's also a
member of the locals module.
the aliens examples make heavy use of the rectangles, you can look at
the oldaliens.py example to see the many ways to move/collide them around.

passing the sequence of (x,y,w,h) is exactly correct. i admit set_clip()
hasn't been tested a whole lot. it should be an easy bug to fix. i expect
i'll have that bug fixes and the cursor functions added by tonight or
tomorrow night.


the other question is, should all functions that create a new object type
(act pretty much like a class constructor) be capitalized. i've been thinking
they should, but have never done it. i think this might make things a bit
clearer to what the function does, pygame.event.event(QUIT) becomes
pygame.event.Event(QUIT). etc, etc. it sounds like what you were expecting
with the Rect, Jan. I think it's a good idea who's time has come.
(sounds like the next release is gonna break a couple things :[ )




____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org