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 as pg | |
import random | |
from time import sleep | |
# For FPS | |
clock = pg.time.Clock() | |
# Colors | |
red = pg.Color(255, 0, 0) | |
green = pg.Color(0, 255, 0) | |
black = pg.Color(0, 0, 0) |
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, sys | |
from pygame.locals import * | |
pygame.init() | |
FPS = 60 | |
fpsClock = pygame.time.Clock() | |
DISPLAYSURF = pygame.display.set_mode((400,300), 0, 32) | |
pygame.display.set_caption('Animation') |
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, sys | |
from pygame.locals import * | |
pygame.init() | |
FPS = 60 | |
fpsClock = pygame.time.Clock() | |
DISPLAYSURF = pygame.display.set_mode((400,300), 0, 32) | |
pygame.display.set_caption('Animation') |
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, sys | |
from pygame.locals import * | |
pygame.init() | |
DISPLAYSURF = pygame.display.set_mode((400,300)) | |
pygame.display.set_caption('Hello World') | |
WHITE = (255, 255, 255) | |
GREEN = (0, 255, 0) | |
BLUE = (0, 0, 128) |
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, sys | |
from pygame.locals import * | |
pygame.init() | |
# setup the window | |
DISPLAYSURF = pygame.display.set_mode((00, 400), 0, 32) | |
pygame.display.set_caption('Drawing') | |
# setup colors |
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
╔════════════════════╦═══════════════════════════════════════════════════════════════════════╗ | |
║ Attribute Name ║ Description ║ | |
╠════════════════════╬═══════════════════════════════════════════════════════════════════════╣ | |
║ myRect.left ║ The int value of the X-coordinate of the left side of the rectangle ║ | |
║ myRect.right ║ The int value of the X-coordinate of the right side of the rectangle. ║ | |
║ myRect.top ║ The int value of the Y-coordinate of the top side of the rectangle. ║ | |
║ myRect.bottom ║ The int value of the Y-coordinate of the bottom side. ║ | |
║ myRect.centerx ║ The int value of the X-coordinate of the center of the rectangle. ║ | |
║ myRect.centery ║ The int value of the Y-coordinate of the center of the rectangle. ║ |
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, sys | |
from pygame.locals import * | |
pygame.init() | |
DISPLAYSURF = pygame.display.set_mode((400, 300)) | |
pygame.display.set_caption('Hello World!') | |
while True: # main game loop | |
for event in pygame.event.get(): | |
if event.type == QUIT: | |
pygame.quit() |
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
#!/usr/bin/env python3 | |
# imports | |
import argparse | |
import random | |
from math import log | |
def main(range_end): | |
guesses_made = 0 | |
# number of guesses is 1 + the log of the range |
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
#!/usr/bin/env python3 | |
import random | |
guesses_made = 0 | |
name = input('Hello! What is your name?\n') | |
number = random.randint(1,20) | |
print('Well, {}, I am thinking of a number between 1 and 20'.format(name)) |
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 sys | |
generations = 5000 | |
pop_size = 1000 | |
gamete_no = 1000 | |
pop = [] | |
n = len(sys.argv) | |
if n == 2: |
NewerOlder