def __init__(self, px, py, image_sprite, groups=[]): #Call parent class Sprite self.groups = groups pygame.sprite.Sprite.__init__(self, self.groups) self.image = image_sprite self.rect = self.image.get_rect() self.body = body2d(px,py) self.hitbox = pygame.Rect(0,0,self.rect.w, self.rect.h)
def __init__(self, px, py, image_sprite, groups=[]): #Call parent class Sprite self.groups = groups pygame.sprite.Sprite.__init__(self, self.groups) self.image = image_sprite self.rect = self.image.get_rect() self.body = body2d(px,py) self.hitbox = pygame.Rect(0,0,self.rect.w, self.rect.h) self.active = False # Resistencia ar self.K = 0.5 * 1.2 * 0.02 * 0.1
import sys sys.path.append("../../modules") from mymath import * from physics.body2d import body2d import pygame pygame.init() screen = pygame.display.set_mode((400, 300)) done = False selectedMass = 0 body_list = [] body_list.append(body2d(100, 50)) body_list.append(body2d(200, 50)) body_list.append(body2d(300, 50)) # Font myfont = pygame.font.SysFont("monospace", 16) tx_instruction = myfont.render("Press A and D to select. Click to move", 0, (255, 0, 0)) tx_instruction2 = myfont.render("W and S to change mass. Space to add", 0, (255, 0, 0)) hide_font = False while not done: screen.fill((0, 0, 0)) for event in pygame.event.get(): if event.type == pygame.QUIT: done = True elif event.type == pygame.MOUSEBUTTONUP and selectedMass >= 0: