def connect(host, port=None, through=None): '''establish a secure tunnel connection to a remote host at the given port Inputs: host -- hostname to which a tunnel should be established port -- port number (on host) to connect the tunnel to through -- 'tunnel-through' hostname [default = None] ''' from Tunnel import Tunnel t = Tunnel() t.connect(host, port, through) return t
def connect(rhost,rport): '''establish a secure tunnel connection to a remote host at the given port Inputs: rhost -- hostname to which a tunnel should be established rport -- port number (on rhost) to connect the tunnel to ''' from Tunnel import Tunnel t = Tunnel('Tunnel') lport = t.connect(rhost,rport) #FIXME: want to have r.lport, r.rport, r.rhost as class members return t,lport
def connect(rhost, rport): '''establish a secure tunnel connection to a remote host at the given port Inputs: rhost -- hostname to which a tunnel should be established rport -- port number (on rhost) to connect the tunnel to ''' from Tunnel import Tunnel t = Tunnel('Tunnel') lport = t.connect(rhost, rport) #FIXME: want to have r.lport, r.rport, r.rhost as class members return t, lport
def main(): background = Background(20) terrain = Tunnel() terrain.build() pygame.init() win_size = (1200, 900) pygame.display.set_mode( win_size, pygame.DOUBLEBUF | pygame.OPENGL | pygame.RESIZABLE) gluPerspective(60, (win_size[0] / win_size[1]), 0.9, 600) glTranslate(0, terrain.radius - 20, -560) glEnable(GL_DEPTH_TEST) clock = pygame.time.Clock() exit_flag = False while not exit_flag: clock.tick(60) for eve in pygame.event.get(): if eve.type == pygame.QUIT: exit_flag = True keys = pygame.key.get_pressed() if keys[pygame.K_d]: terrain.rotate(-1) background.rotate(-1, math.pi / terrain.sides_num / 2) if keys[pygame.K_a]: terrain.rotate(1) background.rotate(1, math.pi / terrain.sides_num / 2) if keys[pygame.K_ESCAPE]: exit_flag = True background.move() terrain.clear() terrain.move() terrain.collision() # glRotatef(1, 0, 0, int(2 * mat.pi)) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) background.draw() terrain.draw() pygame.display.flip()
from RailTrack import RailTrack from Tunnel import Tunnel from Train import Train from Player import Player from Hobo import Hobo import random #This is the amount of time in seconds since the game started. If the player performs an action (ex. waits, hops), time is advanced by 1 second elapsedTime = 0 # Take parameter as intput from stdin tracks = int(input("Enter the number of tracks: ")) p = Player(0, tracks) t = Tunnel(tracks) # Railtracks and trains are in here print("Generated RailTrack object successfully, " + str(t)) mcount = 1 # count for every actions to get the percentage # Game Loop run for n iterations #for i in range(tracks): print("Loading...") nextPos = 0 while not (p.health == 0): #player on track at that time and there is a train coming up # This might be redundant # In each step: # We ask our player if they want to move (potential algorithm: move to random track)
FPS = 60 last_time = time.time() clock = pygame.time.Clock() game_running = True while game_running: # GameLoop dt = time.time() - last_time dt *= FPS last_time = time.time() for event in pygame.event.get(): # Every event will be under here if event.type == pygame.QUIT: # Event to run when we click the X button game_running = False if event.type == SPAWNTUNNEL: pygame.time.set_timer(SPAWNTUNNEL, random.randint(1000, 2000)) tunnel_list.append(Tunnel()) # Tunnels for tunnel in reversed(tunnel_list): tunnel.move(dt) if tunnel.hitbox.x < -100: tunnel_list.remove(tunnel) for tunnel in tunnel_list: for x, player in enumerate(players): if len(tunnel_list) == 0: pass if tunnel.collision(player): savedPlayers.append(players.pop(x)) for player in players: