當前位置: 首頁>>代碼示例>>Python>>正文


Python Img.sndget方法代碼示例

本文整理匯總了Python中Img.sndget方法的典型用法代碼示例。如果您正苦於以下問題:Python Img.sndget方法的具體用法?Python Img.sndget怎麽用?Python Img.sndget使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Img的用法示例。


在下文中一共展示了Img.sndget方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: Tool

# 需要導入模塊: import Img [as 別名]
# 或者: from Img import sndget [as 別名]
'''
Created on 24 Jun 2015

@author: NoNotCar
'''
import Img
import pygame

destsound=Img.sndget("explode.wav")
class Tool(object):
    img=Img.blank32
    def use(self,x,y,world,p):
        pass
class Axe(Tool):
    img=Img.imgret2("Axe.png")
    def use(self,x,y,world,p):
        if world.get_obj(x,y):
            return world.get_obj(x,y).cut(world)
class Wrench(Tool):
    img=Img.imgret2("Wrench.png")
    def use(self,x,y,world,p):
        kmods=pygame.key.get_mods()
        if world.get_obj(x,y):
            if kmods & pygame.KMOD_LSHIFT:
                world.get_obj(x,y).rotate()
                return True
            elif kmods & pygame.KMOD_LCTRL:
                world.get_obj(x,y).wrench(world)
                return True
            elif world.get_obj(x,y).is_owner(p):
                world.dest_obj(x,y)
開發者ID:Nouranium,項目名稱:Monolith,代碼行數:33,代碼來源:Tools.py

示例2: GhostSpawner

# 需要導入模塊: import Img [as 別名]
# 或者: from Img import sndget [as 別名]
        return self.eimgs[self.timer//3%2]
class GhostSpawner(Object):
    img=Img.imgsz("GhostSpawn",(32,40))
    time=60
    def update(self,world):
        if not self.time:
            dirs=[[1,0],[0,1],[-1,0],[0,-1]]
            shuffle(dirs)
            for dx,dy in dirs:
                if world.is_clear(self.x+dx,self.y+dy):
                    world.e.append(Entities.Ghost(self.x+dx,self.y+dy))
                    break
            self.time=randint(120,360)
        else:
            self.time-=1
shot=Img.sndget("Gun")
class CannonBlock(Object):
    destructible = False
    img=Img.img2("CannonBlock")
    def __init__(self,x,y):
        self.x=x
        self.y=y
        self.time=randint(60,120)
    def update(self,world):
        if not self.time:
            p=world.get_p(self.x,self.y)
            if p.x<self.x:
                world.e.append(Entities.CannonBall(self.x,self.y,-1))
                shot.play()
            elif p.x>self.x:
                world.e.append(Entities.CannonBall(self.x,self.y,1))
開發者ID:NoNotCar,項目名稱:BombAdventures,代碼行數:33,代碼來源:Object.py

示例3: MechCategory

# 需要導入模塊: import Img [as 別名]
# 或者: from Img import sndget [as 別名]
import Forestry
import Vehicles
import Img
import Power
import UM
import Robotics
import Crafting

pygame.init()
loc = os.path.dirname(os.getcwd()) + "/Assets/"
imgconv = "u", "l", "", "r"
colinpl = (255, 0, 0), (0, 255, 0), (0, 0, 255), (0, 255, 255), (255, 0, 255), (255, 255, 0), (0, 0, 0), (255, 255, 255)
hdirconv = {(0, -1): 0, (-1, 0): 1, (0, 1): 2, (1, 0): 3}
ps2map = [2, 1, 5, 6, 7, 0, 4, 9]
xboxmap = [0, 1, 2]
picksound = Img.sndget("Randomize2.wav")
sellsound = Img.sndget("Pickup_Coin.wav")


class MechCategory(object):
    img = Img.imgret2("Gear.png")
    iscat = True
    doc = "Tech stuff"

    def __init__(self):
        self.menu = [Buyers.CRotObjBuyer(Mech.SlowConv), Buyers.RotObjBuyer(Mech.Conv, 100),
                     Buyers.RotObjBuyer(Mech.RainConv, 1000),
                     Buyers.RotObjBuyer(Mech.DownTunnel, 200), Buyers.RotObjBuyer(Mech.DownTunnelL, 1000),
                     Buyers.RotObjBuyer(Mech.UpTunnel, 500),
                     Buyers.RotObjBuyer(Mech.Output, 100), Buyers.RotObjBuyer(Mech.Output2, 200),
                     Buyers.ObjBuyer(Mech.Input, 100), Buyers.RotObjBuyer(Mech.IOput, 300),
開發者ID:NoNotCar,項目名稱:monolith,代碼行數:33,代碼來源:Players.py

示例4: World

# 需要導入模塊: import Img [as 別名]
# 或者: from Img import sndget [as 別名]
import Pipe
import PipeGen
import Img
import pygame
import sys
import Direction as D
import random
pfill=Img.sndget("fill")
bfill=Img.sndget("bonus")
exp=Img.sndget("explode")
bexp=Img.sndget("bigexp")
success=Img.sndget("win")
build=Img.sndget("build")
alarm=Img.sndget("alarm")
pdf=pygame.font.get_default_font()
tfont=pygame.font.Font(pdf,32)
bfont=pygame.font.Font(pdf,64)
floors=[[Img.img32("Floor"),Img.img32("FloorFixed")],[Img.img32("EFloor"),Img.img32("EFloorFixed")]]
tt=Img.img("TileTab")
sel=Img.img32("Sel")
editorclasses=[Pipe.Source,Pipe.Drain,Pipe.Block,Pipe.GoldPipe,Pipe.SPipe,Pipe.BPipe,Pipe.XPipe,Pipe.X2Pipe,Pipe.OWPipe,
               Pipe.Resevoir,Pipe.TeleportB,Pipe.TeleportO,Pipe.OPipe]
class World(object):
    size=(13,13)
    score=0
    ttgo=3660
    ttflow=0
    fx=0
    fy=0
    nd=(0,1)
    done=False
開發者ID:NoNotCar,項目名稱:OpenPipes,代碼行數:33,代碼來源:World.py

示例5: bombattack

# 需要導入模塊: import Img [as 別名]
# 或者: from Img import sndget [as 別名]
from Entities import *
import FX
import Img
import Object
missile=Img.sndget("Expmiss")
laugh=Img.sndget("bosslaugh")
tp=Img.sndget("teleport")
def bombattack(world,ssize):
    while True:
        tx=randint(9-ssize,9+ssize)
        ty=randint(9-ssize,9+ssize)
        if world.is_clear(tx,ty):
            bomb=Bomb(tx,ty,2)
            bomb.timer=60
            world.e.append(bomb)
            break
def missileattack(world,ssize):
    while True:
        tx=randint(9-ssize,9+ssize)
        ty=randint(9-ssize,9+ssize)
        if world.is_clear(tx,ty):
            m=FX.Missile(tx*32,-48-(19-ty)*32,ty*32)
            world.fx.append(m)
            world.fx.append(FX.MissileTarget(tx*32,ty*32,m))
            missile.play()
            break
class BGhost(Ghost):
    imgs = imgstrip("BossGhost1")
    aimgs = imgstrip("BossGhost2")
    img = imgs[0]
    hp = 5
開發者ID:NoNotCar,項目名稱:BombAdventures,代碼行數:33,代碼來源:Bosses.py

示例6: World

# 需要導入模塊: import Img [as 別名]
# 或者: from Img import sndget [as 別名]
__author__ = 'NoNotCar'
import Img, Entities, Tiles, Object, FX, pygame
from random import randint
import BattlePlayers

powerup = Img.sndget("powerup")
exp = Img.sndget("explode")


class World(object):
    pconv=[BattlePlayers.Player,BattlePlayers.FatPlayer,BattlePlayers.SmallPlayer,BattlePlayers.ThinPlayer,BattlePlayers.CrazyPlayer]
    rtime=0
    rumbling=0
    def __init__(self, level, players,controllers):
        self.done = False
        self.level = level
        self.exitcode="NORMAL"
        self.e = []
        self.ps=[]
        savfile = open(Img.np("lvls//battle//"+level), "r")
        self.t = []
        self.o = []
        self.fx = []
        self.bfx = []
        pn=0
        savr = savfile.readlines()
        for row in savr[:20]:
            self.t.append([int(s) for s in row.split()])
        for x, row in enumerate(savr[20:]):
            self.o.append([None] * 20)
            crow = [int(s) for s in row.split()]
開發者ID:NoNotCar,項目名稱:BombAdventures,代碼行數:33,代碼來源:BattleWorld.py

示例7: SquishyThing

# 需要導入模塊: import Img [as 別名]
# 或者: from Img import sndget [as 別名]
'''
Created on 26 Aug 2015

@author: Thomas
'''
import Entity
import Img
sqsnd=Img.sndget("squish")
class SquishyThing(Entity.Entity):
    dire="L"
    img=Img.img2("Squishy")
    fimg=Img.hflip(img)
    solid=True
    s="Sq"
    def get_img(self,world):
        return self.img if self.dire=="L" else self.fimg
    def update(self, world, events):
        if not self.move(0, 1, world):
            dx=1 if self.dire=="R" else -1
            if not self.move(dx, 0, world):
                self.dire="L" if self.dire=="R" else "R"
    def squish(self, player, world):
        world.dest_obj(self)
        sqsnd.play()
class SquishyClever(SquishyThing):
    img=Img.img2("SquishyGreen")
    fimg=Img.hflip(img)
    s="SqC"
    def update(self, world, events):
        if not self.move(0, 1, world):
            dx=1 if self.dire=="R" else -1
開發者ID:NoNotCar,項目名稱:jump,代碼行數:33,代碼來源:Enemies.py

示例8: makenoise

# 需要導入模塊: import Img [as 別名]
# 或者: from Img import sndget [as 別名]
from math import ceil
bnoise=None
bnoise2=None
tnoise=None
def makenoise():
    global bnoise,bnoise2
    bnoise=perlin.SimplexNoise(256)
    bnoise2=perlin.SimplexNoise(256)
    global tnoise
    tnoise=perlin.SimplexNoise(256)
cashfont=Img.fload("cool",32)
bscale=128.0
b2scale=160.0
bcfont=Img.fload("cool",64)
threshold=1.2
exp=Img.sndget("bomb")
def ir(n):
    return int(round(n))
numerals=Img.imgstripxf("Numbers",5)+[Img.imgx("Ten")]
scales=[16,32,48,64]
class World(object):
    is_done=False
    winner=None
    invscale=3
    wscale=2
    def __init__(self,ps):
        hs=HomeSector(self,0,0,ps)
        self.ps=ps
        self.w={(0,0):hs}
    def update(self,events):
        for s in [s for s in self.w.itervalues()]:
開發者ID:NoNotCar,項目名稱:TrapDungeon,代碼行數:33,代碼來源:World.py


注:本文中的Img.sndget方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。