code stringlengths 1 1.72M | language stringclasses 1
value |
|---|---|
# -*- coding: utf-8 -*-
# Code copied from http://opencv.willowgarage.com/wiki/PythonInterface - license unknown, but presumed to be at least as liberal as bsd (The license for opencv.).
import cv
import numpy as np
def cv2array(im):
"""Converts a cv array to a numpy array."""
depth2dtype = {
cv.IPL_... | Python |
# -*- coding: utf-8 -*-
# Copyright (c) 2011, Tom SF Haines
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright notice, this list of... | Python |
# Copyright (c) 2012, Tom SF Haines
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright notice, this list of conditions and the follo... | Python |
# -*- coding: utf-8 -*-
# Copyright (c) 2011, Tom SF Haines
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright notice, this list of... | Python |
# -*- coding: utf-8 -*-
# Copyright (c) 2011, Tom SF Haines
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright notice, this list of... | Python |
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2011, Tom SF Haines
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyrig... | Python |
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2010, Tom SF Haines
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyrig... | Python |
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2011 Tom SF Haines
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by... | Python |
# Copyright (c) 2012, Tom SF Haines
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright notice, this list of conditions and the follo... | Python |
# -*- coding: utf-8 -*-
# Copyright (c) 2010, Tom SF Haines
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright notice, this list of... | Python |
# Copyright (c) 2012, Tom SF Haines
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright notice, this list of conditions and the follo... | Python |
# Copyright (c) 2011, Tom SF Haines
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright notice, this list of conditions and the follo... | Python |
# -*- coding: utf-8 -*-
# Copyright (c) 2010, Tom SF Haines
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright notice, this list of... | Python |
# -*- coding: utf-8 -*-
# Code copied from http://opencv.willowgarage.com/wiki/PythonInterface - license unknown, but presumed to be at least as liberal as bsd (The license for opencv.).
import cv
import numpy as np
def cv2array(im):
"""Converts a cv array to a numpy array."""
depth2dtype = {
cv.IPL_... | Python |
# -*- coding: utf-8 -*-
# Copyright (c) 2011, Tom SF Haines
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright notice, this list of... | Python |
# Copyright (c) 2012, Tom SF Haines
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright notice, this list of conditions and the follo... | Python |
# -*- coding: utf-8 -*-
# Copyright (c) 2011, Tom SF Haines
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright notice, this list of... | Python |
# -*- coding: utf-8 -*-
# Copyright (c) 2011, Tom SF Haines
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright notice, this list of... | Python |
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2011, Tom SF Haines
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyrig... | Python |
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2010, Tom SF Haines
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyrig... | Python |
# -*- coding: utf-8 -*-
# Copyright 2011 Tom SF Haines
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agre... | Python |
# -*- coding: utf-8 -*-
# Copyright 2011 Tom SF Haines
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agre... | Python |
# -*- coding: utf-8 -*-
# Copyright 2011 Tom SF Haines
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agre... | Python |
# -*- coding: utf-8 -*-
# Copyright 2011 Tom SF Haines
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agre... | Python |
# -*- coding: utf-8 -*-
# Copyright 2011 Tom SF Haines
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agre... | Python |
# -*- coding: utf-8 -*-
# Copyright 2011 Tom SF Haines
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agre... | Python |
# -*- coding: utf-8 -*-
# Copyright 2011 Tom SF Haines
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agre... | Python |
# -*- coding: utf-8 -*-
# Copyright 2011 Tom SF Haines
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agre... | Python |
# -*- coding: utf-8 -*-
# Copyright 2011 Tom SF Haines
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agre... | Python |
# -*- coding: utf-8 -*-
| Python |
# -*- coding: utf-8 -*-
# Copyright 2011 Tom SF Haines
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agre... | Python |
# Copyright (c) 2012, Tom SF Haines
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright notice, this list of conditions and the follo... | Python |
# -*- coding: utf-8 -*-
# Copyright (c) 2010, Tom SF Haines
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright notice, this list of... | Python |
# Copyright (c) 2012, Tom SF Haines
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright notice, this list of conditions and the follo... | Python |
# Copyright (c) 2011, Tom SF Haines
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright notice, this list of conditions and the follo... | Python |
# -*- coding: utf-8 -*-
# Copyright (c) 2010, Tom SF Haines
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright notice, this list of... | Python |
# -*- coding: utf-8 -*-
# Code copied from http://opencv.willowgarage.com/wiki/PythonInterface - license unknown, but presumed to be at least as liberal as bsd (The license for opencv.).
import cv
import numpy as np
def cv2array(im):
"""Converts a cv array to a numpy array."""
depth2dtype = {
cv.IPL_... | Python |
# -*- coding: utf-8 -*-
# Copyright (c) 2011, Tom SF Haines
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright notice, this list of... | Python |
# Copyright (c) 2012, Tom SF Haines
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright notice, this list of conditions and the follo... | Python |
# -*- coding: utf-8 -*-
# Copyright (c) 2011, Tom SF Haines
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright notice, this list of... | Python |
# -*- coding: utf-8 -*-
# Copyright (c) 2011, Tom SF Haines
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright notice, this list of... | Python |
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2011, Tom SF Haines
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyrig... | Python |
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2010, Tom SF Haines
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyrig... | Python |
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2011 Tom SF Haines
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by... | Python |
#!/usr/bin/python
#
# Copyright (c) 2012 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agre... | Python |
#!/usr/bin/python
# -*- coding: utf-8 -*-
import wx
import urllib
import sys, pickle, logging
from cStringIO import StringIO
import conf
def encrypt(pword):
return 'S'.join(map(lambda x: '%2x'%ord(x), pword))
def decrypt(pword):
return ''.join(map(lambda x: chr(int(x, 16)), pword.split('S')))
... | Python |
#!/usr/bin/python
# -*- coding: utf-8 -*-
import urllib, cookielib, urllib2
import sys, logging, os
from sgmllib import SGMLParser
loginURL = "https://uis1.fudan.edu.cn/amserver/UI/Login?goto=http://www.urp.fudan.edu.cn/index.portal"
scoreURL = "http://www.urp.fudan.edu.cn:84/epstar/app/fudan/ScoreManger/Scor... | Python |
from distutils.core import setup
import py2exe
setup(
name = 'gpa',
console = ['main.py'],
author = 'Wang Yuanxuan',
)
| Python |
#!/usr/bin/python
# -*- coding: utf-8 -*-
import wx
import wx.grid as gridlib
import logging, conf
useLocalData = False
data = []
grade = []
class MyDataTable(gridlib.PyGridTableBase):
def __init__(self, log):
gridlib.PyGridTableBase.__init__(self)
initGrade()
initTags()
... | Python |
#!/usr/bin/python
# -*- coding: utf-8 -*-
import pickle
import logging
logging.basicConfig(filename="debug.log", level=logging.DEBUG, filemode='w')
scores = {'A': 4, 'A-': 3.7, 'B+': 3.3, 'B': 3, 'B-': 2.7, 'C+': 2.3,
'C': 2, 'C-': 1.7, 'D': 1.3, 'D-': 1, 'F': 0, 'P': 4}
version = 'v0.3.2010021... | Python |
print "Hello" | Python |
import sys
sys.path.append("..")
import testutil
testutil.test() | Python |
from fdk.util import *
class ForEachFileHandler:
def handle(self, fileName, filePath):
print "fileName: %s"%fileName
print "filePath: %s"%filePath
def test():
print tabStr(2, "2 tab in front")
print "lower1stChar(AbC)=%s"%lower1stChar("AbC")
print "lower1stChar(abc)=%s"%lower1stChar("abc")
print "... | Python |
# -*- coding: utf8 -*-
import os
# tab字符填充
def tabStr(tabnum,format,*args):
i=0
f=""
while i< tabnum:
f += "\t"
i += 1
f += format
return f % args
# 首字母小写
def lower1stChar(s):
return s[0:1].lower() + s[1:]
# 从路径中获得文件名
def getFileNameFromPath(path, hasExt=True):
index1 = path.rfind(... | Python |
import pygame
import data
def initsounds():
pygame.mixer.set_num_channels(4)
def loadsound(filename):
return pygame.mixer.Sound(data.load(filename))
def play_bgmusic(filename):
'plays filename as music in the background on repeat until told to stop.'
if pygame.mixer.music.get_busy():
pygame.... | Python |
import pygame
import constants as c
import data
class Turbinepole(pygame.sprite.Sprite):
def __init__(self, x, y):
''' Creates a turbinepole, given its x and y coordinates'''
pygame.sprite.Sprite.__init__(self)
self.image, self.rect = data.load_image("pole.png", None)
self.... | Python |
screen_size = (640, 480)
flags = 0
frame_time = 50
import os, sys
from os.path import dirname as d
import pygame
pygame.init()
from pygame.locals import *
import data
import albow
from albow.screen import Screen
from albow.text_screen import TextScreen
from albow.shell import Shell
from albow.resource import get_fo... | Python |
"""
levels.py
contains the definition of all the game's levels.
we can have a level generator in this file should we want random levels
generated rather than in the mainline code.
Concept for levels:
* Turbines produce X MWs (power) each
* Over the course of a level, T time, sum of turbines produce MWh (ener... | Python |
"""
A rudimentary bird.
Aims:
* Get the bird to animate a 'flapping' motion.
* Make it not look like all the bloody birds flap in unision.
* on a collision \w air the bird's accy is increased up or down.
* need some fancy trickery to make this a temporary accel.
perhap some time delayed update?... | Python |
'''
featherinyourcap
A game by Karl Urdevics and Jervis Whitley.
Released under the MIT license (see README.txt for details, tnx.)
havfunbye.
'''
import sys
import data
import pygame
pygame.mixer.pre_init(44100, -16, 2, 1024*3)
from pygame.locals import *
from random import randint, choice
import random
import math
... | Python |
import sys
from pygame import Rect, draw
from pygame.locals import K_RETURN, K_KP_ENTER, K_ESCAPE, K_TAB
from pygame.mouse import set_cursor
from pygame.cursors import arrow as arrow_cursor
from vectors import add, subtract
from utils import frame_rect
import theme
from theme import ThemeProperty, FontProperty
debug_r... | Python |
import os, sys
import pygame
from pygame.locals import RLEACCEL
#default_font_name = "Vera.ttf"
optimize_images = True
run_length_encode = False
def find_resource_dir():
if not 'python' in sys.executable:
path = os.path.dirname(sys.executable)
else:
path = os.path.dirname(sys.argv[0])
dir ... | Python |
from pygame import draw, Surface
from pygame.locals import SRCALPHA
def frame_rect(surface, color, rect, thick = 1):
surface.fill(color, (rect.left, rect.top, rect.width, thick))
surface.fill(color, (rect.left, rect.bottom - thick, rect.width, thick))
surface.fill(color, (rect.left, rect.top, thick, rect.height))
... | Python |
################################################################
#
# Albow - Tab Panel
#
################################################################
from pygame import Rect
from widget import Widget
from theme import ThemeProperty, FontProperty
from utils import brighten
class TabPanel(Widget):
# pages ... | Python |
#
# Albow - Sound utilities
#
import pygame
from pygame import mixer
def pause_sound():
try:
mixer.pause()
except pygame.error:
pass
def resume_sound():
try:
mixer.unpause()
except pygame.error:
pass
def stop_sound():
try:
mixer.stop()
except pygame.error:
pass
| Python |
#
# Albow - Fields
#
from pygame import draw
from pygame.locals import K_LEFT, K_RIGHT, K_TAB
from widget import Widget
from controls import Control
#---------------------------------------------------------------------------
class TextEditor(Widget):
upper = False
tab_stop = True
_text = ""
def __init__(s... | Python |
#
# Albow - Text Screen
#
from pygame import Rect
from pygame.locals import *
from screen import Screen
from theme import FontProperty
from resource import get_image, get_font, get_text
from vectors import add, maximum
from controls import Button
#--------------------------------------------------------------------... | Python |
from pygame import Rect
from widget import Widget
class GridView(Widget):
# cell_size (width, height) size of each cell
#
# Abstract methods:
#
# num_rows() --> no. of rows
# num_cols() --> no. of columns
# draw_cell(surface, row, col, rect)
# click_cell(row, col, event)
def __init__(se... | Python |
#
# Albow - Screen
#
from widget import Widget
#------------------------------------------------------------------------------
class Screen(Widget):
def __init__(self, shell, **kwds):
Widget.__init__(self, shell.rect, **kwds)
self.shell = shell
self.center = shell.center
def begin_frame(self):
pass
... | Python |
try:
from Numeric import add, subtract, maximum
except ImportError:
import operator
def add(x, y):
return map(operator.add, x, y)
def subtract(x, y):
return map(operator.sub, x, y)
def maximum(*args):
result = args[0]
for x in args[1:]:
result = map(max, result, x)
return result
| Python |
#
# Albow - Shell
#
from root import RootWidget
#------------------------------------------------------------------------------
class Shell(RootWidget):
def __init__(self, surface, **kwds):
RootWidget.__init__(self, surface, **kwds)
self.current_screen = None
def show_screen(self, new_screen):
old_scree... | Python |
from pygame import Rect
from albow.resource import get_image
class ImageArray(object):
def __init__(self, image, shape):
self.image = image
self.shape = shape
if isinstance(shape, tuple):
self.nrows, self.ncols = shape
else:
self.nrows = 1
self.ncols = shape
iwidth, iheight = image.get_size()
se... | Python |
#
# Albow - Controls
#
from pygame import Rect, draw
from widget import Widget, overridable_property
from theme import ThemeProperty
from utils import blit_in_rect, frame_rect
import resource
#---------------------------------------------------------------------------
class Control(object):
highlighted = overrid... | Python |
version = (2, 0, 0)
| Python |
#
# Albow - Themes
#
import resource
debug_theme = False
class ThemeProperty(object):
def __init__(self, name):
self.name = name
self.cache_name = intern("_" + name)
def __get__(self, obj, owner):
if debug_theme:
print "%s(%r).__get__(%r)" % (self.__class__.__name__, self.name, obj)
try: ###
ca... | Python |
#
# Albow - Layout widgets
#
from pygame import Rect
from widget import Widget
class RowOrColumn(Widget):
def __init__(self, size, items, kwds):
align = kwds.pop('align', 'c')
spacing = kwds.pop('spacing', 10)
expand = kwds.pop('expand', None)
if isinstance(expand, int):
expand = items[expand]
#if kw... | Python |
"""ALBOW - A Little Bit of Widgetry for PyGame
by Gregory Ewing
greg.ewing@canterbury.ac.nz
"""
from version import version
| Python |
import textwrap
from pygame import Rect
from pygame.locals import *
from widget import Widget
from controls import Label, Button
from layout import Row, Column
from fields import TextField
class Modal(object):
enter_response = True
cancel_response = False
def ok(self):
self.dismiss(True)
def cancel(self):
... | Python |
import sys
import pygame
from pygame.locals import *
from pygame.time import get_ticks
from pygame.event import Event
import widget
from widget import Widget
mod_cmd = KMOD_LCTRL | KMOD_RCTRL | KMOD_LMETA | KMOD_RMETA
double_click_time = 300 # milliseconds
modifiers = dict(
shift = False,
ctrl = False,
alt = False... | Python |
#
# Albow - File Dialogs
#
import os
from pygame import draw, Rect
from albow.widget import Widget
from albow.dialogs import Dialog, ask, alert
from albow.controls import Label, Button
from albow.fields import TextField
from albow.layout import Row, Column
from albow.palette_view import PaletteView
from albow.theme... | Python |
from pygame import Rect, draw
from grid_view import GridView
from utils import frame_rect
from theme import ThemeProperty
class PaletteView(GridView):
# nrows int No. of displayed rows
# ncols int No. of displayed columns
#
# Abstract methods:
#
# num_items() --> no. of items
# draw_item(surf... | Python |
#
# Albow - Table View
#
from itertools import izip
from pygame import Rect
from layout import Column
from palette_view import PaletteView
from utils import blit_in_rect
class TableView(Column):
columns = []
header_font = None
header_fg_color = None
header_bg_color = None
header_spacing = 5
column_margin = 2... | Python |
import pygame
import math
import constants as c
import data
import bird
import sounds
class Turbine(pygame.sprite.Sprite):
def __init__(self, x, y):
''' Creates a turbine head, given its x and y coordinates'''
pygame.sprite.Sprite.__init__(self)
self.image, self.rect = data.loa... | Python |
"""
a really poor popup box.
smart enough to display text and perhaps images
in a grid like or column like fashion.
image | text about image
| can span multiple
| lines.
clicking a mouse button will exit."""
import pygame
from pygame.locals import *
import data
import constants as c
def... | Python |
"""
File to house
bonuses both on a game-wide
and level-wide basis."""
import pygame
import data
import constants as c
def get_bonuses(gamestats, levelstats):
achieved = []
for bonus, kind in bonuses:
if kind == 'game':
stat = gamestats
else:
stat = levelstats
... | Python |
import pygame
XMAX = 800
YMAX = 600
RESOLUTION = (XMAX, YMAX)
FPS = 40
# number of milliseconds between bird updates.
BIRDRATE = 100
# bird event.
BIRDUPDATE = pygame.USEREVENT
# event definitions
# 250 ms between fan gusts
EVENT_FAN_TIMEOUT = 25
EVENT_FAN_TIMEOUT_TIME = 250
BLOW = 1
SUCK = 0
# the amount of kWh ... | Python |
'''Simple data loader module.
Loads data files from the "data" directory shipped with a game.
Enhancing this to handle caching etc. is left as an exercise for the reader.
'''
import os
import sys
import pygame
from pygame.locals import *
if 'python' in sys.executable:
data_py = os.path.join(os.path.abspath(os.p... | Python |
"""
animation.py
implementation of animations, uses sprite sheets."""
import pygame
import data
class Animation(pygame.sprite.Sprite):
def __init__(self, image, pos, delay_ms):
"give the filename, x,y coords and delay between transitions."
pygame.sprite.Sprite.__init__(self)
s = data.Sp... | Python |
#
# fan.py
#
# The Fan class
#
import pygame
import data
import constants as c
import sounds
FAN_READY = 0
FAN_BLOW = 1
FAN_SUCK = 2
class Fan(pygame.sprite.Sprite):
def __init__(self):
pygame.sprite.Sprite.__init__(self)
self.image_normal, self.rect = data.load_image("fan.p... | Python |
import pygame
import constants as c
import data
import bird
class Air(pygame.sprite.Sprite):
def __init__(self, kind, a, b, m):
pygame.sprite.Sprite.__init__(self)
# pass in kind, velocity coeffs (pixels/s) and mass (kg)
self.kind = kind
self.a = a/1000.0
self... | Python |
#
# scorebar.py
#
# implementation of the score bar.
#
import pygame
import data
import constants as c
font = None
def rendertxt(txt):
global font
try:
return font.render(txt, 1, (255, 255, 255))
except AttributeError:
font = pygame.font.Font(None, 26)
return rendertxt(txt)
class... | Python |
#! /usr/bin/env python
from gamelib import main
main.main()
| Python |
#! /usr/bin/env python
from gamelib import main
try:
main.main()
except SystemExit:
pass
| Python |
#! /usr/bin/env python
from gamelib import main
main.main()
| Python |
#! /usr/bin/env python
from gamelib import main
try:
main.main()
except SystemExit:
pass
| Python |
#!/usr/bin/env python2.7
import json
import logging
import os
import pprint as pp
import sys
import unittest
import urllib2
try:
from webtest import TestApp
except:
print """Please install webtest from http://webtest.pythonpaste.org/"""
sys.exit(1)
# Attempt to locate the App Engine SDK based on the system PAT... | Python |
'''Copyright 2011 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in ... | Python |
'''Copyright 2011 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in ... | Python |
#!/usr/bin/env python
import optparse
import jwt
import sys
import json
import time
__prog__ = 'jwt'
__version__ = '0.1'
""" JSON Web Token implementation
Minimum implementation based on this spec:
http://self-issued.info/docs/draft-jones-json-web-token-01.html
"""
import base64
import hashlib
import hmac
try:
... | Python |
'''Copyright 2011 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in ... | Python |
Subsets and Splits
SQL Console for ajibawa-2023/Python-Code-Large
Provides a useful breakdown of language distribution in the training data, showing which languages have the most samples and helping identify potential imbalances across different language groups.