Ejemplo n.º 1
0
Archivo: TT.py Proyecto: needstuff/Game
#       
#     pad.velocity = Vec2D(x, y)
#       
#     oldX = x
#     oldY = y

#     if y < 500 or y >=500:
#         y = 500
    pad.pos = Vec2D(x, y)
    

oldX = 0
oldY = 0

root = Tk()
cd = Physics()
width = height = 600
can = Canvas(root, bg="white", width=width, height=height)
renderer = Renderer(can)

circle = [Vec2D(10 * sqrt(3) / 2, 10 * .5), Vec2D(10 * sqrt(2) / 2, 10 * sqrt(2) / 2), Vec2D(10 * .5, 10 * sqrt(3) / 2), Vec2D(0, 10),
                Vec2D(10 * -.5, 10 * sqrt(3) / 2), Vec2D(10 * -sqrt(2) / 2, 10 * sqrt(2) / 2), Vec2D(10 * -sqrt(3) / 2, 10 * .5), Vec2D(-10, 0),
                 Vec2D(10 * -sqrt(3) / 2, 10 * -.5), Vec2D(10 * -sqrt(2) / 2, 10 * -sqrt(2) / 2), Vec2D(10 * -.5, 10 * -sqrt(3) / 2), Vec2D(0, -10),
                  Vec2D(10 * .5, 10 * -sqrt(3) / 2), Vec2D(10 * sqrt(2) / 2, 10 * -sqrt(2) / 2), Vec2D(10 * sqrt(3) / 2, 10 * -.5), Vec2D(10, 0)]
rect_vertices = [Vec2D(-10, -10), Vec2D(-10, 10), Vec2D(10, 10), Vec2D(10, -10)]
cir = RigidBody2D(circle, pos=Vec2D(150, 100), velocity=Vec2D(450, 300), angularVelocity=3, mass=100)
rect = RigidBody2D(rect_vertices, pos=Vec2D(300, 100), velocity=Vec2D(210, 380), angularVelocity=3, mass=1000)

pad_v = [Vec2D(-30, -10), Vec2D(-30, 10), Vec2D(30, 10), Vec2D(30, -10)]
pad = RigidBody2D(pad_v, pos=Vec2D(0, 0), inverseMass=0)
Ejemplo n.º 2
0
from Tkinter import *
import time
from UI.Renderer import *
from Vec2D import Vec2D
from Core import Physics
from RigidBody2D import RigidBody2D

width = height = 600
root = Tk()
cd = Physics()
can = Canvas(root, bg="white", width=width, height=height)
renderer = Renderer(can)
sidewidth = 20
vert_vertices = [Vec2D(-sidewidth/2,-height/2), Vec2D(-sidewidth/2,height/2), Vec2D(sidewidth/2,height/2), Vec2D(sidewidth/2,-height/2)]
hori_vertices = [Vec2D(-width/2 + 2*sidewidth, -sidewidth/2), Vec2D(-width/2+2*sidewidth, sidewidth/2), Vec2D(width/2-2*sidewidth, sidewidth/2), Vec2D(width/2-2*sidewidth, -sidewidth/2)]
tri_vertices = [Vec2D(-20,10), Vec2D(20,10), Vec2D(0,-100)]
sqr_vertices = [Vec2D(-10,-10), Vec2D(-10,10), Vec2D(10,10), Vec2D(10,-10)]
rect_vertices = [Vec2D(-60,-5), Vec2D(-60, 5), Vec2D(60, 5), Vec2D(60, -5)]
avatar_vertices = [Vec2D(-10, -20), Vec2D(-10, 20), Vec2D(40, 0)]
tri = RigidBody2D(tri_vertices,pos=Vec2D(200,200),velocity=Vec2D(10,10), angularVelocity=-2, inverseMass = 500, inertia = 2, muS = .2, muK = .09)
sqr1 = RigidBody2D(sqr_vertices, pos=Vec2D(400,400), velocity=Vec2D(-160,-160), angularVelocity=5, orientation = 0, inverseMass = 2500, inertia =.05,muS = .2, muK = .01)
sqr2 = RigidBody2D(sqr_vertices, pos=Vec2D(350,300), velocity=Vec2D(60,-60), angularVelocity=5, orientation = 0, inverseMass = 2500, inertia =.05, muS = .2, muK = .01)
rect1 = RigidBody2D(rect_vertices, pos=Vec2D(90, 200), velocity=Vec2D(20,-60), angularVelocity=1, orientation = 0, inverseMass = 600, inertia =6, muS = .25, muK = .04)
leftwall = RigidBody2D(vert_vertices, pos=Vec2D(sidewidth,height/2), inverseMass = 0,  inertia = 999999)
rightwall = RigidBody2D(vert_vertices, pos=Vec2D(width-sidewidth,height/2), inverseMass = 0,  inertia = 999999)
topwall = RigidBody2D(hori_vertices, pos =Vec2D(width/2, sidewidth), inverseMass = 0,  inertia = 999999)
bottomwall = RigidBody2D(hori_vertices, pos=Vec2D(width/2, height-sidewidth-50), inverseMass = 0, inertia = 999999, orientation=-.2)
divider1 = RigidBody2D(rect_vertices, pos=Vec2D(width- 100,height/2), inverseMass=0, orientation=.2, inertia = 999999)
divider2 = RigidBody2D(tri_vertices, pos=Vec2D(width/4,height/2), inverseMass=0, orientation=1.57,inertia = 999999)
avatar = RigidBody2D(avatar_vertices, pos = Vec2D(200,100), velocity=Vec2D(0,0),inverseMass=4000, inertia=.4, muS=.3, muK=.04, angularVelocity=0)
entities = [ rect1, tri, sqr1, sqr2, leftwall,rightwall,topwall, bottomwall, divider1, divider2, avatar]