def __init__(self, main): self.main = main self.drawPriority = 3 self.explosionLastTime = 30 #Of image part self.explosionPoints = [] #X,Y,Time,minRad,maxRad self.explosionImage = helpers.loadPNG('explosion')[0] self.xScroll = 0 self.yScroll = 0 self.particleEffect = PyIgnition.ParticleEffect( self.main.drawScreen, (0, 0), self.main.drawScreen.get_size()) self.particleSource = self.particleEffect.CreateSource((0,0),initdirection=0.0,initdirectionrandrange = math.pi, particlesperframe = 0, \ particlelife = 30, drawtype = PyIgnition.DRAWTYPE_LINE, colour = (255,255,255), length=8.0) self.particleSource.CreateParticleKeyframe(10, colour=(255, 0, 0)) self.particleSource.CreateParticleKeyframe(20, colour=(0, 255, 0)) self.particleSource.CreateParticleKeyframe(30, colour=(0, 0, 255)) self.particlesEmitTime = 1 #How long to emit particles after an explosion. #Lift on particles '''strength = 0.20 strengthrandrange = 0; gravity = self.particleEffect.CreateDirectedGravity(strength, strengthrandrange, (0,-1))''' '''#Wind on particles
def __init__(self, parent): wx.Frame.__init__(self, parent, -1) self.panel = wx.Panel(self, -1) self.hwnd = self.GetChildren()[0].GetHandle() os.environ['SDL_VIDEODRIVER'] = 'windib' os.environ['SDL_WINDOWID'] = str(self.hwnd) self.statusbar = self.CreateStatusBar() self.statusbar.SetFieldsCount(3) self.statusbar.SetStatusWidths([-3, -4, -2]) self.statusbar.SetStatusText("ExeSoft Obsidian", 0) self.statusbar.SetStatusText("Look, it's a nifty status bar!!!", 1) pygame.display.init() self.screen = pygame.display.set_mode() self.Bind(wx.EVT_PAINT, self.Draw) self.Bind(wx.EVT_SIZE, self.OnSize) self.Bind(wx.EVT_CLOSE, self.Kill) self.val = 0 self.SetTitle("ExeSoft Obsidian") self.size = self.panel.GetSizeTuple() self.effect = PyIgnition.ParticleEffect(self.screen, (0, 0), self.size) self.source = self.effect.CreateSource( (self.size[0] / 2, self.size[1]), initspeed=5.0, initdirection=0.0, initspeedrandrange=2.0, initdirectionrandrange=0.2, particlesperframe=10, particlelife=200, drawtype=PyIgnition.DRAWTYPE_POINT, colour=(255, 255, 200)) self.grav = self.effect.CreateDirectedGravity(0.0, 0.2, [1, 0]) self.gravslider = wx.Slider(self, wx.ID_ANY, 0, -50, 50, style=wx.SL_HORIZONTAL | wx.SL_LABELS) self.gravslider.SetTickFreq(0.1, 1) self.Bind(wx.EVT_SCROLL, self.OnScroll) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.gravslider, 0, flag=wx.EXPAND) sizer.Add(self.panel, 1, flag=wx.EXPAND) self.SetAutoLayout(True) self.SetSizer(sizer) self.Layout()
def __init__(self, game): self.game = game self.fire = PyIgnition.ParticleEffect(game.screen, (0, 0), (800, 600)) self.source = self.fire.CreateSource( (300, 500), initspeed=2.0, initdirection=90.0, initspeedrandrange=0.1, initdirectionrandrange=0.5, particlesperframe=3, particlelife=100, drawtype=PyIgnition.DRAWTYPE_CIRCLE, colour=(255, 200, 100), radius=3.0) self.source.CreateParticleKeyframe(10, colour=(200, 50, 20), radius=1.0, length=1) self.moving = False self.target_coords = None
def __init__(self, main): self.main = main self.drawPriority = 0 position = (self.main.FIELD_WIDTH / 2, -300) angToCorner = math.atan2(300, self.main.FIELD_WIDTH / 2) self.particleEffect = PyIgnition.ParticleEffect( self.main.drawScreen, (0, 0), self.main.drawScreen.get_size()) self.particleSource = self.particleEffect.CreateSource( position, initdirection=math.pi, initdirectionrandrange=math.pi / 2 - angToCorner, particlesperframe=2, particlelife=100, initspeed=5, initspeedrandrange=4, drawtype=PyIgnition.DRAWTYPE_BUBBLE, colour=(255, 255, 255), radius=3) #, length=8.0)
def __init__(self, parent, ID): wx.Window.__init__(self, parent, ID) self.parent = parent self.hwnd = self.GetHandle() os.environ['SDL_VIDEODRIVER'] = 'windib' os.environ['SDL_WINDOWID'] = str(self.hwnd) pygame.display.init() self.screen = pygame.display.set_mode() self.size = self.GetSizeTuple() self.timer = wx.Timer(self) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_TIMER, self.Update, self.timer) self.Bind(wx.EVT_SIZE, self.OnSize) self.fps = 60.0 self.timespacing = 1000.0 / self.fps self.timer.Start(self.timespacing, False) self.effect = PyIgnition.ParticleEffect(self.screen, (0, 0), self.size) self.source = self.effect.CreateSource( (self.size[0] / 2, self.size[1]), initspeed=5.0, initdirection=0.0, initspeedrandrange=2.0, initdirectionrandrange=0.2, particlesperframe=10, particlelife=200, drawtype=PyIgnition.DRAWTYPE_CIRCLE, colour=(255, 20, 200), radius=0.0) self.source.CreateParticleKeyframe(100, radius=20.0) self.source.CreateParticleKeyframe(25, colour=(255, 0, 100)) self.source.CreateParticleKeyframe(50, colour=(100, 255, 100)) self.source.CreateParticleKeyframe(75, colour=(0, 100, 255)) self.source.CreateParticleKeyframe(200, colour=(0, 0, 0)) self.grav = self.effect.CreateDirectedGravity(0.0, 0.2, [1, 0]) self.circle = self.effect.CreateCircle((300, 300), (255, 255, 255), 0.5, 50)
import PyIgnition, pygame, sys, math, random, constants from constants import * screen = pygame.display.set_mode((1250, 675)) pygame.display.set_caption("Simulation!!!") clock = pygame.time.Clock() effect1 = PyIgnition.ParticleEffect(screen, (25, 25), (1200, 625)) effect2 = PyIgnition.ParticleEffect(screen, (25, 25), (1200, 625)) effect3 = PyIgnition.ParticleEffect(screen, (25, 25), (1200, 625)) effect4 = PyIgnition.ParticleEffect(screen, (25, 25), (1200, 625)) effect5 = PyIgnition.ParticleEffect(screen, (25, 25), (1200, 625)) effect6 = PyIgnition.ParticleEffect(screen, (25, 25), (1200, 625)) effect7 = PyIgnition.ParticleEffect(screen, (25, 25), (1200, 625)) effect8 = PyIgnition.ParticleEffect(screen, (25, 25), (1200, 625)) effect9 = PyIgnition.ParticleEffect(screen, (25, 25), (1200, 625)) effect10 = PyIgnition.ParticleEffect(screen, (25, 25), (1200, 625)) source1 = effect1.CreateSource(initspeed=3.0, initdirection=2 * math.pi * random.random(), initspeedrandrange=8.0, initdirectionrandrange=2 * math.pi, particlelife=1000, colour=(110, 10, 100), drawtype=PyIgnition.DRAWTYPE_BUBBLE, radius=24.0) source2 = effect2.CreateSource(initspeed=3.0, initdirection=2 * math.pi * random.random(), initspeedrandrange=8.0, initdirectionrandrange=2 * math.pi, particlelife=1000, colour=(110, 10, 100),
import PyIgnition, pygame, sys, math, random, constants from constants import * screen = pygame.display.set_mode((1250, 675)) pygame.display.set_caption("Simulation!!!") clock = pygame.time.Clock() effect1 = PyIgnition.ParticleEffect(screen, (25, 25), (1200, 625)) effect2 = PyIgnition.ParticleEffect(screen, (25, 25), (1200, 625)) effect3 = PyIgnition.ParticleEffect(screen, (25, 25), (1200, 625)) effect4 = PyIgnition.ParticleEffect(screen, (25, 25), (1200, 625)) effect5 = PyIgnition.ParticleEffect(screen, (25, 25), (1200, 625)) effect6 = PyIgnition.ParticleEffect(screen, (25, 25), (1200, 625)) effect7 = PyIgnition.ParticleEffect(screen, (25, 25), (1200, 625)) effect8 = PyIgnition.ParticleEffect(screen, (25, 25), (1200, 625)) effect9 = PyIgnition.ParticleEffect(screen, (25, 25), (1200, 625)) effect10 = PyIgnition.ParticleEffect(screen, (25, 25), (1200, 625)) effect11 = PyIgnition.ParticleEffect(screen, (25, 25), (1200, 625)) effect12 = PyIgnition.ParticleEffect(screen, (25, 25), (1200, 625)) effect13 = PyIgnition.ParticleEffect(screen, (25, 25), (1200, 625)) effect14 = PyIgnition.ParticleEffect(screen, (25, 25), (1200, 625)) effect15 = PyIgnition.ParticleEffect(screen, (25, 25), (1200, 625)) effect16 = PyIgnition.ParticleEffect(screen, (25, 25), (1200, 625)) effect17 = PyIgnition.ParticleEffect(screen, (25, 25), (1200, 625)) effect18 = PyIgnition.ParticleEffect(screen, (25, 25), (1200, 625)) effect19 = PyIgnition.ParticleEffect(screen, (25, 25), (1200, 625)) effect20 = PyIgnition.ParticleEffect(screen, (25, 25), (1200, 625)) effect21 = PyIgnition.ParticleEffect(screen, (25, 25), (1200, 625)) effect22 = PyIgnition.ParticleEffect(screen, (25, 25), (1200, 625)) effect23 = PyIgnition.ParticleEffect(screen, (25, 25), (1200, 625))
# PyIgnition test import PyIgnition, pygame, sys screen = pygame.display.set_mode((800, 600)) pygame.display.set_caption("PyIgnition demo: fire") clock = pygame.time.Clock() fire = PyIgnition.ParticleEffect(screen, (0, 0), (800, 600)) gravity = fire.CreateDirectedGravity(strength=0.07, direction=[0, -1]) wind = fire.CreateDirectedGravity(strength=0.05, direction=[1, 0]) source = fire.CreateSource((300, 500), initspeed=2.0, initdirection=0.0, initspeedrandrange=1.0, initdirectionrandrange=0.5, particlesperframe=10, particlelife=100, drawtype=PyIgnition.DRAWTYPE_CIRCLE, colour=(255, 200, 100), radius=3.0) source.CreateParticleKeyframe(10, colour=(200, 50, 20), radius=4.0) source.CreateParticleKeyframe(30, colour=(150, 0, 0), radius=6.0) source.CreateParticleKeyframe(60, colour=(50, 20, 20), radius=20.0) source.CreateParticleKeyframe(80, colour=(0, 0, 0), radius=50.0) rect = fire.CreateRectangle((400, 100), (200, 100, 100), bounce=0.2, width=100, height=20) rect.CreateKeyframe(frame=500, pos=(400, 250), width=200, height=30) #fire.CreateCircle((350, 200), (200, 100, 100), bounce = 0.2, radius = 25)
def run(width, height, musicFile, file=0): def redrawAllWrapper(screen, data): pygame.display.flip() if data.game == True: redrawAll(screen, data) else: redrawMenu(screen, data) pygame.display.update() def mousePressedWrapper(event, screen, data): if data.game == True: mousePressed(event, data) redrawAllWrapper(screen, data) def keyPressedWrapper(data): if data.game == True: keyPressed(data) else: keyPressedMenu(data) def timerFiredWrapper(data): keyPressedWrapper(data) if data.game == True: if data.isPause == False: timerFired(data) for event in pygame.event.get(): if event.type == pygame.QUIT: data.done = True # pause, then call timerFired again #screen.after(data.timerDelay, timerFiredWrapper, screen, data) # Set up data and call init class Struct(object): pass data = Struct() data.width = width data.height = height data.curframe = 0 data.rtimer = 0 data.ptimer = 0 data.musicFile = musicFile pygame.init() fps = 50 screen = pygame.display.set_mode((data.width, data.height)) data.fire = PyIgnition.ParticleEffect(screen, (0, 0),\ (data.width, data.height)) data.bubbles = PyIgnition.ParticleEffect(screen, (0, 0),\ (data.width, data.height)) if file != 0: with open(file + ".pickle", 'rb') as handle: data.player = pickle.load(handle) else: data.player = Player() init(data) # create the root and the screen data.done = False clock = pygame.time.Clock() while not data.done: clock.tick(fps) data.curframe += 1 if data.game == True: #pygame.time.set_timer(pygame.USEREVENT, 0) data.itimer = pygame.time.get_ticks() // 10 data.timer = data.itimer - data.rtimer - data.ptimer redrawAllWrapper(screen, data) timerFiredWrapper(data) pygame.quit() print("bye!")
# Catherine wheel import PyIgnition, pygame, sys screen = pygame.display.set_mode((600, 600)) pygame.display.set_caption("PyIgnition demo: catherine wheel") clock = pygame.time.Clock() wheel = PyIgnition.ParticleEffect(screen, (0, 0), (600, 600)) flame = wheel.CreateSource((300, 300), initspeed = 20.0, initdirection = 0.0, initspeedrandrange = 0.0, initdirectionrandrange = 0.5, particlesperframe = 3, particlelife = 50, drawtype = PyIgnition.DRAWTYPE_SCALELINE, colour = (255, 200, 200), length = 20.0) sparks = wheel.CreateSource((300, 300), initspeed = 1.0, initdirection = 0.0, initspeedrandrange = 0.9, initdirectionrandrange = 3.141592653, particlesperframe = 1, particlelife = 300, genspacing = 3, drawtype = PyIgnition.DRAWTYPE_IMAGE, imagepath = "particles/Spark.png") wheel.CreateDirectedGravity(strength = 0.05, direction = [0, 1]) velocity = 0.1 maxvelocity = 0.5 acceleration = 0.001 while True: for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() elif event.type == pygame.KEYDOWN: if event.key == pygame.K_s: wheel.SaveToFile("Test.xml") flame.SetInitDirection(flame.initdirection + velocity) if flame.curframe % 30 == 0: flame.ConsolidateKeyframes()
screen = pygame.display.set_mode((800, 600)) pygame.display.set_caption("PyIgnition 'Controlled Eruption' demo") clock = pygame.time.Clock() curframe = 0 started = False # 'Press space to start' text starttextfont = pygame.font.Font("courbd.ttf", 50) starttext = starttextfont.render("Press space to start", True, (255, 255, 255), (0, 0, 0)) starttextpos = ((400 - (starttext.get_width() / 2)), (300 - (starttext.get_height() / 2))) # Background background = PyIgnition.ParticleEffect(screen, (0, 0), (800, 600)) backgroundsource = \ background.CreateSource((10, 10), initspeed=5.0, initdirection=2.35619449, initspeedrandrange=2.0, initdirectionrandrange=1.0, particlesperframe=5, particlelife=125, drawtype=PyIgnition.DRAWTYPE_SCALELINE, colour=(255, 255, 255), length=10.0) backgroundsource.CreateParticleKeyframe(50, colour=(0, 255, 0), length=10.0) backgroundsource.CreateParticleKeyframe(75, colour=(255, 255, 0), length=10.0) backgroundsource.CreateParticleKeyframe(100, colour=(0, 255, 255), length=10.0) backgroundsource.CreateParticleKeyframe(125, colour=(0, 0, 0), length=10.0) backgroundsource2 = \ background.CreateSource((790, 10), initspeed=5.0, initdirection=-2.35619449, initspeedrandrange=2.0, initdirectionrandrange=1.0, particlesperframe=0, particlelife=125, drawtype=PyIgnition.DRAWTYPE_SCALELINE,
import pygame import PyIgnition import sys screen = pygame.display.set_mode((800, 600)) clock = pygame.time.Clock() effect = PyIgnition.ParticleEffect(screen) gravity = effect.CreateVortexGravity(pos=(400, 300), strength=1.0, strengthrandrange=0.0) particles = effect.CreateSource(pos=(0, 0), initspeed=5.0, initdirectionrandrange=0.5, particlesperframe=5, particlelife=200, drawtype=PyIgnition.DRAWTYPE_LINE, length=5.0, radius=5.0) def Draw(): screen.fill((255, 255, 255)) effect.Update() effect.Redraw() pygame.draw.circle(screen, (255, 0, 100), (400, 300), 3) mpos = pygame.mouse.get_pos() # f = gravity.GetForce(mpos) # endpos = [mpos[0] + f[0], mpos[1] + f[1]] # pygame.draw.aaline(screen, (0, 0, 0), mpos, endpos)
pady = 550 ballx = 400 bally = 300 ballx_change = -10 bally_change = -10 ball_width = 30 padx_change = 0 pady_change = 0 pad_width = 267 angle = 1 effect = PyIgnition.ParticleEffect(gamedisplay,(0,0),(display_width,display_height)) source = effect.CreateSource(initspeed = 1.0, initdirection = 0.0, initspeedrandrange = 0.5, initdirectionrandrange = math.pi, particlelife = 1000, colour = (200, 255, 200), drawtype = PyIgnition.DRAWTYPE_BUBBLE, radius = 4.0) effect.CreateDirectedGravity(strength = 0.04, direction = [0, -1]) p = 0 score = 0 needed = 0 wow = pygame.image.load('sprites/wow.png') red = 100 green = 100 blue = 100 padup = 0.00000000001 padupplus = 0.00001