Skip to content

Instantly share code, notes, and snippets.

@hortonew
hortonew / ubuntu-graphics-fix-1204
Last active December 16, 2015 01:59
Fix graphics issues in Ubuntu
http://askubuntu.com/questions/41681/blank-screen-after-installing-nvidia-restricted-driver
Remove everything to do with the Nvidia proprietary drivers.
sudo nvidia-settings --uninstall
sudo apt-get remove --purge nvidia*
Start from scratch.
sudo apt-get remove --purge xserver-xorg-video-nouveau xserver-xorg-video-nv
Reinstall all the things!
@hortonew
hortonew / ubuntu-phone
Created April 10, 2013 13:49
Ubuntu Phone SDK
sudo add-apt-repository ppa:canonical-qt5-edgers/qt5-proper && sudo add-apt-repository ppa:ubuntu-sdk-team/ppa && sudo apt-get update && sudo apt-get install ubuntu-sdk notepad-qml
@hortonew
hortonew / pyglet8_singleSound.py
Last active December 11, 2015 10:58
Pyglet - Play Single Sound
import pyglet
from pyglet.window import key
#Put sound files in a folder called "resources"
pyglet.resource.path = ['resources']
pyglet.resource.reindex()
#Create sound object for laser
screen = pyglet.window.Window(800,600)
laser = pyglet.resource.media('laser.wav')
@hortonew
hortonew / pygame8_singleSound.py
Last active December 11, 2015 10:58
Pygame - Play Single Sound
import pygame, sys, os
from pygame.locals import *
running = True
pygame.init()
screen = pygame.display.set_mode((800,600))
clock = pygame.time.Clock()
#Create path to sound file
mypath = os.path.dirname( os.path.realpath( __file__) )
@hortonew
hortonew / pyglet7_mouseHandling.py
Last active December 10, 2015 23:18
Pyglet - Mouse Handling
import pyglet
screen = pyglet.window.Window(800, 600)
@screen.event
def on_mouse_motion(x, y, dx, dy):
#print current mouse position
print x,y
@screen.event
@hortonew
hortonew / pygame7_mouseHandling.py
Last active December 10, 2015 23:18
Pygame - Mouse Handling
import pygame, sys
running = True
pygame.init()
screen = pygame.display.set_mode((800,600))
clock = pygame.time.Clock()
def handleEvents():
for event in pygame.event.get():
#print current mouse position
@hortonew
hortonew / pyglet5_imageText.py
Last active December 10, 2015 23:09
Pyglet - Sprite image and Text label
import pyglet
#index all resources. Resources folder must be on same level as this file.
pyglet.resource.path = ['resources']
pyglet.resource.reindex()
#create window object
screen = pyglet.window.Window(800, 600)
#create player object. Player image must be in resource folder.
@hortonew
hortonew / pyglet6_batchGroup.py
Last active December 10, 2015 23:09
Pyglet - Batch Group
import pyglet
#index all resources
pyglet.resource.path = ['resources']
pyglet.resource.reindex()
#create window object
screen = pyglet.window.Window(800, 600)
#create batch group to put all objects in
@hortonew
hortonew / pygame6_imageGroup.py
Last active December 10, 2015 23:09
Pygame - Image group
import pygame, sys, os
running = True
pygame.init()
screen = pygame.display.set_mode((800,600))
clock = pygame.time.Clock()
#calculate current path + location of player image
mypath = os.path.dirname( os.path.realpath( __file__) )
p_path = os.path.join(mypath, 'player.png')
@hortonew
hortonew / pygame5_imageText.py
Last active December 10, 2015 23:09
Pygame - Sprite image and Text label
import pygame, sys, os
running = True
pygame.init()
screen = pygame.display.set_mode((800,600))
clock = pygame.time.Clock()
#calculate current path + location of player image. Image must be on same level as this file
mypath = os.path.dirname( os.path.realpath( __file__) )
p_path = os.path.join(mypath, 'player.png')