Skip to content

Instantly share code, notes, and snippets.

View GuyCarver's full-sized avatar

Guy Carver GuyCarver

  • Bethesda Game Studios
  • Maryland
View GitHub Profile
@GuyCarver
GuyCarver / templates.py
Last active August 29, 2015 14:02
Template script for pythonista
import ui
from time import sleep
import editor
import types
import console
'''
This script runs ok forever if it's the only script you run.
Other scripts may also be run if you only run this one once.
But if you run this 2 or more times any other script you try to run thereafter will lock up.
@GuyCarver
GuyCarver / mines.py
Created October 20, 2012 00:37
Pythonista mines game
from scene import *
import random
import console
from functools import partial
from sound import load_effect, play_effect
rows = 24
cols = 20
fsize = 20
plot_size = 32
@GuyCarver
GuyCarver / tank.py
Created November 24, 2012 21:57
Pythonista tank (without a game)
#Pythonista
# remote controlled tank without a game. Haven't figured out the gameplay yet.
# Use remote app https://gist.github.com/959c9fba8e1e0c04f898 to control the tank.
# Work in progress.
from time import clock
from scene import *
from sound import *
from struct import *
@GuyCarver
GuyCarver / Tankremote.py
Created November 25, 2012 09:00
Pythonista Remote Control for Pythonista Tank
#Pythonista
#For use with the rc tank in https://gist.github.com/4141545
#I run this on my iPhone to control the tank on my iPad.
from scene import *
from sound import *
from socket import *
from struct import *
@GuyCarver
GuyCarver / comments.py
Created November 25, 2012 10:24
Pythonista editor script to toggle comment of selected lines.
#Comment/Uncomment selected lines.
import editor
text = editor.get_text()
selection = editor.get_line_selection()
selected_text = text[selection[0]:selection[1]]
is_comment = selected_text.strip().startswith('#')
replacement = ''
for line in selected_text.splitlines():
@GuyCarver
GuyCarver / indent.py
Created November 25, 2012 10:27
Pythonista editor script to indent selected lines.
#indent selection
import editor
text = editor.get_text()
selection = editor.get_line_selection()
selected_text = text[selection[0]:selection[1]]
replacement = ''
for line in selected_text.splitlines():
replacement += '\t' + line + '\n'
@GuyCarver
GuyCarver / paste.py
Created November 25, 2012 10:31
Pythonista editor script to paste clipboard to buffer.
#paste clipboard to buffer.
import clipboard
import editor
cliptext = clipboard.get()
if cliptext != '':
text = editor.get_text()
selection = editor.get_selection()
selected_text = text[selection[0]:selection[1]]
replacement = cliptext + selected_text
@GuyCarver
GuyCarver / unindent.py
Created November 25, 2012 10:28
Pythonista editor script to unindent selected lines.
#unindent selection
import editor
text = editor.get_text()
selection = editor.get_line_selection()
selected_text = text[selection[0]:selection[1]]
replacement = ''
for line in selected_text.splitlines():
replacement += line[line.find('\t') + 1:] + '\n'
@GuyCarver
GuyCarver / confetti.py
Created December 1, 2012 05:54
confetti
# Modified Particles sample to show rotating rectangles.
import canvas
from scene import *
from random import random
from colorsys import hsv_to_rgb
from threading import Thread, Event
p_size = 64
mt = True
@GuyCarver
GuyCarver / Soldier.py
Created December 1, 2012 07:16
create Images directory if doesn't exist.
#example of animated frames for a character walk.
#downloads a soldier sprite sheet, cuts out frames for the walk cycles in 4 directions
# and animates the character walking in the direction controlled by gravity.
from scene import *
from PIL import Image
import urllib, os
start = Point(3, 1) #the sheet has 8 sets of characters in a 4x2 grid.
ssize = Size(96, 128)