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
Show hidden characters
{ | |
"auto_complete_commit_on_tab": true, | |
"bold_folder_labels": true, | |
"color_scheme": "Packages/Tomorrow Color Schemes/Tomorrow-Night.tmTheme", | |
"font_face": "Ubuntu Mono", | |
"font_options": | |
[ | |
"subpixel_antialias" | |
], | |
"font_size": 13.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
a = 10 | |
b = 20 | |
a = a + b | |
b = a - b | |
a = a - b | |
# a = 20 | |
# b = 10 |
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
def gcd(x, y): | |
while y: | |
x, y = y, x % y | |
return x |
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
#written by Hiradur | |
#Replaces any block above sea level with air and every block beneath it with dirt | |
#to keep processing time short it only replaces blocks from above sea level to level 64 | |
#if you built higher you have to change the parameter | |
#import minecraft.py module for interaction with the world | |
import minecraft.minecraft as minecraft | |
#import minecraft block module for block ids | |
import minecraft.block as block | |
#import time for delays |
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
#written by Hiradur | |
#Replaces any block above sea level with air | |
#too keep processing time short it only replaces blocks from above sea level to level 64 | |
#if you built higher you have to change the parameter | |
#import minecraft.py module for interaction with the world | |
import minecraft.minecraft as minecraft | |
#import minecraft block module for block ids | |
import minecraft.block as block | |
#import time for delays |
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 minecraft | |
import time | |
mc = minecraft.Minecraft.create(); | |
while True: | |
hits = mc.events.pollBlockHits() | |
for hit in hits: | |
block = mc.getBlockWithData(hit.pos.x, hit.pos.y, hit.pos.z); | |
block.data = (block.data + 1) & 0xf; |
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
# Calculate Pi via the Monte Carlo method | |
# Throw darts at a square region and count how many fall into a | |
# quarter-circle. The ratio of that count to the total number of darts | |
# is 1/4 * Pi! | |
# More information (and a cool graphic) here: | |
# http://en.wikipedia.org/wiki/Monte_Carlo_method | |
# | |
# A classroom project by KidsCanCode - http://kidscancode.org/ | |
from random import random | |
import math |
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
font_name = pg.font.match_font('hack') | |
def draw_text(text, size, color, x, y, align="topleft"): | |
font = pg.font.Font(font_name, size) | |
text_surface = font.render(text, True, color) | |
text_rect = text_surface.get_rect(**{align: (x, y)}) | |
screen.blit(text_surface, text_rect) |
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
class Spritesheet: | |
# utility class for loading and cutting spritesheets | |
def __init__(self, filename): | |
self.spritesheet = pg.image.load(filename).convert_alpha() | |
def get_image_by_rect(self, x, y, w, h): | |
r = pg.Rect(x, y, w, h) | |
return self.spritesheet.subsurface(r) |
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
class Camera: | |
def __init__(self, width, height): | |
self.camera = pg.Rect(0, 0, width, height) | |
self.width = width | |
self.height = height | |
def apply(self, rect): | |
return rect.move(self.camera.topleft) | |
def update(self, target): |
OlderNewer