Posts about programming (old posts, page 13)

2007-10-02 14:11

Everything is still around

For a project I am doing for one of my customers, I needed a mailing list archive. I looked, and it seems the nicer one is Lurker.

Sadly, there are no RPM packages, so I had to build it manually... and ran into mimelib. Which, looking closer, is the same mimelib from Doug Sauder I used in KRN back in the late 90s.

And which I had a hand in GPLing, too. And it's still in use. One of the things I always liked about FLOSS: nothing ever really gets thrown away.

2007-09-14 18:35

New library: ChipScene

This is the real outcome of my PyWeek failure: a neat library.

Take Chipmunk and Qt mash them up, and what do you get?

A OpenGL-accelerated, multiplatform, easy-to-use playground!

But watch the silly video that shows no interesting features instead:

You can't see it but there are 29 balloons, numbered, that bounce around happily.

Performance in the video sucks because I had to disable OpenGL in order to capture it correctly (and video recording kills my notebook,anyway). That demo normally runs in 3 seconds, not 57.

Here's the non-boilerplate code for that demo:

def fillWorld(scene):
  items=[]
  for x in range(1, 29):
      b=cs.CPBodyItem(bpos=[0+13*random.randint(0,25), -50-30*random.randint(0,10)],m=10)
      s=cs.CPCircleShapeItem(10, b, e=.5, offset=[0, 0])
      t=QtGui.QGraphicsSimpleTextItem(str(x), s)
      t.setPos(-5, -5)
      items.append(b)
  items.append(cs.CPSegmentShapeItem([0, 50], [500, 450], 1, None, e=.7))
  items.append(cs.CPSegmentShapeItem([0, 450], [500, 50], 1, None, e=.7))

  for i in items:
      scene.addItem(i)

Neat, isn't it?

You can get it at the ChipScene google code project including, of course, the source.

2007-09-10 07:54

What I learned at PyWeek

  1. I don't have the time for this kind of deadlines anymore. Not even one all-nighter? I did nothing on Saturday except real work and family reunion?
  2. It's really easy to write games with Python. It's mostly just a matter of having a good game concept. The coding is the easy part.
  3. Chipmunk is cool. Qt's graphic scene stuff is cool. My ChipmunkScene is coolest ;-) I should rethink the API but the concept is killer stuff. With a little work this thing is like LEGO!
  4. I will try again in PyWeek6.

2007-09-06 15:27

A little further on TLB

A bit of progress, although not much time to work on it anymore so I will probably not make it.

Objects now can do things when they are hit by other kinds of things.

Example: If a ball hits the bottom of the catapult cup, the catapult shoots. If something hits the target object, you win the level.

2007-09-06 08:43

First pic of TLB

Not a game yet, but the engine is starting to look good.

tlb1

The ball drops, follows both ramps, bounces down the stairs, hits the dominoes, the last one falls on the pivoting ramp, slides down and to the left, falls standing and leans left, then hits the rest of the dominoes.

2007-09-05 17:01

PyWeek progress: the 4 hour mark

Suddenly I was having a calm day at work, and Rosario is taking care of the baby, so I spent a few hours on the PyWeek project.

I have integrated Chipmunk with QGraphicsScene.

What does it mean? That I can now...

  • Create a scene
  • Create a view onto that scene
  • Create balls, walls and polygons as scene items
  • Watch said balls/walls/polygons bounce around happily under Chipmunk direction.

For example, here's enough code to create a few balls a box and a staircase:

self.scene=ChipScene()
self.ui.view.setScene(self.scene)

for x in range (0, 10):
    self.scene.addBall(x*50.0+10, 50.0, 10.)
    self.scene.addBall(x*50.0+20, 20.0, 10.)
self.scene.addWall(0., 0., 0., 500.)
self.scene.addWall(0., 500., 500., 500.)
self.scene.addWall(500., 500., 500., 0.)
self.scene.addWall(500., 0., 0., 0.)
for i in range (0, 20):
    self.scene.addWall(i*20, 200+i*20, i*20+20, 200+i*20)
    self.scene.addWall(i*20+20, 200+i*20, i*20+20, 200+i*20+20)

self.scene.addPoly([[0, 50], [0, 100], [100, 100], [100, 50], [0, 50]])

I declare that nifty.

2007-09-05 09:46

PyWeek5

Well, it seems I am in trouble for PyWeek.

Why? Because it's wednesday and I have done nothing. Nothing! It's because I have been working a lot, really, and I have a 4 month baby, too.

So, I am upping the ante.

I will do a PyDay.

I am taking tomorrow off (yeah, right!) and I'm doing the game in one day. Maybe I will scrounge a few hours on sunday, too.

It will probably not be fit for the contest because:

  • I will use PyQt
  • I won't test it in any platform other than my Linux box

But here's the game concept (BTW: Twisted sucks as a theme. It sucks really, really, really hard!):

According to the dictionary, Twisted also means perverted. So, this game, Twisted Little Boy is about a bad boy. A really bad boy. But a clever one. He creates machines using random equipment he finds to do evil, really mean things.

I will probably do a live-blog thing like those tutorials I wrote years ago about PyQt.

There's a Google code project (obviously empty): http://code.google.com/p/twistedlittleboy/

See you all tomorrow.

2007-08-13 17:59

Django, the view from a parachute

In the last few days I have been learning Django in perhaps the hardest way possible: by being hired to work on a site someone else wrote.

I already had the view from 10000 feet. And since I had to get to this thing rather quickly, I jumped on my parachute from those 10000 feet, and learned it on the way down.

Here's what I knew:

  • Python Web framework
  • Regexp-based URL dispatching
  • Its own template language
  • Its own ORM and form stuff

I have hacked stuff based on TurboGears, Colubrid, pure CherryPy, Mako/Kid/Cheetah/CherryTemplate templates, Routes, Paste and about half a dozen other frameworks or pieces that are used for frameworks, so how new could it be? Well, not very new. I am starting to notice a sort of sameness in these things. They are all alike.

First, the conclusion: I liked it, I could work with it.

Now for some little detail:

  • The URL dispatching is nice ,if not really interesting. there seem to be two ways to do this, all frameworks use one or the other, and almost everyone likes regexps better.
  • The ORM+newforms is quite nice! Of course everything was done with oldforms, which is... not quite so nice. But you can switch pieces as you go, and the code actually simplifies as you hack, so it's good.
  • The template language I could live without. It doesn't seem to be specially featureful, and it didn't seem as expressive to me as my current favourite, Mako. Luckily you can replace it easily. It's not that it's bad, it's just average.

So, I see no reason to learn it instead of Turbogears, or viceversa. On the other hand, if you know one, you can learn the other in perhaps a weekend, so there's no point on not having at least a basic knowledge of both.

2007-08-08 10:59

Be afraid, young pumpkins!

Allow me to enter trash-talking mode...

Be very afraid because this year, my mighty skills are entering PyWeek for the first time.

Just to make it interesting and somewhat challenging:

  • I will be entering as an individual, not in a team.
  • I have not written a line of PyGame code in my life.
  • I have written barely any game code at all.
  • I will submit my final code one day earlier, just because I can.

Nonetheless, I intend to kick asses and ask no questions. I intend to overwhelm you all with a game of such awesomeness you will all whither like lettuce in Lapland. I will write code of such ingenuity you will try to steal it and fail.

...exiting mode.

Should be fun and my entry will probably suck. But we'll see...

2007-08-08 09:05

Me and FLOSS in the late '90s

I have no idea how, but I ran into this in Linuxtoday:

KDE Programming Tutorial 0.2 (Dec 22nd 1998, 00:09:36 )
Roberto Alsina announced that he uploaded to ftp.kde.org the version 0.2 of his excellent programming tutorial. It is also available here. Hopefully, this must-have material will be soon included in the kdesdk package and in CVS.

Now, this was pretty shocking because I don't remember writing it (anyone knows where a copy may be?). I have no idea what was in it, and in fact, the idea of people learning C++ from me in 1998 is so stupid it's shocking, since I knew very little.

Then it hit me, the URL! Ultra7? That was my 486 at college [1].

It had a webserver? What on earth had I been drinking back then? Why can't I remember this???

Wayback machine, come here! Fetch!

Here's my first home page. I must say it's pretty good. It's not garish. Very Web2.0 in the abundant white space.

First interesting thing: there is at least one extant copy of PyXForms, my first free software project, used by absolutely noone.

And there are even two cool screenshot of a functional program noone ever used [2]:

im1im2

In fact, I have no idea how I did that highlighted message display.

Then all that proto-good taste goes away when you reach the page for my most "popular" project ever... Krn in my 1999 home page [4]. It' so 1999 free software style. All that's missing is an electric blue background.

It seems I had discovered The Gimp and it's banner scripts!

BTW: I wonder what's Magnus Reftel doing nowadays? We used to exchange dozens of mails a day and for some reason we lost contact.

There was also a mailing list archive for the very very very first posts of our proto LUG (which would later become LUGLI)

And here's the best part, and the one that makes me kinda sad... Themes for Qt1.

You can read a little about them in this thread.

I have written about them once or twice before but here's the short version:

Rasterman was starting to hack themes for Gtk. I decided they couldn't be the only ones with this cool new technology but I had the big disadvantage of not being able to touch Qt's code because of licensing issues. So I intercepted the drawing events using a LD_PRELOAD hack and implemented a theme full of gradients without modifying or recompiling Qt or KDE.

Now that's one of the most impressive hacks I have ever performed, even if it was a hack done with the most evil code ever, and... there seems to be no extant copy of the code or the screenshots.

Which is kinda sad, indeed.

[1] UNL, where every computer had a public IP address!
[2] The idea was a sort of GUI Pine, all handled with single key strokes. I still pine for that program! [3]
[3] And for the fjords.
[4] AKA the buggiest program ever to be part of KDE proper.

Contents © 2000-2018 Roberto Alsina