예제 #1
0
파일: karel.py 프로젝트: kvbik/robot
 def ocisluj(self, *velikost):
     # očíslování buněk města
     if len(velikost) == 0:
         ivel = 8
     else:
         ivel = velikost[0]
     livewires.forbid_movables()
     ivel = livewires.set_textsize(ivel)
     for i in range(self.svisle):
             for j in range(self.vodorovne):
                     livewires.move(*self.sour_pole(j, i)[:2])
                     livewires.text(str([j, i]))
     ivel = livewires.set_textsize(ivel)
     livewires.allow_movables()
예제 #2
0
파일: karel.py 프로젝트: kvbik/robot
    def zobraz(self):
        livewires.forbid_movables()
        # celé město obarvit pozadím - kvůli překreslování
        i = [self.x,self.y,
        self.x+self.vodorovne*(self.modul+self.tl_cary)+self.tl_cary,
        self.x+self.svisle*(self.modul+self.tl_cary)+self.tl_cary]
        i += [self.barva_pozadi,1]
        livewires.box(*i)
        # vodorovné čáry
        for i in range(self.svisle+1):
            livewires.box(self.x, self.y+i*(self.modul+self.tl_cary),self.x+self.tl_cary*(self.vodorovne+1)+self.modul*self.vodorovne-1, self.y+i*(self.modul+self.tl_cary)+self.tl_cary-1,self.barva_cary,1)
        livewires.allow_movables()
        # svislé čáry
        for i in range(self.vodorovne+1):
            livewires.box(self.x+i*(self.modul+self.tl_cary), self.y, self.x+i*(self.modul+self.tl_cary)+self.tl_cary-1, self.y+self.svisle*(self.tl_cary+self.modul)+self.tl_cary-1, self.barva_cary,1)
        livewires.allow_movables()

        # namaluj zdi (případně ostatní objekty)
        for irad in range(len(self.objekty)): 
            for islo in range(len(self.objekty[irad])):
                if "wall" in self.objekty[irad][islo]:
                    self.maluj_zed(islo, irad)
        self.je_videt = True
예제 #3
0
파일: karel.py 프로젝트: kvbik/robot
# -*- coding: utf-8 -*-

import livewires

#livewires.begin_graphics()
livewires.allow_movables()


class Robot():
    "Robot - říkejme mu třeba Kája"

    def __init__(self,*seznam_objektu):
        self.velikost = 100
        self.orientace = 0
        self.x = 200
        self.y = 200
        self.zobrobjekty = []
        self.je_videt = False
        if len(seznam_objektu)>0:
            self.objekty = seznam_objektu[0]
        else:
            self.objekty = []
            self.objekty = [["c",0,0,0.5,livewires.Colour.red,1],["c",0.1,0.18,0.08,livewires.Colour.black,1],["c",0.1,-0.18,0.08,livewires.Colour.black,1],["p",[0.1,0,0.3,-0.1,0.3,0.1],livewires.Colour.black,1,1],["b",0.38,-0.15,0.43,0.15,livewires.Colour.black,1]]
        self.delka_kroku = self.velikost
        # identifikace města, ve kterém se robot nachází
        self.mesto = False
        # je-li robot stavitelem města
        self.je_stavitel = False
        
    def zed_na_policku(self, *nastaveni):
        ized = False