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 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. |
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 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 |
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
#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 * |
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
#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 * |
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
#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(): |
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
#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' |
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
#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 |
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
#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' |
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
# 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 |
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
#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) |
OlderNewer