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

Re: [pygame] Let's begin some questions...



Sorry... I missed out one fn from pyplace:

def load_raw(name, path=None):
   "load an image, don't change anything"
   file = data.name(name, path)
   return pygame.image.load(file)
 

So you need to do something like:
import pygame
import pygame.image, pygame.draw, pygame.transform
from pygame.locals import *

Then you can use pygame.image.load
 

Panagiotis Halatsakos wrote:

 nope... i had something similar in visual basic but I am beginning from scratch ...Which library has the load_raw() function?
----- Original Message -----
Sent: Friday, September 07, 2001 4:06 PM
Subject: Re: [pygame] Let's begin some questions...
 Nope only supports isometric, specialised for that
120x60 or 60x30 (although currently I've only got images at 120x60 and am shrinking them to display).

Do you have a data structure for your units/map/buildings &c. yet? I could look at what would be involved in rendering iso

p.

Panagiotis Halatsakos wrote:

 Interesting...Does your pyplace support tiles like 32x32 and 64x64 and so? I am planning to use a pure 2d (not isometric in the beggining) environment... Panos
----- Original Message -----
Sent: Friday, September 07, 2001 3:28 PM
Subject: Re: [pygame] Let's begin some questions...
 This worked for me, to create array containing images and shrink it
import Numeric as N
import pygame.surfarray as surfarray
def load(name, path=None):
   "load an image, halve if it small tiles tune flags for display mode"
   img = load_raw(IMGPREFIX + name, path)
   if SHRINKIMAGES:
      img = halve_image(img)
   if not img.get_flags() & HWSURFACE:
      transparentcolourkey = 255,0,0
      img.set_colorkey(transparentcolourkey, RLEACCEL)
   return img.convert()
def halve_image(img):
   "halve an image in both dimensions, force transparent colour to RED"
   imgarray=surfarray.array3d(img)
   (src_maxx,src_maxy) = img.get_size()
   # All images must have even width and height values
   smallpic = pygame.Surface((src_maxx>>1,src_maxy>>1))
   surfarray.blit_array(smallpic,imgarray[::2,::2])
   if not smallpic.get_flags() & HWSURFACE:
      transparentcolourkey = 255,0,0
      smallpic.set_colorkey(transparentcolourkey, RLEACCEL)
   return smallpic
 

This is from pyplace/gfx.py

If you get the pyplace code from pyplace.sourceforge.net then you have tile blitting and image halving and things, you'd want version alpha 0f
which I'll upload (tar and cvs tag) in about 5 minutes.
 

Panagiotis Halatsakos wrote:

Ok Well since I am new with all the pygame/python... How do arrays work there? I want to translate my (formerly) directx tilemap reader to python for the project... Is there a specific package I need to use to do arrays? I mean the only data that I found are tuples and ordinary data types.... Thanks in advance...