def __init__(self,X, Y, Width, Height, Sprites=None, Delay=-1, MinVelocityX=-100, MaxVelocityX=100, MinVelocityY=-100, MaxVelocityY=100, MinRotation=-360, MaxRotation=360, Gravity=500, Drag=0, Graphics=None, Quantity=0, Multiple=false, Parent=None): FlxCore.__init__(self); self.visible = false; self.x = X; self.y = Y; self.width = Width; self.height = Height; self.minVelocity = FlxPoint(MinVelocityX,MinVelocityY); self.maxVelocity = FlxPoint(MaxVelocityX,MaxVelocityY); self._minRotation = MinRotation; self._maxRotation = MaxRotation; self._gravity = Gravity; self._drag = Drag; self._delay = Delay; self._timer=0 self._particle = 0; if(Graphics != None): self._sprites = FlxArray(); for i in range(Quantity): if(Multiple): (self._sprites.add( FlxSprite(Graphics,0,0,true))).randomFrame(); else: self._sprites.add( FlxSprite(Graphics)); for i in range(len(self._sprites)): if(Parent == None): FlxG.state.add(self._sprites[i]); else: Parent.add(self._sprites[i]); else: self._sprites = Sprites; self.kill(); if(self._delay > 0): self.reset();
def __init__(self,X,Y,Width,Height,TileGraphic,Empties=0): FlxCore.__init__(self); self._tileSize=0; self.x = X; self.y = Y; self.width = Width; self.height = Height; if(TileGraphic == None): print "block None graphic" return; self._pixels = TileGraphic self._rects = FlxArray(); self._p = FlxPoint(); self._tileSize = self._pixels.height; self.widthInTiles = math.ceil(self.width/self._tileSize); self.heightInTiles = math.ceil(self.height/self._tileSize); self.width = self.widthInTiles*self._tileSize; self.height = self.heightInTiles*self._tileSize; self.numTiles = self.widthInTiles*self.heightInTiles; self.numGraphics = self._pixels.get_width()/self._tileSize; for i in range( numTiles): if(math.random()*(numGraphics+Empties) > Empties): self._rects.append(Rect(self._tileSize*Math.floor(Math.random()*self.numGraphics),0,self._tileSize,self._tileSize)); else: self._rects.append(None);
def __init__(self, MapData, TileGraphic, CollisionIndex=1, DrawIndex=1): #image = pyglet.resource.image("data/logo.png") FlxCore.__init__(self) self.CollideIndex = CollisionIndex self.DrawIndex = 1 self._ci = CollisionIndex self.widthInTiles = 0 self.heightInTiles = 0 self._data = FlxArray() #c; #cols:Array; rows = open(MapData).read().split("\n") rows.reverse() rows = rows[2:] self.heightInTiles = len(rows) for r in range(self.heightInTiles): cols = rows[r].split(",") if (len(cols) <= 1): self.heightInTiles -= 1 continue if (self.widthInTiles == 0): self.widthInTiles = len(cols) for c in range(self.widthInTiles): self._data.append(int(cols[c])) self._pixels = TileGraphic self._rects = FlxArray() self._p = FlxPoint() self._tileSize = self._pixels.height self.width = self.widthInTiles * self._tileSize self.height = self.heightInTiles * self._tileSize self.numTiles = self.widthInTiles * self.heightInTiles for i in range(self.numTiles): if (self._data[i] >= DrawIndex): self._rects.append( FlxRect(self._tileSize * self._data[i], 0, self._tileSize, self._tileSize)) else: self._rects.append(None) #self._block = FlxBlock(0,0,self._tileSize,self._tileSize,None); self._screenRows = int(Math.ceil(FlxG.height / self._tileSize) + 1) if (self._screenRows > self.heightInTiles): self._screenRows = self.heightInTiles self._screenCols = int(Math.ceil(FlxG.width / self._tileSize) + 1) if (self._screenCols > self.widthInTiles): self._screenCols = self.widthInTiles self._tileObjects = range(self._pixels.width / self._pixels.height) i = 0 while (i < self._pixels.width / self._pixels.height): collide = FlxCore.NONE if (i >= self.CollideIndex): collide = self.allowCollisions self._tileObjects[i] = FlxTile(self, i, self._tileSize, self._tileSize, (i >= self.DrawIndex), collide) i += 1
def __init__(self,MapData, TileGraphic, CollisionIndex=1, DrawIndex=1): #image = pyglet.resource.image("data/logo.png") FlxCore.__init__(self); self.CollideIndex = CollisionIndex;self.DrawIndex = 1; self._ci = CollisionIndex; self.widthInTiles = 0; self.heightInTiles = 0; self._data = FlxArray(); #c; #cols:Array; rows = open(MapData).read().split("\n"); rows.reverse() rows=rows[2:] self.heightInTiles = len(rows); for r in range(self.heightInTiles): cols = rows[r].split(","); if(len(cols) <= 1): self.heightInTiles-=1; continue; if(self.widthInTiles == 0): self.widthInTiles = len(cols); for c in range(self.widthInTiles): self._data.append(int(cols[c])); self._pixels = TileGraphic self._rects = FlxArray(); self._p = FlxPoint(); self._tileSize =self._pixels.height; self.width = self.widthInTiles*self._tileSize; self.height = self.heightInTiles*self._tileSize; self.numTiles = self.widthInTiles*self.heightInTiles; for i in range(self.numTiles): if(self._data[i] >= DrawIndex): self._rects.append(FlxRect(self._tileSize*self._data[i],0,self._tileSize,self._tileSize)); else: self._rects.append(None); #self._block = FlxBlock(0,0,self._tileSize,self._tileSize,None); self._screenRows =int( Math.ceil(FlxG.height/self._tileSize)+1); if(self._screenRows > self.heightInTiles): self._screenRows = self.heightInTiles; self._screenCols = int(Math.ceil(FlxG.width/self._tileSize)+1); if(self._screenCols > self.widthInTiles): self._screenCols = self.widthInTiles; self._tileObjects = range(self._pixels.width/self._pixels.height) i=0 while(i < self._pixels.width/self._pixels.height): collide=FlxCore.NONE if(i>= self.CollideIndex): collide=self.allowCollisions self._tileObjects[i] =FlxTile(self,i,self._tileSize,self._tileSize,(i >= self.DrawIndex),collide) i+=1;
def __init__(self, X, Y, Width, Height, Sprites=None, Delay=-1, MinVelocityX=-100, MaxVelocityX=100, MinVelocityY=-100, MaxVelocityY=100, MinRotation=-360, MaxRotation=360, Gravity=500, Drag=0, Graphics=None, Quantity=0, Multiple=false, Parent=None): FlxCore.__init__(self) self.visible = false self.x = X self.y = Y self.width = Width self.height = Height self.minVelocity = FlxPoint(MinVelocityX, MinVelocityY) self.maxVelocity = FlxPoint(MaxVelocityX, MaxVelocityY) self._minRotation = MinRotation self._maxRotation = MaxRotation self._gravity = Gravity self._drag = Drag self._delay = Delay self._timer = 0 self._particle = 0 if (Graphics != None): self._sprites = FlxArray() for i in range(Quantity): if (Multiple): (self._sprites.add(FlxSprite(Graphics, 0, 0, true))).randomFrame() else: self._sprites.add(FlxSprite(Graphics)) for i in range(len(self._sprites)): if (Parent == None): FlxG.state.add(self._sprites[i]) else: Parent.add(self._sprites[i]) else: self._sprites = Sprites self.kill() if (self._delay > 0): self.reset()
def __init__(self, Tilemap, Index, Width, Height, Visible, AllowCollisions): FlxCore.__init__(self) #,0, 0, Width, Height); # # /** # # * This function is called whenever an object hits a tile of this type. # # * This function should take the form <code>myFunction(Tile:FlxTile,Object:FlxObject):void</code>. # # * Defaults to null, set through <code>FlxTilemap.setTileProperties()</code>. # # */ # self.callback=None; # # /** # # * Each tile can store its own filter class for their callback functions. # # * That is, the callback will only be triggered if an object with a class # # * type matching the filter touched it. # # * Defaults to null, set through <code>FlxTilemap.setTileProperties()</code>. # # */ # self.filter=None; # # /** # # * A reference to the tilemap this tile object belongs to. # # */ # public var tilemap:FlxTilemap; # /** # * The index of this tile type in the core map data. # * For example, if your map only has 16 kinds of tiles in it, # * this number is usually between 0 and 15. # */ # public var index:uint; # /** # * The current map index of this tile object at this moment. # * You can think of tile objects as moving around the tilemap helping with collisions. # * This value is only reliable and useful if used from the callback function. # */ # public var mapIndex:uint; self.immovable = true self.moves = false self.callback = None self.filter = None self.width = Width self.height = Height self.tilemap = Tilemap self.index = Index self.visible = Visible self.allowCollisions = AllowCollisions self.velocity = FlxPoint() self.mapIndex = 0
def __init__(self,Tilemap, Index, Width, Height, Visible, AllowCollisions): FlxCore.__init__(self)#,0, 0, Width, Height); # # /** # # * This function is called whenever an object hits a tile of this type. # # * This function should take the form <code>myFunction(Tile:FlxTile,Object:FlxObject):void</code>. # # * Defaults to null, set through <code>FlxTilemap.setTileProperties()</code>. # # */ # self.callback=None; # # /** # # * Each tile can store its own filter class for their callback functions. # # * That is, the callback will only be triggered if an object with a class # # * type matching the filter touched it. # # * Defaults to null, set through <code>FlxTilemap.setTileProperties()</code>. # # */ # self.filter=None; # # /** # # * A reference to the tilemap this tile object belongs to. # # */ # public var tilemap:FlxTilemap; # /** # * The index of this tile type in the core map data. # * For example, if your map only has 16 kinds of tiles in it, # * this number is usually between 0 and 15. # */ # public var index:uint; # /** # * The current map index of this tile object at this moment. # * You can think of tile objects as moving around the tilemap helping with collisions. # * This value is only reliable and useful if used from the callback function. # */ # public var mapIndex:uint; self.immovable = true; self.moves = false; self.callback = None; self.filter = None; self.width=Width self.height=Height self.tilemap = Tilemap; self.index = Index; self.visible = Visible; self.allowCollisions = AllowCollisions; self.velocity = FlxPoint(); self.mapIndex = 0;
def __init__(self): FlxCore.__init__(self) self._children = FlxArray()
def __init__(self): FlxCore.__init__(self) self._children = FlxArray();
def __init__(self,Graphic=None,X=0,Y=0,Animated=false,Reverse=false,Width=0,Height=0,Color=0): if(Graphic != None): #image = pyglet.resource.image(Graphic) self.pixels = Graphic; pass else: self.pixels= pygame.image.load("data/logo.png") #pixels = FlxG.createBitmap(Width,Height,Color); FlxCore.__init__(self) #self.position=(X,FlxG.height-Y); #self.anchor=(0,0) #print dir(self.pixels) self.x = X; self.y = Y; if(Width == 0): if(Animated): Width = self.pixels.height; else: Width = self.pixels.width; self.width =Width self._bw = Width; self.height = self.pixels.height; self._bh = self.height; self.offset = FlxPoint(); self.velocity = FlxPoint(); self.acceleration = FlxPoint(); self.drag = FlxPoint(); self.maxVelocity = FlxPoint(10000,10000); self.angle = 0; self.angularVelocity = 0; self.angularAacceleration = 0; self.angularDrag = 0; self.maxAngular = 10000; self.thrust = 0; self.scale = FlxPoint(1,1); self.finished = false; self._facing = true; self._animations = FlxArray(); if(Reverse): #pass self._flipped = self.pixels.width>>1; else: self._flipped = 0; self._curAnim = None; self._curFrame = 0; self._frameTimer = 0; self._p = FlxPoint(self.x,self.y); self._pZero = FlxPoint(); self._r = FlxRect(0,0,self._bw,self._bh); #self._pixels = BitmapData(width,height); #print self._bw,self._bh #raw_input() self._pixels=self.pixels.get_region(0,0,self._bw,self._bh)#,self._pZero); self.health = 1; self._alpha = 1; self._callback = None;
def __init__(self,X, Y, Text="", Color=0xffffffff, Font=None, Size=18, Justification=None, Angle=0): pyglet.text.Label.__init__(self,Text,font_name=Font,font_size=Size,x=X,y=Y) FlxCore.__init__(self); self.x=X self.y=Y