game programming tutorials using pyglet

28 views
Skip to first unread message

joey101

unread,
Jul 3, 2008, 7:11:52 PM7/3/08
to pyglet-users
Hello,

I haven't publicized it at all because I don't want much pressure to
make subsequents tutorials but I have written two at http://arcticpaint.com/tutorials/

Both use pyglet. I originally wrote them for pre pyglet 1.0 (although
1.1 beta 1 is required now because I updated it to use text.Label). If
you happen to read though them let me know if I'm doing things un-
pyglety. I haven't really kept up on pyglet development recently.

A couple people suggested I start linking around to them so I thought
I'd mention them here.

Regards,
Joey

Pie21

unread,
Jul 3, 2008, 9:29:27 PM7/3/08
to pyglet-users
Joey,

Looking through the Mines code now and it looks very good. No
criticism I can give because you clearly know a lot more about
programming than I do, but there's some good stuff in there like
setting up the code with the Client class and such, even without
networking. Makes sense, but no one else told me to do that :P

One question though: I assume you used Rabbyt because pyglet 1.0
didn't have the Sprite class. I've never even heard of Rabbyt and
barely used pyglet's sprites to be honest, so which one would you say
is 'better', or are they fairly comparable? Apparently Rabbyt has some
pretty efficient collision detection going for it which I can't find
anything about in pyglet.

In closing, great work, keep it up and keep linking!

- Oliver

joey101

unread,
Jul 4, 2008, 1:13:29 PM7/4/08
to pyglet-users
Hi Oliver,

Thanks for the compliments. It's really only my personal preference to
structure stuff that way. Often times I think it makes the code easier
to get into for someone else. But really I would suggest going with
what ever structure you think best for a particular game. In 99sheep I
don't use that structure because games won't ever be networked,
recorded, logged or anything else that would benefit from a separation
of the display and mechanics. For instance I don't really feel like
creating two classes for each character (shepherd, sheep, wolf etc);
but for snowballz that's a whole different story. :)

I have never used pyglet's sprites so I can't compare the two. I've
used rabbyt since before pyglet 1.0. I like rabbyt because it is very
fast (all the GL calls, animations etc are done in C) and has a simple
API. Extending the sprite works very well (all the xy, x, y, rot, rgb
and so on integrate very well for many many use cases). It's small;
which is good on so many levels. My brother develops it so that makes
it even easier to use (and I have made a couple suggestions that have
gotten implemented so it fits my taste too).
But what I like most about it is the anims. If you haven't checked out
rabbyt.lerp/ease/ease_in/ease_out then you absolutely need to - It's
the best thing since sliced bread. There are some good examples
demonstrating their use in the rabbyt examples directory.
And yes, the collision detection is nice and fast enough.

Reticently, Alex implemented some batch stuff which - unless I've
misunderstood it's purpose - speeds up pyglet's sprite render quite a
bit. But I haven't looked at it yet.

Pretty much the only disadvantage for me with using rabbyt is
distribution. Last time I tried it took some work to get it packaged
with py2exe. But I think that's inherit with not being pure python. I
also had a small hick-up when trying to package it with cx_Freeze in
linux; but it didn't take more than a couple minuets to fix.

/me steps down from soap box. :)

~Joey

Keeyai

unread,
Jul 5, 2008, 2:46:36 PM7/5/08
to pyglet-users
I also use rabbyt and love it. I was using it with pygame and just
continued using it through my time with pyglet. Like Joey stated, it
is very easy to use and works extremely well, so I would definitely
check it out.

Joey, I haven't read your tuts yet, but I like other stuff I've seen
you do so I'm excited about it.

Onirik

unread,
Jul 5, 2008, 3:54:28 PM7/5/08
to pyglet-users
On 4 Lug, 01:11, joey101 <marshallpeng...@gmail.com> wrote:
> Hello,
>
> I haven't publicized it at all because I don't want much pressure to
> make subsequents tutorials but I have written two athttp://arcticpaint.com/tutorials/

wow! great work!! :)
this is very useful to me

Pie21

unread,
Jul 6, 2008, 5:05:05 AM7/6/08
to pyglet-users
On Jul 5, 3:13 am, joey101 <marshallpeng...@gmail.com> wrote:
> Hi Oliver,
>
> Thanks for the compliments. It's really only my personal preference to
> structure stuff that way. Often times I think it makes the code easier
> to get into for someone else. But really I would suggest going with
> what ever structure you think best for a particular game.

I like it as an idea. I spent a while last night going through the
game I'm writing and converting it to the game/client structure and
though it didn't really change anything, it makes a lot more sense
rather than just having everything global. Obviously the real benefit
is for networking (which I'm looking forward to adding in), only I
have no idea how to do it. If I may be so bold, are any future
tutorials going to incorporate networking, or is that kind of outside
your scope? And don't take that as pressure to get another one out
there - take your time. Just a suggestion =)

> But what I like most about it is the anims. If you haven't checked out
> rabbyt.lerp/ease/ease_in/ease_out then you absolutely need to - It's
> the best thing since sliced bread. There are some good examples
> demonstrating their use in the rabbyt examples directory.
> And yes, the collision detection is nice and fast enough.

It certainly seems very fast, but I'm not exactly pushing it yet. The
one problem I have is that the documentation isn't nearly as
comprehensive as pyglet's, which is fair enough but it doesn't explain
a lot beyond what the functions do, such as how to use them.
sprite.shape had and still has me confused - I get what it does, but
not what the numbers for left, right etc mean. Also with lerp it
sounds pretty awesome but kinda bugs out when I try and make my
sprites do it. By which I mean it generally doesn't work. And I don't
know why, and I don't even know the basic stuff I need to have in
place first.

Also it doesn't help that the examples don't appear to be included
with the Windows installer.

joey101

unread,
Jul 6, 2008, 10:49:11 AM7/6/08
to pyglet-users, Matthew Marshall


On Jul 6, 4:05 am, Pie21 <piemaste...@gmail.com> wrote:
> On Jul 5, 3:13 am, joey101 <marshallpeng...@gmail.com> wrote:
>
> > Hi Oliver,
>
> > Thanks for the compliments. It's really only my personal preference to
> > structure stuff that way. Often times I think it makes the code easier
> > to get into for someone else. But really I would suggest going with
> > what ever structure you think best for a particular game.
>
> I like it as an idea. I spent a while last night going through the
> game I'm writing and converting it to the game/client structure and
> though it didn't really change anything, it makes a lot more sense
> rather than just having everything global. Obviously the real benefit
> is for networking (which I'm looking forward to adding in), only I
> have no idea how to do it. If I may be so bold, are any future
> tutorials going to incorporate networking, or is that kind of outside
> your scope? And don't take that as pressure to get another one out
> there - take your time. Just a suggestion =)

You aren't the first one to ask :)
I'm actually already planning on making the next tutorial be an
Othello clone with the focus on networking. I just haven't decided
which networking library to use. Right now for our games we use an in-
house one that works well I think, but it has many pitfalls that are
almost impossible to debug if you make a silly mistake.

When making tutorials I spend about 50% of the time writing the game
and then the other %90 trying to make it easier to understand and
writing all the comments. And that's after planning it all out. In
this case networking is not a trivial thing to pull off. So it takes
some time :P

But I'm glad I decided to target them at programmers beyond the
beginner level; that makes it whole worlds easier to write.

>
> > But what I like most about it is the anims. If you haven't checked out
> > rabbyt.lerp/ease/ease_in/ease_out then you absolutely need to - It's
> > the best thing since sliced bread. There are some good examples
> > demonstrating their use in the rabbyt examples directory.
> > And yes, the collision detection is nice and fast enough.
>
> It certainly seems very fast, but I'm not exactly pushing it yet. The
> one problem I have is that the documentation isn't nearly as
> comprehensive as pyglet's, which is fair enough but it doesn't explain
> a lot beyond what the functions do, such as how to use them.
> sprite.shape had and still has me confused - I get what it does, but
> not what the numbers for left, right etc mean. Also with lerp it
> sounds pretty awesome but kinda bugs out when I try and make my
> sprites do it. By which I mean it generally doesn't work. And I don't
> know why, and I don't even know the basic stuff I need to have in
> place first.

Well, I'm not the one to be talking to about that; so I'm Cc-ing this
to Matthew :)

>
> Also it doesn't help that the examples don't appear to be included
> with the Windows installer.

It's included in the source distribution. If you have rabbyt installed
running the examples should work just fine from there.

~Joey

joey101

unread,
Jul 6, 2008, 10:52:55 AM7/6/08
to pyglet-users
I'm glad it is, that's my goal with writing these. Especially for
helping those that want to move from pygame/SDL to GL (not that my
tutorials have anything to do with OpenGL really).
Reply all
Reply to author
Forward
0 new messages