Exemplo n.º 1
0
 def initArea(self, areas):
     #for all areas in the list areas
     for newAreaJson in areas:
         #initialise a new area
         newArea = Area(newAreaJson)
         self.areasDict[newAreaJson["name"]] = newArea
     self.initTree()
Exemplo n.º 2
0
def main():
    PI = 0.0

    print("Jay Ganesh.......")

    print("Enter Radius")

    No = float(input())

    print("Enter Value of PI")

    PI = float(input())

    ret = Area(No, PI)

    print("Radius of Circle is :", ret)
Exemplo n.º 3
0
  def __init__(self):
    self.__PLR_INIT_POS = [1,1]
    self.__PLR_INIT_FACE = Player.S
    
    self.__master = Tk()
    self.__w = Canvas(self.__master, width=WIN_WIDTH, height=WIN_HEIGHT)
    self.__w.pack()

    PLR_IMAGES = {Player.N:PhotoImage(file="images/playerN.gif"), \
              Player.S:PhotoImage(file="images/playerS.gif"), \
              Player.W:PhotoImage(file="images/playerW.gif"), \
              Player.E:PhotoImage(file="images/playerE.gif")}

    IMAGES = {"images/floor_dirt.gif":PhotoImage(file="images/floor_dirt.gif"), \
              "images/wall_rock.gif":PhotoImage(file="images/wall_rock.gif"), \
              "images/door_ladder_down.gif":PhotoImage(file="images/door_ladder_down.gif"), \
              "images/door_ladder_up.gif":PhotoImage(file="images/door_ladder_up.gif"), \
              "images/interactive_sign.gif":PhotoImage(file="images/interactive_sign.gif"), \
              "images/interactive_door.gif":PhotoImage(file="images/interactive_door.gif"), \
              "images/door_door.gif":PhotoImage(file="images/door_door.gif"), \
              "images/floor_door_mat.gif":PhotoImage(file="images/floor_door_mat.gif"), \
              "images/wall_black.gif":PhotoImage(file="images/wall_black.gif"), \
              "images/door_black.gif":PhotoImage(file="images/door_black.gif"), \
              "images/wall_table_S.gif":PhotoImage(file="images/wall_table_S.gif"), \
              "images/wall_table_N.gif":PhotoImage(file="images/wall_table_N.gif"), \
              "images/floor_indoors.gif":PhotoImage(file="images/floor_indoors.gif"), \
              "images/floor_door_mat.gif":PhotoImage(file="images/floor_door_mat.gif"), \
              }

    Square.INIT(self.__w, IMAGES)
    
    areaInfo = self.__loadArea()
    self.__myA = Area(areaInfo[1:])  #first row contains other data
    self.__processData(areaInfo[0])
    #self.__myA.initTest()
    
    self.__me = Player(self.__w, self.__PLR_INIT_POS, self.__PLR_INIT_FACE, PLR_IMAGES)
    Area.setPlayer(self.__me)

    self.__master.tk.call('tk', 'scaling', 2.0)
    #self.__oldUpdate()
    self.__update()
    self.__master.bind("<Key>", self.key)

    mainloop()

    '''
Exemplo n.º 4
0
    def Main(self):
        if self.quit == False:
            Handler = pygame.event.get()
            self.screen.fill((0, 0, 0))
            if self.state == "World":
                if self.area == None:
                    self.area = self.area = Area.Area(
                        Wself.player("default.dfile"), "teron")
                temp = self.area.step(Handler)
                if temp != None:
                    if temp[0] == "Fight":
                        self.arena = Arena.Arena(Bself.player("default.dfile"),
                                                 temp[1])
                        self.state = "Fight"
            if self.state == "Title":
                temp = self.Test.step(self.screen, Handler, [])
                if temp != None:
                    self.state = temp
            if self.state == "Fight":
                #if pygame.mixer.music.get_busy()==False:
                #	pygame.mixer.music.load('resc/Brainkrieg.ogg')
                #	pygame.mixer.music.play()
                temp = self.arena.step(self.screen, Handler)
                if temp != None:
                    t2 = []
                    for ID in temp:
                        for c in range(0, len(self.area.grid)):
                            if self.area.grid[c][
                                    0].group == "Bug" and self.area.grid[c][
                                        0].id == ID:
                                t2.append(c)
                    t2.sort(reverse=True)
                    for num in t2:
                        self.area.grid.pop(num)
                    del t2
                    self.state = "World"
                    #pygame.mixer.music.stop()

            self.fps = self.getFPS()
            self.screen.blit(self.font.render(self.fps, 0, (255, 0, 0)),
                             (0, 0))
            self.timer.tick(30)

            pygame.display.flip()
            self.getQuit(Handler)
        else:
            exit()
Exemplo n.º 5
0
def read_accidents_from_file(date_object):
    localisations = Area.Localisation.make_dictionary()
    intersections = Area.Intersection.make_dictionary()
    type_of_collisions = Details.TypeOfCollision.make_dictionary()

    try:
        with open('Accidents.csv', 'r', encoding="ISO-8859-1") as csv_file:
            reader = csv.reader(csv_file, delimiter=',')
            for row in reader:
                date = Date.Date(read_hour(row[4]), read_minute(row[4]),
                                 int(row[3]), int(row[2]), 2000 + int(row[1]))
                if date_object == date:
                    area = Area.Area(localisations[row[6]],
                                     intersections[row[7]])
                    details = Details.Details(type_of_collisions[row[9]])
                    accident = Accident.Accident(area, date, details)
                    accidents.append(accident)
    except FileNotFoundError:
        print("Cannot open a file")
Exemplo n.º 6
0
 def __init__(self):
     self.time = 0
     self.step = 0.003
     self.path = Path.Path()
     pos = Position.Position(0, 0)
     pos.y = 420
     self.path.add(pos, 0)
     pos.x = 90
     self.path.add(pos, 1)
     pos.x = 180
     self.path.add(pos, 1)
     pos.y = 180
     self.path.add(pos, 2)
     pos.x = 420
     self.path.add(pos, 2)
     pos.y = 500
     self.path.add(pos, 2)
     pos.x = 750
     self.path.add(pos, 2)
     pos.y = 330
     self.path.add(pos, 1)
     pos.x = 1250
     self.path.add(pos, 2)
     pos.x = 1350
     self.path.add(pos, 2)
     self.tower = Towers.Tower(0, 0)
     self.map = Map.Map()
     self.area = Area.Area()
     self.wave = Wave.Wave(self.path)
     self.wave.nextWave()
     self.score = Score.Score()
     self.shop = Shop.Shop()
     self.isSetupDone = False
     self.setupTime = 0
     self.newTower = False
     self.newTowerType = 0
     self.enemies = pygame.sprite.Group()
     self.towerList = list()
     self.avg = list()
     self.timer = 0
     self.startTimer = False
Exemplo n.º 7
0
def main():
    ##COMMENT OUT LINE IN __init__ OF Square CLASS BEFORE RUNNING
    Square.INIT(0)
    me = Player([2, 2])
    Area.setPlayer(me)
    myA = Area()
    myA.initTest()

    print(myA)
    inp = input("What would you like to do? [w,a,s,d] [q]")
    while inp != "q":
        if inp == "w":
            me.setFacing(Player.N)
            me.move((-1, 0))
            ##print("u" + str(me.getCurPos()))
            if myA.getSquare(me.getCurPos()).isWall():
                print("moving back now")
                me.move((1, 0))
        elif inp == "s":
            me.setFacing(Player.S)
            me.move((1, 0))
            ##print(me.getCurPos())
            if myA.getSquare(me.getCurPos()).isWall():
                me.move((-1, 0))
        elif inp == "a":
            me.setFacing(Player.E)
            me.move((0, -1))
            ##print(me.getCurPos())
            if myA.getSquare(me.getCurPos()).isWall():
                me.move((0, 1))
        elif inp == "d":
            me.setFacing(Player.W)
            me.move((0, 1))
            ##print(me.getCurPos())
            if myA.getSquare(me.getCurPos()).isWall():
                me.move((0, -1))
        if myA.getSquare(me.getCurPos()).isDoor():
            me.setCurPos(myA.getSquare(me.getCurPos()).getLoc2())

        print(myA)
        inp = input("What would you like to do? [w,a,s,d] [q]")
Exemplo n.º 8
0
import Area

area = Area.Area(Area.Localisation.Out_of_agglomeration,
                 Area.Intersection.Intersection_in_X)

#properties test
assert area.localisation == Area.Localisation.Out_of_agglomeration
assert area.intersection == Area.Intersection.Intersection_in_X

#setters test
area.localisation = Area.Localisation.In_built_up_areas
area.intersection = Area.Intersection.Out_of_intersection

assert area.localisation == Area.Localisation.In_built_up_areas
assert area.intersection == Area.Intersection.Out_of_intersection
Exemplo n.º 9
0
import Area
import Car

if __name__ == "__main__":

    circuleArea = Area.Area(10)
    print("圓面積:", circuleArea.getArea())

    myCar = Car.Car()
    myCar.setColor("Blue")
    myCar.setMark("BMW")

    print("車子的顏色:", myCar.color)
    print("車子的品牌:", myCar.mark)
import Accident
import Area
import Date
import Details

object = Accident.Accident(
    Area.Area(Area.Localisation.In_built_up_areas,
              Area.Intersection.Out_of_intersection),
    Date.Date(12, 30, 5, 11, 2018),
    Details.Details(Details.TypeOfCollision.Multiple_collisions))

#properties test
assert object.area.localisation == Area.Localisation.In_built_up_areas
assert object.area.intersection == Area.Intersection.Out_of_intersection
assert object.date == Date.Date(12, 30, 5, 11, 2017)
assert object.details == Details.Details(
    Details.TypeOfCollision.Multiple_collisions)

#setters test
object.area = Area.Area(Area.Localisation.Out_of_agglomeration,
                        Area.Intersection.Out_of_intersection)
object.date = Date.Date(11, 50, 28, 2, 2017)
object.details = Details.Details(Details.TypeOfCollision.By_the_side)
assert object.area.localisation == Area.Localisation.Out_of_agglomeration
assert object.date == Date.Date(11, 50, 28, 2, 2017)
assert object.details == Details.Details(Details.TypeOfCollision.By_the_side)