Beispiel #1
0
    def __init__(self):
        base.accept('f1', self.toggleDebug)

        self.debugNode = BulletDebugNode('Debug')
        self.debugNode.showWireframe(True)
        self.debugNode.showConstraints(True)
        self.debugNode.showBoundingBoxes(False)
        self.debugNode.showNormals(False)
        self.debugNP = base.render.attachNewNode(self.debugNode)
        # self.debugNP.show()

        # World
        self.world = BulletWorld()
        self.world.setGravity(Vec3(0, 0, -9.81))
        self.world.setDebugNode(self.debugNP.node())

        # Terrain
        visNP = base.loader.loadModel('models/terrain.egg')

        mesh = BulletTriangleMesh()
        for x in visNP.findAllMatches('**/+GeomNode'):
            geom = x.node().getGeom(0)
            mesh.addGeom(geom)
        shape = BulletTriangleMeshShape(mesh, dynamic=True)

        body = BulletRigidBodyNode('Bowl')
        bodyNP = base.render.attachNewNode(body)
        bodyNP.node().addShape(shape)
        bodyNP.setPos(0, 0, 1)
        bodyNP.setCollideMask(BitMask32.allOn())
        self.world.attachRigidBody(bodyNP.node())

        visNP.reparentTo(bodyNP)

        shapex = BulletBoxShape(5)
        bodyx = BulletRigidBodyNode('Egg')
        bodyNPx = base.render.attachNewNode(bodyx)
        bodyNPx.setPos(0, 0, 3)
        bodyNPx.node().setMass(100.0)
        bodyNPx.node().addShape(shapex)
        self.world.attachRigidBody(bodyNPx.node())
        # visNP.reparentTo(bodyNPx)

        # Player
        self.players = []
        self.myId = -1
        self.speed = Vec3(0, 0, 0)
        self.walk_speed = 2.5

        # Camera
        base.disableMouse()
        props = WindowProperties()
        props.setCursorHidden(True)
        base.win.requestProperties(props)

        # SkySphere
        Sky()

        self.initCam()
Beispiel #2
0
 def __init__(self):
     self.win = Window((Game.win_width, Game.win_height))
     self.sky = Sky(Game.win_width, Game.win_height)
     self.platform = Platform(Game.win_width, 96, Game.win_height - 96 - 30)
     self.dino = None
     self.enemy_velocity = 250
     self.score = 0
     self.create_handlers()
     self.enemies = []
Beispiel #3
0
    def __init__(self):

        self.size = (800, 400)
        self.fps = 30
        self.screen = None

        self.sky = Sky(self)
        self.foreground = Foreground(self)
        self.sun = Sun(self)
Beispiel #4
0
def enter():
    global mainstage
    mainstage = title_state.stage
    global player
    player = Player()
    global sky
    if stageload.stage == 2:
        sky = Sky(stageload.stage)
    else:
        sky = Sky(mainstage)

    global map_counter
    if stageload.stage == 2:
        map_counter = Mapcounter(stageload.stage)
    else:
        map_counter = Mapcounter(mainstage)

    game_world.add_object(sky, 0)
    game_world.add_object(player, 1)
Beispiel #5
0
 def __init__(self, width, height):
     self.mWidth = width
     self.mHeight = height
     self.mSky = Sky(width, height)
     self.mPlanet1 = Planet(200, 210, 215)
     self.mPlanet1.setColor(204, 204, 204)
     self.mMountain1 = Mountain(width, height)
     self.mCrater1 = Crater(40, 130, 100, 100)
     self.mCrater2 = Crater(35, 120, 50, 50)
     self.mCrater3 = Crater(90, 10, 90, 90)
     self.mCrater4 = Crater(250, 90, 100, 100)
     self.mCrack1 = Crack(290, 250)
     self.mCrack2 = Crack(285, 240)
     self.mHill1 = Hill(175, 400)
     self.mHill2 = Hill(300, 380)
     self.mHill3 = Hill(500, 450)
     self.mStar = Star(width, height)
     return
Beispiel #6
0
def create_world():
    global prince, rose, sky, grass, balls, big_balls, icon_pause, icon_planet, blood_gage, tree, tree2, trees, trees2, dirty_waters, item_barriers, item_boosters
    prince = Prince()
    rose = Rose()
    icon_pause = Icon_pause()
    icon_planet = Icon_planet()
    blood_gage = Blood_gage()
    tree = Tree()
    tree2 = Tree2()
    #    trees = [Tree() for i in range(5)]
    #    trees2 = [Tree2() for i in range(5)]
    dirty_waters = [Dirty_water() for i in range(2)]
    item_barriers = [Item_barrier() for i in range(3)]
    item_boosters = [Item_booster() for i in range(3)]

    #    big_balls = [BigBall() for i in range(10)]

    #    big_balls_for_collsion_check = big_balls, []

    #    balls = [Ball() for i in range(10)]
    #    balls = big_balls + balls
    grass = Grass()
    sky = Sky()
Beispiel #7
0
from sky import Sky
s = Sky(400)
s.read_frame_hip()
s.read_frame_tyc()
s.print_progress(1, 3)
s.read_line()
s.print_progress(2, 3)
s.read_star()
s.print_progress(3, 3)
s.print_time()
s.init_area(1, s.fs[1], s.fs[2], s.fs[3], s.fs[4], s.fs[5], s.fs[6], s.fs[7],
            6)
s.draw_alpha_lines(15)
s.draw_delta_lines(10)
s.draw_constellation_lines()
s.draw_star()
s.draw_legend()
s.draw_alpha_text(15)
s.draw_delta_text(10)
s.draw_header_link(1, 0)
for k, v in s.f1.items():
    if v[0] == 1:
        s.draw_frame_link(k, v[1], v[3], v[4], v[6], 'hip{:03}'.format(k),
                          'red')
s.draw_frame(True, False, False, False)
s.save_img()
s.init_area(2, s.fn[1], s.fn[2], s.fn[3], s.fn[4], s.fn[5], s.fn[6], s.fn[7],
            6)
s.draw_alpha_lines(15)
s.draw_delta_lines(10)
s.draw_constellation_lines()
cubesat = Led(brightness=1.,
              std=1.,
              sequence=header,
              frequency=30,
              x=CMOS.cols // 2,
              y=CMOS.rows // 2)
# Receiver object with a camera, that captures images at a fixed frequency (1 / fps)
# The receiver generates a random noise pattern that is applied to all the captured images. Set noise=False for no noise
print(CMOS)
print('\nGenerating background variation noise pattern, please wait... ',
      end='')
receiver = Receiver(camera=CMOS, fps=60)
print('Done!')

# Create teh sky  with random stars and 1 cubesat (Led)
sky = Sky()
sky.add_random_stars(N_STARS,
                     max_x=CMOS.cols,
                     max_y=CMOS.rows,
                     min_brightness=.02,
                     max_brightness=1.,
                     min_std=.01,
                     max_std=2.)
sky.add_cubesat(cubesat)

# Capture a video from t=0 to t=100 ms. The cubesat (Led) will be repeating its sequence starting at t=0
# Video frames will include the cubesat (Led) or not, according to it's blinking frecuency, current state in the sequence (High or Low)
# and video capturing speed (fps)
timestamps, video = receiver.capture_video(sky, millis_end=150)

# Process the frames as we want, in this case it's just a median filter
Beispiel #9
0
def create_sky(canvas):
    sky1 = Sky(canvas, tkinter.NW)
    sky2 = Sky(canvas, tkinter.SW)
    sky1.draw_sky()
    sky2.draw_sky()
    return sky1, sky2
Beispiel #10
0
from sky import Sky
s = Sky(400, True)
s.read_frame_tyc()
s.print_time()
s.read_star_tyc()
s.print_time()
i = 0
n = len(s.f3)
for k, v in s.f3.items():
    d = s.alpha_d(v[5])
    s.init_area(k, v[1], v[2], v[3], v[4], v[5], v[6], v[7], 16, True)
    s.draw_alpha_lines(d)
    s.draw_delta_lines(1)
    s.draw_frame(True, True, True, True)
    s.draw_star_tyc(int(k - 1))
    s.draw_legend(True)
    s.draw_alpha_text(d)
    s.draw_delta_text(1)
    s.draw_header_tyc(k)
    s.save_img()
    i = i + 1
    s.print_progress(i, n)
s.print_time()
Beispiel #11
0
    def setup(self):
        self.worldNP = render.attachNewNode('World')

        # World
        self.debugNP = self.worldNP.attachNewNode(BulletDebugNode('Debug'))
        self.debugNP.hide()

        self.world = BulletWorld()
        self.world.setGravity(Vec3(0, 0, -9.81))
        self.world.setDebugNode(self.debugNP.node())

        # Plane
        #shape = BulletPlaneShape(Vec3(0, 0, 1), 0)
        #mesh = BulletTriangleMesh()
        #geomNodes = loader.loadModel('levels/test1/collision').findAllMatches('**/+GeomNode')
        #geomNode = geomNodes.getPath(0).node()
        #geom = geomNode.getGeom(0)
        #mesh.addGeom(geom)
        #shape = BulletTriangleMeshShape(mesh, dynamic=False, bvh=True )
        #np = self.worldNP.attachNewNode(BulletRigidBodyNode('Ground'))
        #np.node().addShape(shape)
        #np.setPos(0, 0, 20.0)
        #np.setCollideMask(BitMask32.allOn())
        #self.world.attachRigidBody(np.node())

        #sky dome
        self.sun_sky = Sky()
        self.sun_sky.setTime(17.0)

        #terrain
        self.ground = Terrain(self.world, self.worldNP)
        self.ground.loadMesh(path + 'levels/gandg2/collision')
        self.ground.setMaps(path + 'levels/gandg2/')
        self.ground.setTextures((39, 1, 2, 15, 4, 5))

        #grass
        self.grass = Grass()
        self.grass.setMap(path + 'levels/gandg2/grass.png')
        self.grass_to_cut = self.grass.getStatus()
        # Car
        self.car = Car(self.world, self.worldNP)
        self.car.setPos(161.0, 160.0, 26)
        #camera
        self.camera = FlyingCamera()

        #car to character scale 0.0128
        self.char = Character(self.world, self.worldNP)
        self.char.enterCar()
        #self.char.setPos(256, 250, 80)

        #filter manager, post process
        self.filters = Postprocess()
        #self.filters.setupFxaa()
        #no time to make it work, sorry...
        self.filters.setupFilters()

        #map objects .. hardcoded because of time
        self.object_root = render.attachNewNode('object_root')
        obj = [(path + 'models/pyweek_wall1', 0.0, (303.0, 405.0,
                                                    25.0980415344238),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 0.0, (301.0, 405.0,
                                                    25.0980434417725),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 0.0, (299.0, 405.0,
                                                    25.0980415344238),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 0.0, (297.0, 405.0,
                                                    25.0980415344238),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 0.0, (295.0, 405.0,
                                                    25.0980415344238),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 0.0, (293.0, 405.0,
                                                    25.0980434417725),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 0.0, (291.0, 405.0,
                                                    25.0980415344238),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 0.0, (289.0, 405.0,
                                                    25.0980415344238),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 0.0, (287.0, 405.0,
                                                    25.0980415344238),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 0.0, (285.0, 405.0,
                                                    25.0980415344238),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 0.0, (283.0, 405.0,
                                                    25.0980415344238),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 0.0, (281.0, 405.0,
                                                    25.0980415344238),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 0.0, (281.0, 385.0,
                                                    25.0980415344238),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 0.0, (283.0, 385.0,
                                                    25.0980453491211),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 0.0, (285.0, 385.0,
                                                    25.0980415344238),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 90.0, (304.0, 404.0,
                                                     25.0980415344238),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 90.0, (304.0, 402.0,
                                                     25.0980415344238),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 90.0, (304.0, 400.0,
                                                     25.0980415344238),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 90.0, (304.0, 398.0,
                                                     25.0980415344238),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 90.0, (304.0, 396.0,
                                                     25.0980415344238),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 90.0, (304.0, 394.0,
                                                     25.0980415344238),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 90.0, (304.0, 392.0,
                                                     25.237850189209),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 90.0, (280.0, 404.0,
                                                     25.0980415344238),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 90.0, (280.0, 398.0,
                                                     25.0980415344238),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 90.0, (280.0, 396.0,
                                                     25.0980415344238),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 90.0, (280.0, 394.0,
                                                     25.0980415344238),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 90.0, (280.0, 392.0,
                                                     25.0980415344238),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 90.0, (280.0, 390.0,
                                                     25.0980415344238),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 90.0, (280.0, 388.0,
                                                     25.0980415344238),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 90.0, (280.0, 386.0,
                                                     25.0980415344238),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 90.0, (286.0, 386.0,
                                                     25.0980415344238),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 90.0, (286.0, 388.0,
                                                     25.0980415344238),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 90.0, (286.0, 390.0,
                                                     25.0980434417725),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 0.0, (287.0, 391.0,
                                                    25.0980415344238),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 0.0, (289.0, 391.0,
                                                    25.1190624237061),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 0.0, (291.0, 391.0,
                                                    25.1960334777832),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 0.0, (293.0, 391.0,
                                                    25.1596641540527),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 0.0, (295.0, 391.0,
                                                    25.2697868347168),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 0.0, (297.0, 391.0,
                                                    25.3282146453857),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 0.0, (299.0, 391.0,
                                                    25.3496627807617),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 0.0, (301.0, 391.0,
                                                    25.2688617706299),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 0.0, (303.0, 391.0,
                                                    25.2534332275391),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_wall1', 90.0, (280.0, 402.0,
                                                     25.0980415344238),
                path + 'models/pyweek_wall1_collision'),
               (path + 'models/pyweek_box', 0.0,
                (279.600006103516, 401.700012207031, 25.0980415344238), None),
               (path + 'models/pyweek_box', 0.0,
                (279.399993896484, 402.200012207031, 25.0980415344238), None),
               (path + 'models/pyweek_box', 0.0,
                (279.600006103516, 402.700012207031, 25.0980415344238), None),
               (path + 'models/pyweek_box', 0.0,
                (279.399993896484, 403.399993896484, 25.0980415344238), None),
               (path + 'models/pyweek_box', 0.0,
                (278.799987792969, 402.799987792969, 25.0980415344238), None),
               (path + 'models/pyweek_box', 0.0,
                (278.799987792969, 402.100006103516, 25.0980415344238), None),
               (path + 'models/pyweek_box', 0.0, (279.0, 401.5,
                                                  25.0980415344238), None),
               (path + 'models/pyweek_box', 0.0, (278.5, 401.600006103516,
                                                  25.0980415344238), None),
               (path + 'models/pyweek_box', 0.0,
                (278.799987792969, 401.899993896484, 25.5980415344238), None),
               (path + 'models/pyweek_box', 90.0, (279.5, 402.600006103516,
                                                   25.5980415344238), None),
               (path + 'models/pyweek_box', 90.0, (279.0, 402.5,
                                                   25.5980415344238), None),
               (path + 'models/pyweek_box', 90.0, (279.399993896484, 402.0,
                                                   25.5980415344238), None),
               (path + 'models/pyweek_box', 90.0,
                (278.100006103516, 402.299987792969, 25.0980415344238), None),
               (path + 'models/pyweek_box', 90.0,
                (277.799987792969, 401.700012207031, 25.0980415344238), None),
               (path + 'models/pyweek_box', 90.0,
                (278.200012207031, 401.899993896484, 25.5980415344238), None),
               (path + 'models/pyweek_box', 90.0,
                (279.399993896484, 402.399993896484, 26.0980415344238), None),
               (path + 'models/pyweek_box', 90.0, (279.0, 401.899993896484,
                                                   26.0980415344238), None),
               (path + 'models/pyweek_box', 90.0,
                (278.799987792969, 402.399993896484, 26.0980415344238), None)]
        for i in obj:
            loadObject(model=i[0],
                       H=i[1],
                       pos=i[2],
                       world=self.world,
                       worldNP=self.worldNP,
                       root=self.object_root,
                       collision_solid=i[3])
        self.object_root.flattenStrong()

        #models/pyweek_gate,90.0,(280.0,399.0,25.0980415344238))

        #gui
        self.hud = HUD()

        #volume
        sfxMgr = base.sfxManagerList[0]
        sfxMgr.setVolume(cfg['sound-volume'] * 0.01)
        musicMgr = base.musicManager
        musicMgr.setVolume(cfg['music-volume'] * 0.01)

        #music
        self.driving_music = loader.loadMusic(path + 'music/driving.ogg')
        self.driving_music.setLoop(True)
        self.driving_music.play()
        self.walking_music = loader.loadMusic(path + 'music/walking.ogg')
        self.walking_music.setLoop(True)

        print self.char.actor.getScale(render)