def __init__(self, xPosition, yPosition): self.input = objects.Input() self.damage = 0 self.xVelocity = 0 self.yVelocity = 0 self.xFriction = 1.75 self.acceleration = 1.2 self.direction = 1 self.jumpCounter = 0 self.aerialAttacked = 0 self.aerialSpecialed = 0 self.isSmashing = False self.isGrounded = False self.isGrabbing = False self.canMove = True self.canGrab = True self.canAttack = True self.groundedPlatform = None self.startedCharge = False self.smashing = False self.attacking = False self.special = False self.aerial = False self.forward = False self.backward = False self.upward = False self.downward = False self.canBeHit = True self.isUpSpecial = True self.cancelUpSpecial = False self.isRock = False self.regainMomentum = False self.isDead = False self.basicAttackCounter = 0 self.smashCounter = 0 self.hitboxes = [] self.spritePrefix = "" self.orientation = "right" self.anim = None self.spritexPosition = 0 self.hurtSprite = pyglet.image.Animation.from_image_sequence( spriteDictionary["hurt"], 1 / 30, False) self.hurtSpriteF = pyglet.image.Animation.from_image_sequence( spriteDictionary["hurtF"], 1 / 30, False) self.sprites = spriteDictionary["idle"] self.anim = pyglet.image.Animation.from_image_sequence( self.sprites, 0.5, True) self.sprite = pyglet.sprite.Sprite(self.anim) self.xScale = 1 self.yScale = 1 self.score = 0 self.box = objects.Box(xPosition, yPosition, self.sprite.width * self.xScale, self.sprite.height * self.yScale)
def update(self): self.launch -= constants.dt if (self.launch < 0): if hasattr(self, 'ball'): self.ball.destruct() del self.ball self.launch = 10 #self.ball = objects.Ball(self.pos, 0.1) self.ball = objects.Box(self.pos, (0.1, 0.1)) x, y = self.direction self.ball.addForce((1000 * x, 1000 * y))
def objects_in_part3(): """ 生成第三关的物体 """ key = untils.create_door_key() door = objects.Door(key) paper = objects.Paper(key, False) handle = objects.Handle(True) box = objects.Box(paper,False) add_a_object('door', door) add_a_object('paper',paper) add_a_object('handle',handle) add_a_object('box',box) return 'paper', 'handle', 'box'
def test_box_instance(self): box = objects.Box()
import camera import objects import scene import time p = objects.Point cam = camera.Camera( (1.5, -1., -1.35), (0., 0., 0.), ) sce = scene.Scene([ objects.Intersect( objects.Differ(objects.Box((0., 0., 0.), (1., 1., 5.)), objects.Circle((0., 0., 0.), 1.5)), objects.Circle((0., 0., 0.), 2.)) ]) sce = objects.Box((0., 0., 0.), (0.5, 0.5, 0.5)) #sce = objects.Circle((0.,0.,0.), 1.) cam.start_screen() pygame = cam.pg cam.draw(sce) print("Looping") while True: for event in pygame.event.get(): if event.type == pygame.KEYDOWN: if event.key == pygame.K_p: cam.fl = cam.fl - 0.0005
import camera import objects import scene import time p = objects.Point cam = camera.Camera( (5.1, 0., 0), (0., 0., 0.), ) sce = scene.Scene([ objects.Intersect( objects.Differ(objects.Box((0., 0., 0.), (1., 1., 5.)), objects.Circle((0., 0., 0.), 1.5)), objects.Circle((0., 0., 0.), 2.)) ]) #sce = objects.Circle((0.,0.,0.), 1.) cam.start_screen() pygame = cam.pg print("Looping") start = time.time() for i in range(20): cam.draw(sce) cam.point = cam.point - [0.5, 0, 0] print("20 frames took", time.time() - start) cam.wait()
objects.Triangle( a=[LL[0], ll, LL[1]], b=[UL[0], ul, UL[1]], c=[UR[0], ur, UR[1]], color=[0.0, 0.1, 0.2], ), objects.Triangle( a=[UR[0], ur, UR[1]], b=[LR[0], lr, LR[1]], c=[LL[0], ll, LL[1]], color=[0.0, 0.1, 0.2], ), ] if len(wave_mesh) > 4: bounding_box = objects.Box(vmin=[min_x, min_y, min_z], vmax=[max_x, max_y, max_z]) scene_wave = {"bounds": bounding_box, "objects": wave_mesh} scene["wave_part_" + str(counter)] = scene_wave counter += 1 wave_mesh = [] min_x, max_x = 1e9, -1 * 1e9 min_y, max_y = 1e9, -1 * 1e9 min_z, max_z = 1e9, -1 * 1e9 if len(wave_mesh) > 0: # remaining triangles bounding_box = objects.Box(vmin=[min_x, min_y, min_z], vmax=[max_x, max_y, max_z]) scene_wave = {"bounds": bounding_box, "objects": wave_mesh} scene["wave" + str(counter)] = scene_wave