[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Yeah looks like i'm doing quite well so far, completed my goal for today.
Ok heres my outcome. main2.py is the newer one. main.py is the older one.
On 9/10/07, Lamonte Harris <pyth0nc0d3r@xxxxxxxxx
> wrote:Yeah I just seen it lol sorry my mistake. I'll email back when I'm done.
Thanks for all the help, so far so good.
On 9/10/07, Ethan Glasser-Camp
<glasse@xxxxxxxxxx> wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Lamonte Harris wrote:
> def __init(self):
>
> Is that a good start btw?
Most people write __init__ instead of __init.
The best way to figure out of something is a good start is to keep
going with it and see what happens.
Ethan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla -
http://enigmail.mozdev.org
iD8DBQFG5hrxhRlgoLPrRPwRAqWYAKCpUQUCh9m3mTiAz0n/T//x94uwWACfZcZ7
CoD5SMBuWzNG2dQ/PAWTqts=
=ms66
-----END PGP SIGNATURE-----
import pygame,sys,string
from pygame.locals import *
class Block(pygame.sprite.Sprite):
def __init__(self):
pygame.sprite.Sprite.__init__(self)
class map_(object):
def __init__(self,block=100,wndow=(300,300)):
self.BLOCK = block
self.size = wndow
self.window = pygame.display.set_mode(self.size)
self.blocks = []
self.map = []
pygame.init()
def hex_converter(self,hexcolorcode):
hexcolorcode = hexcolorcode[1:]
red = hexcolorcode[0:2]
red = int(red,16)
blue = hexcolorcode[2:4]
blue = int(blue,16)
green = hexcolorcode[4:6]
green = int(green,16)
return (red,green,blue)
def create_box(self,size,color,rect):
box = Block()
box.image = pygame.Surface((size))
pygame.draw.rect(box.image,color,box.image.get_rect())
box.color = color
box.point = rect
self.blocks.append(box)
def load_text_map(self,map):
file = open(map,"r")
links = file.readlines()
file.close()
x = 0
total = len(links)
k = 0
while k<total:
self.map.append([])
k += 1
for i in links:
i = string.replace(i,"\n","")
i = i.split(",")
for e in i:
self.map[x].append(e)
x += 1
def render_map(self,aray,dict):
x=0
for e in aray:
z = 0
for y in e:
aray[x][z] = dict[int(y)]
z += 1
x += 1
return aray
def main(self):
z = 0
x = 0
y = 0
m = 0
while z < len(self.map):
q = 0
while q < len(self.map[z]):
self.create_box(self.map[z][q][0],self.map[z][q][1],(x,y))
x += self.BLOCK
q += 1
x = 0
y += self.BLOCK
z += 1
self.draw_box()
def draw_box(self):
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT: sys.exit()
e = 0
while e < len(self.blocks):
self.window.blit(self.blocks[e].image,self.blocks[e].point)
e += 1
pygame.display.update()
Map = map_(25)
tiles = {1 : [(25,25),Map.hex_converter("#E0ECFF")], 2 : [(25,25),Map.hex_converter("#B5EDBC")], 3 : [(25,25),Map.hex_converter("#F3E807")] }
Map.load_text_map("map1.map")
Map.render_map(Map.map,tiles)
Map.main()
import pygame,sys,string
from pygame.locals import *
class map_:
def __init__(self,block=100,wndow=(300,300)):
self.BLOCK = block
self.size = wndow
self.map = []
self.surfaces = [[],[]]
self.window = pygame.display.set_mode(self.size)
pygame.init()
def create_box(self,size,color,rect):
box = pygame.Surface((size))
pygame.draw.rect(box,color,box.get_rect())
self.surfaces[0].append(box)
self.surfaces[1].append(rect)
def load_text_map(self,map):
file = open(map,"r")
links = file.readlines()
file.close()
x = 0
total = len(links)
k = 0
while k<total:
self.map.append([])
k += 1
for i in links:
i = string.replace(i,"\n","")
i = i.split(",")
for e in i:
self.map[x].append(e)
x += 1
def draw_box(self):
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT: sys.exit()
e = 0
while e < len(self.surfaces[0]):
self.window.blit(self.surfaces[0][e],self.surfaces[1][e])
e += 1
pygame.display.update()
def render_map(self,aray,dict):
x=0
for e in aray:
z = 0
for y in e:
aray[x][z] = dict[int(y)]
z += 1
x += 1
return aray
def hex_converter(self,hexcolorcode):
hexcolorcode = hexcolorcode[1:]
red = hexcolorcode[0:2]
red = int(red,16)
blue = hexcolorcode[2:4]
blue = int(blue,16)
green = hexcolorcode[4:6]
green = int(green,16)
return (red,green,blue)
def main(self):
z = 0
x = 0
y = 0
m = 0
while z < len(self.map):
q = 0
while q < len(self.map[z]):
self.create_box(self.map[z][q][0],self.map[z][q][1],(x,y))
x += self.BLOCK
q += 1
x = 0
y += self.BLOCK
z += 1
self.draw_box()
Map = map_(25)
tiles = {1 : [(25,25),Map.hex_converter("#E0ECFF")], 2 : [(25,25),Map.hex_converter("#B5EDBC")], 3 : [(25,25),Map.hex_converter("#F3E807")] }
Map.load_text_map("map1.map")
Map.render_map(Map.map,tiles)
Map.main()
- References:
- [pygame] Yeah looks like i'm doing quite well so far, completed my goal for today.
- Re: [pygame] Yeah looks like i'm doing quite well so far, completed my goal for today.
- Re: [pygame] Yeah looks like i'm doing quite well so far, completed my goal for today.
- Re: [pygame] Yeah looks like i'm doing quite well so far, completed my goal for today.
- Re: [pygame] Yeah looks like i'm doing quite well so far, completed my goal for today.
- Re: [pygame] Yeah looks like i'm doing quite well so far, completed my goal for today.
- Re: [pygame] Yeah looks like i'm doing quite well so far, completed my goal for today.
- Re: [pygame] Yeah looks like i'm doing quite well so far, completed my goal for today.
- Re: [pygame] Yeah looks like i'm doing quite well so far, completed my goal for today.
- Re: [pygame] Yeah looks like i'm doing quite well so far, completed my goal for today.