This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from time import sleep | |
import random | |
DISP_WIDTH = 96 | |
DISP_HEIGHT = 32 | |
NB_MAX_CHAR_GEN=64 | |
class MovingChar(): | |
def __init__(self , display): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pygame | |
from time import sleep | |
import random | |
import sys | |
BLACK = ( 0, 0, 0) | |
NB_PIX_BATCH = 64 | |
DISP_WIDTH = 640 | |
DISP_HEIGHT = 480 | |
REFR_RATE = 0.008 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
import sys | |
def printMultiples(k, sup_bound): | |
map(print, [ k*i for i in xrange(1,1+(sup_bound/k) ) ] ) | |
if (len(sys.argv)<3 ): | |
print("this program prints multiples of k up to a cernain bound") | |
print("usage: python "+sys.argv[0]+" k sup_bound") | |
sys.exit(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pygame | |
from time import sleep | |
#replace this by some cool sound effect & music ! | |
SFX = 'alrighty.wav' | |
MUSIC = '4sequence.mp3' | |
# init pygame ; load n play a sound effect | |
pygame.init() | |
soundObj = pygame.mixer.Sound('alrighty.wav') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pygame | |
from pygame.locals import * | |
import sys | |
from time import sleep | |
# init. pygame libr; create the screen and diplays a help message in the console | |
pygame.init() | |
DISPLAYSURF = pygame.display.set_mode((640, 480)) | |
src_color = pygame.Color('antiquewhite3') | |
targ_color = pygame.Color('yellow') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import pygame | |
from pygame.locals import * | |
def generateRandColorObj(): | |
return pygame.Color( | |
random.randint(0,255), random.randint(0,255), random.randint(0,255), 255 ) | |
def addSquare(start_pos, end_pos, color ): | |
square_list.append( (start_pos, end_pos, color)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
current_milli_time = lambda: int(round(time.time() * 1000)) | |
# we use the Factory Design Pattern, RngCreator is the abstract class | |
class RngCreator(object): | |
def createRng(self): | |
raise NotImplementedError("Please Implement this method") | |
def inputParams(self, p_dict): | |
raise NotImplementedError("Please Implement this method") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
# This code implements the so-called "descent method" which is a kind of NEIGHBOR SEARCH METHOD | |
# often used in optimization. | |
# I apply it to the simple problem of finding the minimum value in a huge random matrix | |
# I count the nb of values tested to show how this kind of search is efficient in practice | |
# I initiale a random matrix and compute the global min. value on-the-fly to know | |
# if the descent method eventually succeeds in finding it. | |
N = 128 ; M = 128 | |
MAX_VAL = 255 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this program draws a random TREE-LIKE shape, inspired by L-Systems | |
import pygame | |
from time import sleep | |
import random | |
import sys | |
DISP_WIDTH = 640 | |
DISP_HEIGHT = 480 | |
def randPeriod(): | |
return random.choice((1, 16, 64) ) #determines the slope with wich the emerging branch grows |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import pygame | |
from pygame.locals import * | |
SCREEN_W = 640 | |
SCREEN_H = 480 | |
def refeshFunction(): | |
DISPLAYSURF.fill( pygame.Color('antiquewhite3') ) | |
# draws the paddle | |
rect_rep_paddle =\ |