Skip to content

Instantly share code, notes, and snippets.

View Torxed's full-sized avatar

Anton Hvornum Torxed

View GitHub Profile
from game import gamehandle
from file2 import givexp
def main():
print('1) give xp')
print('2) give 500 xp')
donow = input()
if donow == '1':
givexp(200) #this is in File2.py
if donow == '2':
gamehandle.give_xp(500)
@Torxed
Torxed / File2.py
Last active August 29, 2015 14:03
from game import gamehandle
def givexp(ammount):
gamehandle.load_variables()
gamehandle.give_xp(ammount)
@Torxed
Torxed / game.py
Last active August 29, 2015 14:03
import pickle
class Game(object):
def __init__(self):
self.experience = 0
self.health = 0
self.loadedFromDisk = False
def give_xp(self, given_xp):
self.experience += given_xp
def save_variables(self):
with open('game.dump', 'wb') as fh:
import pickle
gameVars = {'health' : 100, 'stamina' : 100} # 100% on both
print('Current health is:', gameVars['health'])
gameVars['health'] -= 25
pickle.dump(gameVars, open('game.dump', 'wb'))
del(gameVars)
try:
# Part of my main class more often than not,
# this will do the actual drawing of lines
def draw_line(xy, dxy, color=(0.2, 0.2, 0.2, 1)):
glColor4f(color[0], color[1], color[2], color[3])
glBegin(GL_LINES)
glVertex2f(xy[0], xy[1])
glVertex2f(dxy[0], dxy[1])
glEnd()
# How to call it to get a two-line-thickness healthbar.
@Torxed
Torxed / test.py
Last active August 29, 2015 14:02
A short test in lookup-times on DNS records.
#!/usr/bin/python3
from socket import gethostbyname
from time import *
domains = ('cobra.com', 'tiger.com', 'ferrarri.com', 'amazon.com', 'thelongestdomainnameintheworldandthensomeandthensomemoreandmore.com', 'sockervadd.se')
for domain in domains:
start = time()
## This instructs the OS to do a DNS lookup.
gethostbyname(domain)
end = time()
@Torxed
Torxed / test.py
Created May 8, 2014 11:39
Small Pyglet class based graphical application that rotates an image
import pyglet
from pyglet.gl import *
from collections import OrderedDict
from time import time
from os.path import abspath
class House(pyglet.sprite.Sprite):
def __init__(self):
self.texture = pyglet.image.load(abspath('./image.png'))
super(House, self).__init__(self.texture)
from threadimg import *
class worker(Thread):
def __init__(self, filehandle, password, crackflag):
Thread.__init__(self)
self.fh = filehandle
self.pwd = password
self.cracked = crackflag
self.start()
name of display: :0
display: :0 screen: 0
direct rendering: Yes
server glx vendor string: NVIDIA Corporation
server glx version string: 1.4
server glx extensions:
GLX_ARB_create_context, GLX_ARB_create_context_profile,
GLX_ARB_create_context_robustness, GLX_ARB_fbconfig_float,
GLX_ARB_multisample, GLX_EXT_buffer_age,
GLX_EXT_create_context_es2_profile, GLX_EXT_create_context_es_profile,
@Torxed
Torxed / hardware.txt
Last active December 20, 2015 00:49
My hardware specs
Computer
********
Summary
-------
-Computer-
Processor : 8x Intel(R) Core(TM) i7-2760QM CPU @ 2.40GHz
Memory : 16394MB (1352MB used)