Showing posts with label code. Show all posts
Showing posts with label code. Show all posts

Sunday, October 23, 2011

Boilerzerker features

Here's a quick list of the essential features to be included in Boilerzerker. Sorted by what is currently implemented and what will be implemented.


Implemented:

  • Physics simulation
    • collision
    • thrusters/movement
  • Moving Body
  • Steam Cannon
  • Animation
  • Editable Players
    • Robot Editor
  • Gamestates
    • Title Menu
    • Host Game
    • Connect to Game
    • Editor
To Come:
  • 4 Player Networking
  • Main Server for host list
  • PowerUps
  • Special Weapons
  • Destroy-able environment
  • Better Robot Editor
    • Color Selection
    • Persistent data(doesn't erase when you close the game)

Friday, December 14, 2007

Sweaters

Thomas: class Vector(object):
def __init__(self, a=0, b=0 ):
if _is_numeric(a):
self.x = a
self.y = b
else:
self.x = b[0] - a[0]
self.y = b[1] - a[1]
def __getitem__(self, index):
if index == 0:
return self.x
elif index == 1:
return self.y
else:
raise IndexError
def __add__(self, other):
return Vector(self.x + other.x, self.y + other.y)
def __sub__(self, other):
return Vector(self.x - other.x, self.y - other.y)
def __mul__(self, other):
try:
other = other - 0
except:
raise TypeError, "Only scalar multiplication is supported."
return Vector( other * self.x, other * self.y )
def __rmul__(self, other):
return self.__mul__(other)
def __div__(self, other):
return Vector( self.x / other, self.y / other )
def __neg__(self):
return Vector(-self.x, -self.y)
def __abs__(self):
return self.length()
def __repr__(self):
return '(%s, %s)' % (self.x, self.y)
def __str__(self):
return '(%s, %s)' % (self.x, self.y)
def dot(self, vector):
return self.x * vector.x + self.y * vector.y
def cross(self, vector):
return self.x * vector.y - self.y * vector.x
def length(self):
return math.sqrt( self.dot(self) )
def perpindicular(self):
return Vector(-self.y, self.x)
def unit(self):
return self / self.length()
def projection(self, vector):
k = (self.dot(vector)) / vector.length()
return k * vector.unit()
def angle(self, vector=None):
if vector == None:
vector = Vector(1,0)
return math.acos((self.dot(vector))/(self.length() * vector.length()))
def angle_in_degrees(self, vector=None):
return (self.angle(vector) * 180) /math.pi
def re
that helps
i googled that!
alright, time to knit some sweaters
later
me: laters

Tuesday, December 11, 2007

Dragon Starver: The Beginning of Starvation



import sys, os
import pygame
from pygame.locals import *
from cgkit.cgtypes import vec3

def load_image(name, colorkey=None):

fullname = os.path.dirname(sys.argv[0])
fullname = os.path.join(fullname, 'data')
fullname = os.path.join(fullname, name)
try:
image = pygame.image.load(fullname)
except pygame.error, message:
print 'Cannot load image:', fullname
raise SystemExit, message
image = image.convert()
if colorkey is not None:
if colorkey is -1:
colorkey = image.get_at((0,0))
image.set_colorkey(colorkey, RLEACCEL)
return image

class Spritesheet:
def __init__(self, filename):
self.sheet = pygame.image.load(filename).convert()
def imgat(self, rect, colorkey = None):
rect = Rect(rect)
image = pygame.Surface(rect.size).convert()
image.blit(self.sheet, (0, 0), rect)
if colorkey is not None:
if colorkey is -1:
colorkey = image.get_at((0, 0))
image.set_colorkey(colorkey, RLEACCEL)
return image
def imgsat(self, rects, colorkey = None):
imgs = []
for rect in rects:
imgs.append(self.imgat(rect, colorkey))
return imgs

class AnimatedSprite:
def __init__(self, images, rect):
self.images = images

class Dragon:
def __init__(self):
self.surface = load_image("Dragon.bmp", (255,255,255))
self.pos = vec3(0,0,0)

def main():
pygame.init()

screen = pygame.display.set_mode((1024, 768),1)
pygame.display.set_caption('Dragon Starver')

fnt = pygame.font.Font(pygame.font.get_default_font(),18)

back = pygame.Surface((1024,768),1)
back = back.convert()
back.fill((200,200,200))

keys = {K_a:False,K_d:False,K_w:False,K_s:False}

dragon = Dragon();

while True:
for event in pygame.event.get():
if event.type == QUIT:
sys.exit(0)
elif event.type == KEYDOWN:
keys[event.key] = True
elif event.type == KEYUP:
keys[event.key] = False

if keys[K_a]:
dragon.pos.x -= 1
if keys[K_d]:
dragon.pos.x += 1
if keys[K_w]:
dragon.pos.y -= 1
if keys[K_s]
code to load images, and pull images off of a sprite sheet
and it moves a dragon around on the screen
Sent at 4:58 PM on Tuesday
me: sweet
haha
Sent at 5:15 PM on Tuesday
me: meh
took me a while because i haven't actually opened Flash before
but i have a little placeholder
do you need transparency in the image?
it's a bmp right now
Sent at 5:30 PM on Tuesday
Thomas's new status message - I'm not here right now 5:36 PM
Thomas: I can do transparency on bitmaps now
didnt you read the code!
Sent at 5:55 PM on Tuesday
me: nope
haha
sorry
i will now
though
hang on