Can't create a new image and blit_into it

117 views
Skip to first unread message

Alex Morais

unread,
Apr 23, 2008, 6:43:19 PM4/23/08
to pyglet-users
I'm working on a Level class for my game in which it will iterate over
the map specification and blit all of the tiles to a texture or
image. This way I can just re-blit the visible region of the map.

Can anyone tell me the proper or prescribed method for instantiating
an image into which I'll be blitting loaded image data?

Txema Vicente

unread,
Apr 23, 2008, 6:54:11 PM4/23/08
to pyglet...@googlegroups.com
Hi. This could work:

bgimage=pyglet.image.create(width,height)
bgimage.texture.blit_into(tile,x,y,0)

> --
> No virus found in this incoming message.
> Checked by AVG.
> Version: 7.5.524 / Virus Database: 269.23.3/1392 - Release Date:
> 22/04/2008 15:51
>
>

Alexander Morais

unread,
Apr 23, 2008, 8:17:12 PM4/23/08
to pyglet...@googlegroups.com
Thanks for the response.  Unfortunately when I tried this I get....

pyglet.image.ImageException: Cannot blit images onto <ImageData 1216x800>.

Here's my code in a nutshell.

MapFloor = image.create(width, height)
    
for y in range(0, self.LevelHeight):
     for x in range(0, self.LevelWidth):
           MapFloor.texture.blit_into(sprite, X, Y)

Alex Holkner

unread,
Apr 23, 2008, 9:02:16 PM4/23/08
to pyglet...@googlegroups.com
On 4/24/08, Alexander Morais <alex...@gmail.com> wrote:
> Thanks for the response. Unfortunately when I tried this I get....
>
> pyglet.image.ImageException: Cannot blit images onto <ImageData 1216x800>.
>
> Here's my code in a nutshell.
>
> MapFloor = image.create(width, height)
>
> for y in range(0, self.LevelHeight):
> for x in range(0, self.LevelWidth):
> MapFloor.texture.blit_into(sprite, X, Y)

That looks like a bug, would you mind providing a complete test case?

(To directly create a texture, use pyglet.image.Texture.create(width,
height) [requires pyglet 1.1]).

Alex.

Alexander Morais

unread,
Apr 23, 2008, 10:52:53 PM4/23/08
to pyglet...@googlegroups.com
ah.  I haven't installed 1.1 yet.  heh.  I guess that may fix the problem.

Ben Sizer

unread,
Apr 24, 2008, 6:53:09 AM4/24/08
to pyglet-users
On Apr 23, 11:43 pm, Alex Morais <alexmm...@gmail.com> wrote:
> I'm working on a Level class for my game in which it will iterate over
> the map specification and blit all of the tiles to a texture or
> image. This way I can just re-blit the visible region of the map.

Why would you want to do this instead of just re-blitting the tiles as
appropriate? Is this for some sort of minimap or something?

--
Ben Sizer

Alexander Morais

unread,
Apr 24, 2008, 3:29:14 PM4/24/08
to pyglet...@googlegroups.com
I was in a crunch and needed to get something going really fast, so I'm sure there are better ways to write map editors.  I was just trying to blit the visible portion of the image instead of reiterating over the tiles.  So, nothing special; just drawing the map.  I've never written a map tiler before.  Know any good libs that use Pyglet for game stuff?  I saw Coco's lib, but I was so deep into my engine that I didn't wanna go backwards.
Reply all
Reply to author
Forward
0 new messages