Ejemplo n.º 1
0
 def __init__(self):
     points = [Point(0, 2), Point(1, -1), Point(0, 0), Point(-1, -1)]
     self.life = None
     self.max_life = 100
     self.damage = 10
     self.motion = Motion([0, 0])
     self.displacement = [Motion([0, 0]), Motion([0, 0])]
     Form.__init__(self, points)
Ejemplo n.º 2
0
 def __init__(self,position,**kwargs):
     """Create a brick using its position."""
     points=self.getCornersPointsFromPosition(position)
     form=Form(points)
     form.makeSparse()
     form=MaterialForm.createFromForm(form)
     #material_points=[MaterialPoint.createFromPoint(point) for point in points]
     super().__init__(form.getMaterialPoints(),kwargs)
Ejemplo n.º 3
0
 def startForm(self, screen_position, window):
     """Start a new form to create using screen_position and window."""
     position = self.getFromScreen(screen_position, window)
     point = Point(position)
     self.selection = len(self.forms)
     self.forms.append(Form([point]))
Ejemplo n.º 4
0
from mypoint import Point
from myform import Form
from myvector import Vector
from mywindow import Window

from random import randint

window=Window()
wsx,wsy=window.size
X=wsx//4
Y=wsy//4

posAlea=lambda :[randint(X,3*X),randint(Y,3*Y)]


f1=Form([Point(*posAlea()) for i in range(5)])
f1=f1.getSparse()
f2=Form([Point(*posAlea()) for i in range(5)])
f2=f2.getSparse()

#f1.points[0].color=(255,0,0)
#f1.points[1].color=(255,0,0)

while window.open:
    window.check()
    window.clear()
    f1.rotate(0.01,f1[0])
    #f1.rotate(-0.01)
    f2.rotate(0.02,f1[1])
    f2.rotate(-0.03)
    f1.show(window)
Ejemplo n.º 5
0
 def __init__(self):
     points = [Point(0, 10), Point(10, -10), Point(-10, -10)]
     self.life = None
     self.max_life = 100
     self.damage = 10
     Form.__init__(self, points)
Ejemplo n.º 6
0
from myform import Form
from mypoint import Point


class Set:
    def __init__(self, forms):
        self.forms = forms

    def move(self):
        pass

    def control(self):
        pass


if __name__ == "__main__":
    forms = [
        Form([
            Point(random.randint(-10, 10), random.randint(-10, 10))
            for i in range(10)
        ]) for i in range(3)
    ]
    set = Set(forms)
    surface = Surface()
    while surface.open:
        surface.check()
        set.control()
        surface.clear()
        set.show()
        surface.flip()
Ejemplo n.º 7
0
from mypoint import Point
from myform import Form
from myvector import Vector

import random
import time

if __name__ == "__main__":
    window = Surface2()
    p1 = Point(15, 62)
    p2 = Point(250, 400)
    p3 = Point(800, 500)
    p4 = Point(400, 400, color=(0, 255, 0))
    points = [p1, p3, p2, p4]
    f = Form([
        Point(random.randint(-10, 10), random.randint(-10, 10))
        for i in range(10)
    ])
    #f.show(window)
    f2 = f.getSparse()
    p1.show(window)
    p2.show(window)
    v = Vector(p2[0] - p1[0], p2[1] - p1[1], color=(255, 0, 0))
    center = f2.center()
    while window.open:
        window.check()
        window.clear()
        window.draw.control()
        window.draw.show()
        #v.rotate(0.1)
        v.show(center, window)
        f2.rotate(0.1)
Ejemplo n.º 8
0
#Indeed the surface was designed to answer all the needs of the clients as if it
#was a window but is in reality a completely different type using somekind of
#kernel pattern using only a true window as a attribute and being a intermediary.
#This intermediary is necessary in order to change the coordonnate system of the window.
#It is pivotal that all the coordonnates involved in future programs remain in plane's
#coordonnates' system for simplicity.
wsx, wsy = window.draw.window.size
X = wsx // 4
Y = wsy // 4

#posAlea=lambda :[randint(X,3*X),randint(Y,3*Y)] #Obsolete
#posAlea=lambda:(randint(-5,5),randint(-5,5))

#f1=Form([Point(*posAlea()) for i in range(5)],fill=True) #Obsolete
#f1=f1.getSparse()
f1 = Form.random(5, -10, 10)
#f2=Form([Point(*posAlea()) for i in range(5)])
#f2=f2.getSparse()
f2 = Form.random(5, -10, 10)

#f1.points[0].color=(255,0,0)
#f1.points[1].color=(255,0,0)

while window.open:
    window.check()
    window.clear()
    window.show()
    window.control()
    f1.rotate(0.01, f1[0])
    #f1.rotate(-0.01)
    f2.rotate(0.02, f1[1])