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
# coding: utf-8 | |
''' | |
NOTE: This requires Pythonista 3 | |
Demo of a custom ui.View subclass that embeds a native map view using MapKit (via objc_util). Tap and hold the map to drop a pin. | |
The MapView class is designed to be reusable, but it doesn't implement *everything* you might need. I hope that the existing methods give you a basic idea of how to add new capabilities though. For reference, here's Apple's documentation about the underlying MKMapView class: http://developer.apple.com/library/ios/documentation/MapKit/reference/MKMapView_Class/index.html | |
adapted from original code by omz |
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 | |
import random | |
from math import radians | |
import time | |
from functools import partial | |
class Die(ui.View): | |
def __init__(self,faces='ABCDEF',*args,**kwargs): | |
self.faces=faces | |
self._face_idx=0 | |
ui.View.__init__(self,*args,**kwargs) |
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, random | |
from functools import partial | |
colors=['salmon','orange','yellow','turquoise','gray','white'] | |
N=4 #size if grid | |
dicestr='AACIOT,ABILTY,ABJMOQ,ACDEMP,ACELRS,ADENVZ,AHMORS,BIFORX,DENOSW,DKNOTU,EEFHIY,EGKLUY,EGINTV,EHINPS,ELPSTU,GILRUW'.split(',') | |
dice=[[face if not face=='Q' else 'Qu' for face in die ] for die in dicestr] |
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, random | |
from functools import partial | |
colors=['salmon','orange','yellow','turquoise','gray','white'] | |
N=4 #size if grid | |
def animate_button(button,num_rolls): | |
''' returns a callable, which when called will ui.animate to change title and color, with a recursive completion for a total of num_rolls''' | |
def ani(): | |
i=random.randrange(6) | |
button.title=str(i+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 ui, random | |
from functools import partial | |
colors=['salmon','orange','yellow','turquoise','gray','white'] | |
N=4 #size if grid | |
def animate_button(button,num_rolls): | |
''' returns a callable, which when called will ui.animate to change title and color, with a recursive completion for a total of num_rolls''' | |
def ani(): | |
i=random.randrange(6) | |
button.title=str(i+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 ui, random | |
from functools import partial | |
colors=['salmon','orange','yellow','turquoise','gray','white'] | |
def animate_button(button,num_rolls): | |
''' returns a callable, which when called will ui.animate to change title and color, with a recursive completion for a total of num_rolls''' | |
def ani(): | |
i=random.randrange(6) | |
button.title=str(i+1) | |
button.bg_color=colors[i] | |
def finish(): |
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 very simple drawing 'app' that demonstrates | |
custom views and saving images to the camera roll. | |
''' | |
import ui | |
import photos | |
import console | |
# The PathView class is responsible for tracking |
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
# coding: utf-8 | |
''' | |
Part 3 -- Walk Cycle and Sound Effects 🏃 | |
In the previous part, our little alien moved left and right, but it all looked a bit unnatural. It might be different for aliens, but we usually don't just slide on the ground without moving our feet, while always looking in the same direction... | |
We're going to add a very simple walk cycle animation in this part -- and while we're at it, some footstep sounds too. | |
The changes in this part are numbered. You can navigate between them using the popup menu that appears when you tap the filename. | |
''' |
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
# coding: utf-8 | |
''' | |
Part 3 -- Walk Cycle and Sound Effects 🏃 | |
In the previous part, our little alien moved left and right, but it all looked a bit unnatural. It might be different for aliens, but we usually don't just slide on the ground without moving our feet, while always looking in the same direction... | |
We're going to add a very simple walk cycle animation in this part -- and while we're at it, some footstep sounds too. | |
The changes in this part are numbered. You can navigate between them using the popup menu that appears when you tap the filename. | |
''' |
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 math | |
class myscene(Scene): | |
def setup(self): | |
a=SpriteNode('plf:LaserPurple') | |
self.add_child(a) | |
self.a=a | |
a.position=(0,300) | |
a.vel=[180,120] |