def __init__(self, parent=None): QGraphicsPixmapItem.__init__(self, parent) self.x = 41 self.y = 100 self.vel_x = 0 self.vel_y = 0 self.counter = 0 #dir 0: oikealle, dir 1: vasemmalle self.dir = 0 self.score = 0 #animaatio self.animations_right = [ QPixmap("static/kario2_right.png"), QPixmap("static/kario3_right.png"), QPixmap("static/kario2_right.png"), QPixmap("static/kario5_right.png") ] self.animations_left = [ QPixmap("static/kario2_left.png"), QPixmap("static/kario3_left.png"), QPixmap("static/kario2_left.png"), QPixmap("static/kario5_left.png") ] self.setPixmap(QPixmap("static/kario1_right.png")) self.setPos(self.x, self.y) self.lift = -17 self.can_jump = False self.points = 0 self.alive = True self.win = False
def __init__(self, pixmap, c_width, c_height): QGraphicsPixmapItem.__init__(self, None) self.c_width = c_width # Container width self.c_height = c_height # Container height self.setPixmap(pixmap) # The pixmap self.setFlag(QGraphicsItem.ItemIsMovable) # Make it movable self.pixmap = self.pixmap() # just call it once
def __init__(self, offset_x, offset_y, parent=None): QGraphicsPixmapItem.__init__(self, parent) self.setPixmap(QPixmap("laserBlue07_sm.png")) self.offset_x = offset_x self.offset_y = offset_y self.active = False self.frames = 0
def __init__(self, power, color, bot): QGraphicsPixmapItem.__init__(self) # graphics self.maskColor = QColor(255, 128, 0) # 用Qt的QColor方法设置颜色 self.pixmap = QPixmap( os.getcwd() + "/robotImages/blast.png") # 用Qt的QPixmap方法。设置炮弹的图片 self.setPixmap(self.pixmap) # QGraphicsPixmapItem中的方法 self.setColour(color) # 下边的自定义函数 self.isfired = False # physics self.width = self.boundingRect().width() self.height = self.boundingRect().height() if power <= 0.5: power = 0.5 elif power >= 10: power = 10 self.power = power bsize = power if power < 3: bsize = 4 self.pixmap = self.pixmap.scaled(bsize, bsize) self.setPixmap(self.pixmap) # QGraphicsPixmapItem中的方法 self.robot = bot
def __init__(self, scr_w, scr_h, parent=None): QGraphicsPixmapItem.__init__(self, parent) self.setPixmap(QPixmap("Images/DurrrSpaceShip_50.png")) self.scr_w = scr_w self.scr_h = scr_h self.setPos((self.scr_w - self.pixmap().width()) / 2, self.scr_h - self.pixmap().height() - 10)
def __init__(self, parent=None): QGraphicsPixmapItem.__init__(self, parent) enemy = random.randint(0, 3) self.setPixmap(QPixmap(self.enemyArray[enemy])) self.spone = False self.frames = 0 self.IS_DEAD = False self.check = 0
def __init__(self, offset_x, offset_y, parent=None): QGraphicsPixmapItem.__init__(self, parent) self.setPixmap(QPixmap("Images/player1Laser.png")) self.offset_x = offset_x self.offset_y = offset_y self.active = False self.speed = 10 self.frames = 55 self.framesPassed = 0
def __init__(self, offset_x, offset_y, scr_w, scr_h, parent=None): QGraphicsPixmapItem.__init__(self, parent) self.setPixmap(QPixmap("Images/bolt1.png")) self.offset_x = offset_x self.offset_y = offset_y self.scr_w = scr_w self.scr_h = scr_h self.active = False self.frames = 0
def __init__(self, offset_x, offset_y, parent=None): QGraphicsPixmapItem.__init__(self, parent) self.setPixmap(QPixmap(path + 'PNG/Lasers/laserBlue07.png')) # bullet이미지 할당. self.offset_x = offset_x self.offset_y = offset_y # bullet 좌표 설정. self.active = False self.frames = 0
def __init__(self, viewpoint_name): QGraphicsPixmapItem.__init__(self, QPixmap(tower_pixmap), parent=None) rect = self.boundingRect() self.setScale(tower_width / rect.width()) self.setOffset(-rect.width() / 2, -rect.height()) vp_item = QGraphicsRectItem(-rect.width() / 2, -rect.width(), rect.width(), rect.width()) item = MouseOverLabelledItem(vp_item, 'viewpoint', None) item.setMouseOverText(viewpoint_name) item.setParentItem(self)
def __init__(self, x, y, parent=None): QGraphicsPixmapItem.__init__(self, parent) self.x = x self.y = y self.setPixmap(QPixmap("static/price.png")) self.setPos(self.x, self.y) self.available = True self.deleted = False
def __init__(self, x, y, parent=None): QGraphicsPixmapItem.__init__(self, parent) self.setPixmap(QPixmap("Images/enemy.png")) self.setPos(x, y) self.active = False self.frames = 0 self.chosen = False self.powerUp = False self.collapseSpeed = 2 self.collapseFrames = 350
def __init__(self, x, y, color="2", parent=None): QGraphicsPixmapItem.__init__(self, parent) self.setPixmap(QPixmap("Images/bolt" + color + ".png")) self.frames = 0 self.x = x - ENEMY_BULLET_X_OFFSET self.y = y self.setVisible(True) self.active = True self.setPos(self.x, self.y) self.frames = 180 # enemy_bullet_frames self.bullet_speed = 4
def __init__(self, pixmap, name, *args, **kwargs): self.filename = name QGraphicsPixmapItem.__init__(self, pixmap, *args, **kwargs) self.setFlags(QGraphicsItem.ItemIsMovable | QGraphicsItem.ItemIsSelectable | QGraphicsItem.ItemSendsGeometryChanges | QGraphicsItem.ItemSendsScenePositionChanges) self.w = self.pixmap().width() self.h = self.pixmap().height()
def __init__(self, icon_type, icon_name, parent): QGraphicsPixmapItem.__init__(self) self.setParentItem(parent) self.p_size = QRectF(0.0, 0.0, 24.0, 24.0) self.icon = None self.x_offset = 4 self.y_offset = 4 if icon_type in (ICON_CLIENT, ICON_APPLICATION): self.setIcon(icon_type, icon_name)
def __init__(self, type, pos, width, height, drawing_priority, solid=True): QGraphicsPixmapItem.__init__(self) self.setTransformOriginPoint(QPoint(width / 2, height / 2)) self.setPixmap(QPixmap('Sprites/' + type + '.png')) self.setZValue(drawing_priority) self.setPos(pos) self.rect = QRectF(pos.x(), pos.y(), width, height) self.type = type self.solid = solid self.isBroken = False
def __init__(self, src, title, pixmap, NW_coords, SE_coords): QGraphicsPixmapItem.__init__(self, pixmap, None) self.source_file = src self.title = title rect = self.boundingRect() nw = NW_coords.toQPointF() se = SE_coords.toQPointF() scale = QTransform.fromScale((se.x() - nw.x()) / rect.width(), (se.y() - nw.y()) / rect.height()) self.setTransform(scale) self.setPos(nw) self.setVisible(False)
def __init__(self, start_x, start_y, parent=None): QGraphicsPixmapItem.__init__(self, parent) self.x = start_x self.y = start_y self.vel_y = 0 self.vel_x = 0 self.setPixmap(QPixmap("static/enemy_left.png")) self.setPos(self.x, self.y) self.can_move = True self.alive = True self.deleted = False
def __init__(self, parent=None): QGraphicsPixmapItem.__init__(self, parent) self.setPixmap(QPixmap("frame-111.png")) self.jumping = 0 self.can_jump = True self.won = False self.loss = False self.map = Map() self.won_count = 50 self.draw_won = 100 self.loss_count = 2 self.draw_loss = 100
def __init__(self, x, y, parent = None): QGraphicsPixmapItem.__init__(self, parent) self.x = x self.y = y self.counter = 0 self.victory = False self.animation = [QPixmap("static/flag1"), QPixmap("static/flag2"), QPixmap("static/flag3"), QPixmap("static/flag4"), QPixmap("static/flag5"), QPixmap("static/flag6"), QPixmap("static/flag7")] self.setPixmap(self.animation[0]) self.setPos(self.x, self.y)
def __init__(self, path, size, parent=None): QGraphicsPixmapItem.__init__(self, parent) self._path = path self._loaded = False self._text = QGraphicsTextItem(self) self._text.setFont(QFont("Arial", 14)) self._text.setPlainText(os.path.basename(path)) self._text.setPos(0, size.height()) self.setShapeMode(QGraphicsPixmapItem.BoundingRectShape) self.setFlags(self.flags() | QGraphicsItem.ItemIsSelectable ) # | QtGui.QGraphicsItem.ItemIsMovable )
def __init__(self, x, y, parent=None): QGraphicsPixmapItem.__init__(self, parent) # load image frames explosion_grid = QImage("Images/explosion_16x64x64.png") self.explosion_pics = [] for col in range(0, 4): for row in range(0, 4): self.explosion_pics.append( QPixmap.fromImage( explosion_grid.copy(row * 64, col * 64, 64, 64))) self.counter = 0.1 self.setPixmap(self.explosion_pics[int(self.counter)]) self.x = x self.y = y self.setPos(x, y) self.frames = 0
def __init__(self, scene, pos, angle, initial_speed): QGraphicsPixmapItem.__init__(self) self.setPos(pos) self.setRotation(angle) self.speed = self.basic_speed + initial_speed self.setPixmap( QPixmap( self.bullet_pict_path)) self.setOffset( - self.boundingRect().width() / 2, - self.boundingRect().height() / 2) self.setScale(0.025) self.cycles_of_explosion = 5 self.exploded = False self.setVisible(True) print( "bullet pos_x = " + str(pos.x()) + "pos_y = " + str(pos.y()) + " angle = " + str(angle))
def __init__(self, parent=None): QGraphicsPixmapItem.__init__(self, parent) self.setPixmap(QPixmap("f_stand.png")) self.setScale(0.25) self.keys_pressed = set() self.width = self.sceneBoundingRect().width() # 50 self.height = self.sceneBoundingRect().height() # 57 self.standing = False # 땅에 서있는가 서있지 않는가 self.jumped = False # 점프를 했는가 안했는가 self.foot_y = 0 self.excel_horizontal = 0 # 수평 방향 가속도. self.excel_vertical = 0 # 수직 방향 가속도. self.jump_excel = JUMP_EXCEL_DEFAULT # 점프력 설정. 전역 변수 JUMP_EXCEL_DEFAULT를 받아옴. self.animate_num = 0 # 캐릭터가 움직이는 것 처럼 보이게 하기위한 캐릭터 칩의 번호. self.last_chip_num = 5 # 한 캐릭터가 가진 캐릭터 칩의 마지막 번호(0~5번까지임) self.y_before_jump = 0 # 점프 전 y좌표 저장
def __init__(self, pic, x, y, animeGeomOn, animeOpacOn, parent): """ 初始化 :param pic: QPixmap :param x: :param y: :param animeGeomOn: bool :param animeOpacOn: bool :param parent: """ QGraphicsPixmapItem.__init__(pic, parent) # 改变几何中心, 默认在重心 self.sizePixmapOrig.setWidth(pic.width()) self.sizePixmapOrig.setHeight(pic.height()) self.setTransformOriginPoint(pic.width() * 0.5, pic.height() * 0.5) self.setPos(x, y) self.setOpacity(1) self.setScale(1) self.show() self.enableAnime(animeGeomOn, animeOpacOn)
def __init__(self, x, y, player_x, player_y, parent=None): QGraphicsPixmapItem.__init__(self, parent) self.setPixmap(QPixmap("Images/bolt4.png")) self.frames = 0 self.bullet_speed = 3.5 self.x = x - ENEMY_BULLET_X_OFFSET self.y = y self.dx = 0 x_diff = self.x - player_x if x_diff >= -30 and x_diff <= 50: self.dx = random.randint(0, 5) - 3 if x_diff < -30: self.dx = random.randint(0, 5) if x_diff > 50: self.dx = random.randint(0, 5) * -1 if self.y > player_y: self.bullet_speed = -3.5 self.setVisible(True) self.active = True self.setPos(self.x, self.y) self.frames = 180 # enemy_bullet_frames
def __init__(self, x, y, val, parent = None): QGraphicsPixmapItem.__init__(self, parent) self.x = x self.y = y if val == 1: self.setPixmap(QPixmap("static/ground.png")) self.setPos(self.x, self.y) elif val == 2: self.setPixmap(QPixmap("static/water.png")) self.setPos(self.x, self.y) elif val == 3: self.setPixmap(QPixmap("static/box.png")) self.setPos(self.x, self.y) elif val == 4: self.setPixmap(QPixmap("static/tube_top.png")) self.setPos(self.x-5, self.y) elif val == 5: self.setPixmap(QPixmap("static/tube.png")) self.setPos(self.x, self.y) elif val == 6: self.setPixmap(QPixmap("static/tile1.png")) self.setPos(self.x, self.y)
def __init__(self, ax, ay): QGraphicsPixmapItem.__init__(self) self.setPixmap(QPixmap("zone_dead.png")) self.setPos(ax, ay) self.setScale(0.15)
def __init__(self): QGraphicsPixmapItem.__init__(self) self.setPixmap(QPixmap("f_door_0.png")) self.setScale(0.2) self.opened = False
def __init__(self, scr_w, scr_h, parent=None): QGraphicsPixmapItem.__init__(self, parent) self.pen = QPen(Qt.blue, 3, Qt.SolidLine) self.scr_w = scr_w self.scr_h = scr_h self.pic = [] self.counter = 0 self.dx = 1.2 direction = random.randint(0, 1) if direction == 0: self.dx = -1 * self.dx self.dy = 0 self.hp = 1 self.score = 60 self.active = True self.effect = False self.effect_pic_set = False self.name = "default" self.frames = 900 # for ring protection and other? x = -40 if self.dx < 0: x = self.scr_w + 40 i = random.randint(0, 3) if i == 0: self.name = "flare" self.hp = 1 self.score = 60 self.pic.append(QPixmap("Images/Spybot/1.png")) self.pic.append(QPixmap("Images/Spybot/2.png")) self.pic.append(QPixmap("Images/Spybot/3.png")) self.pic.append(QPixmap("Images/Spybot/3.png")) self.pic.append(QPixmap("Images/Spybot/2.png")) self.pic.append(QPixmap("Images/Spybot/1.png")) if i == 1: self.name = "shield" self.hp = 1 self.score = 60 self.pic.append(QPixmap("Images/Spybot/10.png")) if i == 2: self.name = "slowed" self.hp = 1 self.score = 60 self.pic.append( QPixmap("Images/PunkRobot/punkrobot0.png").scaled( 30, 30, Qt.KeepAspectRatio, Qt.FastTransformation)) self.pic.append( QPixmap("Images/PunkRobot/punkrobot1.png").scaled( 30, 30, Qt.KeepAspectRatio, Qt.FastTransformation)) if i == 3: self.name = "Alien transport" self.hp = 1 self.score = 0 self.pic.append(QPixmap("Images/UFO2a.png")) self.pic.append(QPixmap("Images/UFO2b.png")) self.pic.append(QPixmap("Images/UFO2c.png")) self.setPixmap(self.pic[0]) #x = -50 # random.randint(10, self.scr_w - self.pixmap().width()) y = random.randint(60, 250) self.setPos(x, y) # flare self.flare = QPixmap("Images/flare_1.png") self.flareoffsets = [self.flare.width() / 2, self.flare.height() / 2] self.flarereducer = 0.9 # percent reduction per frame of original pixmap self.flarereduction = 100 # percentage of original pixmap self.shield0 = QPixmap("Images/ring0.png").scaled( 100, 100, Qt.KeepAspectRatio, Qt.FastTransformation) self.shield1 = QPixmap("Images/ring1.png").scaled( 100, 100, Qt.KeepAspectRatio, Qt.FastTransformation) self.shield2 = QPixmap("Images/ring2.png").scaled( 100, 100, Qt.KeepAspectRatio, Qt.FastTransformation) self.slowed = [] for i in range(1, 10): self.slowed.append(QPixmap("Images/slowed/slow" + str(i) + ".png")) for i in range(9, 0, -1): self.slowed.append(QPixmap("Images/slowed/slow" + str(i) + ".png"))
def __init__(self, scr_w, scr_h, en_type=-1, en_x=-1, en_y=-1, parent=None): QGraphicsPixmapItem.__init__(self, parent) entype = en_type if entype == -1: entype = random.randint(0, 100) self.pic = [] self.counter = 0 self.dx = 0.4 self.dy = 0.3 self.hp = 1 self.score = 10 self.name = "" self.scr_w = scr_w self.scr_h = scr_h y = en_y if y < 0: y = random.randint(-100, 0) if entype < 30: self.dy = 0.15 + random.randint(0, 4) / 20 self.dx = 0.35 + random.randint(0, 8) / 10 self.name = "Dangly tentacles" self.hp = 2 self.score = 20 self.pic.append( QPixmap("Images/Spaceships-Drakir2/Spaceship-Drakir1.png")) self.pic.append( QPixmap("Images/Spaceships-Drakir2/Spaceship-Drakir2.png")) if entype >= 30 and entype < 55: self.name = "Lots a tentacles" self.dy = 0.15 self.dx = 1.9 + random.randint(0, 4) / 10 self.hp = 2 self.score = 20 self.pic.append( QPixmap("Images/Spaceships-Drakir2/Spaceship-Drakir5.png")) self.pic.append( QPixmap("Images/Spaceships-Drakir2/Spaceship-Drakir7a.png")) if entype >= 55 and entype < 60: self.name = "Big mother" self.hp = 3 self.dy = 0.19 self.dx = 1 self.pic.append( QPixmap("Images/Spaceships-Drakir2/Spaceship-Drakir4.png")) self.pic.append( QPixmap("Images/Spaceships-Drakir2/Spaceship-Drakir3.png")) self.pic.append( QPixmap("Images/Spaceships-Drakir2/Spaceship-Drakir5.png")) self.pic.append( QPixmap("Images/Spaceships-Drakir2/Spaceship-Drakir3.png")) self.score = 30 if entype >= 60 and entype < 90: self.name = "Space mine" self.dx = 1 + random.randint(0, 6) / 10 self.dy = 0.45 self.pic.append( QPixmap("Images/Spaceships-Drakir2/Spaceship-Drakir6.png")) self.pic.append( QPixmap("Images/Spaceships-Drakir2/Spaceship-Drakir6a.png")) if entype >= 90: self.score = 50 self.name = "Mother UFO" y = -80 self.dx = 0.9 + random.randint(0, 4) / 10 self.dy = 0.2 self.hp = 5 self.pic.append(QPixmap("Images/UFO1c.png")) self.pic.append(QPixmap("Images/UFO1d.png")) self.setPixmap(self.pic[0]) # randomise dx direction d = random.randint(0, 1) if d == 0: self.dx = -1 * self.dx x = en_x if x < 0: x = random.randint(10, self.scr_w - self.pixmap().width() - 10) self.setPos(x, y)