• Content count

  • Joined

  • Last visited

Community Reputation

122 Neutral

About Euronomus

  • Rank
  1. Quote: I don't necissarily agree with the decision but if I had kids I definatly wouldn't want schools teaching them what's right and what's wrong. That would be my job. In this case, I would think of it as a mild suppresion of one person's free speach in exchange for everyone's freedom of beliefs. This ruling protects your right to believe what you want too after all. Apparently you read this article through a mirror, cause you've got it backwards This ruling pretty much gives schools the right to tell students - "You must believe as we do, any vocalazation of dissent or questioning of this belief and you will be punished." Quote: Which reminds me, in that whole story, where are the student unions? Shouldnt they be raising hell over this? I don't know about where this went down, but here in Indiana there are no student unions, at least not in k-12.
  2. bleeps

    Theres no pattern at all and it continues the entire time the comp is on. Plus the noises aren't just simple beeps they seem to modulate and drop off at wierd intervals.
  3. bleeps

    so yesterday I started up my computer and it keeps making random noises (think old school atari/pong noises) from my pc speaker though the comp seems to run fine. I've rebooted in dos and Knoppix and it still happens so I'm guessing its a hardware problem, but I have no clue what hardware failing could cause this to happen, any Ideas?
  4. Python: Saving a surface

    If you still can't get it to work download the PIL its ImageGrab module can take screenshots.
  5. closest point on a line

    Thank you, the whole time I was messing with this I kept thinking there had to be an easier way but all my googling turned up nothing.
  6. closest point on a line

    I'm trying to find how, given a line and a point, to find the closest point on the line to that point. I searched around and could'nt find a standard way, so I've written a function using Bresenhams line alogorithm. I iterate through all the points in the line checking the distance for each point and when the current distance is greater than the previous I return the previous point. It works for most cases but not all and at this point I think I've just been staring at it for to long, so I was hoping someone could point out my problem or point me to a more consice method. this works line = 299, 200, 300, 300 point = 345, 400 this does'nt line = 300, 200, 300, 300 point = 345, 400 import math def find_closest(line, point): x0, y0, x1, y1 = line x2, y2 = point steep = abs(y1-y0) > abs(x1-x0) if steep: x0,y0 = y0,x0 x1,y1 = y1,x1 if x0 > x1: x0,x1 = y1,x0 y0,y1 = y1,y0 deltax = x1-y0 deltay = abs(y1-y0) err = 0 if y0 < y1: ystep = 1 else: ystep = -1 y = x0 old = None for x in range(x0, x1): if steep: d = math.sqrt(math.pow((y-y2),2)+math.pow((x-x2), 2)) if old is None: old = (d, (y, x)) elif d > old[0]: return old[1] old = (d, (y, x)) else: d = math.sqrt(math.pow((x-x2),2)+math.pow((y-y2), 2)) if old is None: old = (d, (x, y)) elif d > old[0]: return old[1] old = (d, (x, y)) err += deltay if err*2 > deltax: y += ystep err -= deltax return old[1] if __name__ == '__main__': import Tkinter class Test(Tkinter.Frame): def __init__(self): Tkinter.Frame.__init__(self) self.grid() self.canv = Tkinter.Canvas(self, height=450, width=450, bg='white') self.line = Tkinter.Entry(self) self.point = Tkinter.Entry(self) self.gobutton = Tkinter.Button(self, text='go', self.canv.grid(row=0, column=0, columnspan=3) self.line.grid(row=1, column=0) self.point.grid(row=1, column=1) self.gobutton.grid(row=1, column=2) self.line.insert('end', '300, 200, 300, 300') self.point.insert('end', '345, 400') def run(self): line = [int(a) for a in self.line.get().split(',')] point = [int(a) for a in self.point.get().split(',')] x0, y0, x1, y1 = line x2, y2 = point x3, y3 = find_closest(line, point) self.canv.delete('all') self.canv.create_line(x0, y0, x1, y1, fill='red') self.canv.create_line(x2, y2, x3, y3, fill='blue') t = Test() t.mainloop() [source\]
  7. Last Ditch Xbox games

    I'd have to second Ninja Gaiden. All the Star Wars games I played were pretty good also, and I'm not a fan of the movies at all.
  8. Waiting to be called an un-cultured American.
  9. If you want something a little more complex try searching for captured Go pieces. It took me a couple of hours to figure that one out, but I don't think it's to complicated to explain once you've written the code.
  10. howto: Transparent Image in Python

    First I would recommend reading The pil handbook , it has a lot of info on the questions you're asking, and if you use pil alot you'll need to refer to it quite a bit. To answer this specific question, you need to understand image alpha values. Put simply an alpha value is an integer between 0 and 255, 0 being completely transparent, and 255 being completely opaque. img.paste takes 3 args, (sourceimage ,position, mask). The mask is a single-band image, or an image with an alpha band. Wherever the mask image has a value of 0 the "underneath" pixel will show, wherever it has a value of 255 the "above" pixel will show, and any value in-between will result in a mixture of both pixels. if you want an image to hold its own alpha band it needs to be converted to 'RGBA' mode (if its not already) then you can just use an image as its own mask. eg. image.paste(image2, pos, image2) Now if all you want to do is remove one color (colorkeying), I haven't found an "easy" way to do it but you can do something like this: (not tested) def getmask(img, color): data = img.getdata() mask ='L', img.size, 255) mdata = mask.getdata() for ind, pix in enumerate(data): if pix == color: mdata[ind] = 0 mask.putdata(mdata) return mask but I imagine this would be quite slow [Edited by - Euronomus on January 24, 2007 3:12:11 PM]
  11. where do i go next?

    Quote: if there is a way to randomly select a word from a list... please share :) import random words = ['this', 'is', 'a', 'list', 'of', 'words'] word = random.choice(words)
  12. Singleton alternative

    Wow you guy's are fast. Quote: What's wrong with passing the resources you need (display object, fonts, other stuff) when you instantiate your Battlescene class? This is what I was hoping to get away from. It just feels unwieldly to pass my Battle class several args it won't need just so it can pass them down the line. battle = Battle(, beast, self.display, self.fonts, self.avatars, self.cursor, musicfile, self.mixer, self.input) so battle can in-turn instantiate Battlescene with its own long set of args Quote: You need to look at the objects on a case by case basis, figure out their lifetimes and who really needs to access them. So are you saying maybe make my Battle class live for the life of the program then give it a method to call every time an actual battle occurs?
  13. Singleton alternative

    I'm currently in the process of refactoring my first real game. I have a handfull of singletons I'd like to factor out of the new version. After giving it some thought, I came up with the solution of making a master class with my needed resources as class attributes. I could then have the classes that need the resources inherit from said master class. (in python) class Resources(object): @classmethod def init(cls, fontdata): cls.display = Display() cls.fonts = Fonts(fontdata) cls.dimages = ImageHandler('') cls.avatars = ImageHandler('') #all classes that inherit have access to the necessary Instances class Battlescene(Resources): def draw(self): img = self.dimages['BattleScene'] self.display.draw(img, self.pos) Is this an acceptable alternative or am I misusing inheritance?