def DrawFlag(x,y): global SquareSize DrawCoveredSquare() BoxSize = SquareSize/3 color("gold") box(StartingX + SquareSize * x + SquareSize/2 - BoxSize/2,StartingY + SquareSize * y + SquareSize/2 - BoxSize/2, SquareSize/3,SquareSize/3) color("orange") rectangle(StartingX + SquareSize * x + SquareSize/2 - BoxSize/2,StartingY + SquareSize * y + SquareSize/2 - BoxSize/2, SquareSize/3,SquareSize/3)
def handle_frame(): global car1, car2, leftPressed, rightPressed, upPressed, downPressed, aPressed, sPressed, dPressed, wPressed, explosions, explosionCount color("white") box(0, 0, screen_width, screen_height) color("red") if leftPressed: car1.change_orientation(4) elif rightPressed: car1.change_orientation(-4) elif upPressed: car1.Acceleration += 0.01 if car1.Acceleration > 0.05: car1.Acceleration = 0.05 elif downPressed: if car1.Acceleration == 0: if car1.Acceleration < -0.05: car1.Acceleration = -0.05 else: car1.Acceleration -= 0.01 if aPressed: car2.change_orientation(4) elif dPressed: car2.change_orientation(-4) elif wPressed: car2.Acceleration += 0.01 if car2.Acceleration > 0.05: car2.Acceleration = 0.05 elif sPressed: if car2.Acceleration == 0: if car2.Acceleration < -0.05: car2.Acceleration = -0.05 else: car2.Acceleration -= 0.01 car1.update_speed() car2.update_speed() testCollisions() car1.draw_car("Foo") car2.draw_car("Bar") for i in range(0, explosionCount): if explosions[i] != None: if explosions[i].draw(): explosions[i] = None # for i in range (0, len(otherCars)): #Draw connected players cars # otherCars[i].draw() #Draw the map color("green") rectangle(outerWallX, outerWallY, outerWallWidth, outerWallHeight)
def stopButton(): global stopMinY,stopMaxY,stopMinX,stopMaxX color("red") rectangle((screen_width - 180), screen_height - 40, 150,30) text(screen_width - 85, screen_height - 35, "STOP") stopMinX = (screen_width - 180) stopMaxX = (screen_width - 30) stopMinY = (screen_height - 40) stopMaxY = (screen_height - 10) print stopMinX
def stopButton(): global stopMinY, stopMaxY, stopMinX, stopMaxX color("red") rectangle((screen_width - 180), screen_height - 40, 150, 30) text(screen_width - 85, screen_height - 35, "STOP") stopMinX = (screen_width - 180) stopMaxX = (screen_width - 30) stopMinY = (screen_height - 40) stopMaxY = (screen_height - 10) print stopMinX
def finishButtons(): global fbShown, chosen_color, p2cMinX, p2cMaxX, p2cMinY, p2cMaxY, p2wMinX, p2wMaxX, p2wMinY, p2wMaxY, p3cMinX, p3cMaxX, p3cMinY, p3cMaxY, p3wMinX, p3wMaxX, p3wMinY, p3wMaxY color("green") #P2 Correct rectangle((screen_width / 2) - 75, screen_height / 2, 150, 30) text((screen_width / 2) - 45, ((screen_height / 2) + 5), "P2 Correct") #P3 Correct rectangle((screen_width / 2) - 75, ((screen_height / 2) + 40), 150, 30) text((screen_width / 2) - 45, ((screen_height / 2) + 45), "P3 Correct") color("red") #P2 Wrong rectangle((screen_width / 2) + 95, screen_height / 2, 150, 30) text((screen_width / 2) + 125, ((screen_height / 2) + 5), "P2 Wrong") #P3 Wrong rectangle((screen_width / 2) + 95, ((screen_height / 2) + 40), 150, 30) text((screen_width / 2) + 125, ((screen_height / 2) + 45), "P3 Wrong") p2cMinX = ((screen_width / 2) - 75) p2cMaxX = ((screen_width / 2) + 75) p2cMinY = (screen_height / 2) p2cMaxY = (screen_height / 2) + 30 p2wMinX = ((screen_width / 2) + 95) p2wMaxX = ((screen_width / 2) + 245) p2wMinY = (screen_height / 2) p2wMaxY = ((screen_height / 2) + 30) p3cMinX = ((screen_width / 2) - 75) p3cMaxX = ((screen_width / 2) + 175) p3cMinY = ((screen_height / 2) + 40) p3cMaxY = ((screen_width / 2) + 70) p3wMinX = ((screen_width / 2) + 95) p3wMaxX = ((screen_width / 2) + 245) p3wMinY = ((screen_width / 2) + 40) p3wMaxY = ((screen_width / 2) + 70) fbShown = "true"
def finishButtons(): global p2cMinX,p2cMaxX,p2cMinY,p2cMaxY, p2wMinX, p2wMaxX, p2wMinY, p2wMaxY, p3cMinX, p3cMaxX, p3cMinY, p3cMaxY, p3wMinX, p3wMaxX, p3wMinY, p3wMaxY color("green") #P2 Correct rectangle((screen_width / 2) - 75, screen_height / 2, 150,30) text((screen_width / 2) - 45, ((screen_height / 2) + 5), "P2 Correct") #P3 Correct rectangle((screen_width / 2) - 75, ((screen_height / 2) + 40), 150,30) text((screen_width / 2) - 45, ((screen_height / 2) + 45), "P3 Correct") color("red") #P2 Wrong rectangle((screen_width / 2) + 95, screen_height / 2, 150,30) text((screen_width / 2) + 125, ((screen_height / 2) + 5), "P2 Wrong") #P3 Wrong rectangle((screen_width / 2) + 95, ((screen_height / 2) + 40), 150,30) text((screen_width / 2) + 125, ((screen_height / 2) + 45), "P3 Wrong") p2cMinX = ((screen_width / 2) - 75) p2cMaxX = ((screen_width / 2) + 75) p2cMinY = (screen_height / 2) p2cMaxY = (screen_height / 2) + 30 p2wMinX = ((screen_width / 2) + 95) p2wMaxX = ((screen_width / 2) + 245) p2wMinY = (screen_height / 2) p2wMaxY = ((screen_height / 2) + 30) p3cMinX = ((screen_width / 2) - 75) p3cMaxX = ((screen_width / 2) + 175) p3cMinY = ((screen_height / 2) + 40) p3cMaxY = ((screen_width / 2) + 70) p3wMinX = ((screen_width / 2) + 95) p3wMaxX = ((screen_width / 2) + 245) p3wMinY = ((screen_width / 2) + 40) p3wMaxY = ((screen_width / 2) + 70)
def drawToolbar(): tools = ["line","bold","circle","bird","stars","italics","triangle","hearts","eraser"] text (screen_width - 300, 10, "Toolbar:") rectangle(screen_width - 300,35,25,25) line(screen_width - 286, 40, screen_width - 286, 52) rectangle(screen_width - 275,35,25,25) box (screen_width - 264, 37, 5, 20) rectangle(screen_width - 250,35,25,25) spot (screen_width - 238, 47, 8) rectangle(screen_width - 225,35,25,25) text(screen_width - 219, 38, "B") rectangle(screen_width - 200,35,25,25) text(screen_width - 193, 38, "*") rectangle(screen_width - 175,35,25,25) text(screen_width - 165, 38, "/") rectangle(screen_width - 150,35,25,25) text(screen_width - 145, 38, "T") rectangle(screen_width - 125,35,25,25) text(screen_width - 120, 38, "H") rectangle(screen_width - 100,35,25,25) text(screen_width - 95, 38, "X")
def ToolBoxThickness(x, y, thicknesses, w, h): for t in thicknesses: spot(x + w / 2, y + h / 2, t) rectangle(x, y, w, h) y = y + h
def ToolBoxThickness (x,y,thicknesses,w,h): for t in thicknesses: spot(x + w/2, y + h/2, t) rectangle(x,y,w,h) y = y + h
from tealight.art import (color, line, spot, rectangle, circle, box, image, text, background) from tealight.art import (screen_width, screen_height) rectangle(30,3400