daily pastebin goal
79%
SHARE
TWEET

Untitled

a guest Jan 14th, 2018 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from kivy.app import App
  2. from kivy.uix.widget import Widget
  3. from kivy.uix.label import Label
  4. from kivy.core.window import Window
  5. from kivy.lang import Builder
  6. from kivy.clock import Clock
  7. from kivy.uix.boxlayout import BoxLayout
  8. from kivy.properties import NumericProperty
  9. from kivy.properties import Property
  10. from kivy.graphics import Rectangle
  11.  
  12. from volta import Volta
  13. from moto import Moto
  14. from motofantasma import MotoFantasma
  15. from minimapa import MiniMapa
  16.  
  17. """Per recollir la instanciacio en memoria de les classes definides a l'arxiu
  18. .kv es fa servir 'self.root.ids.' mes el valor de l'atribut 'id' corresponent,
  19. que apareix a l'arxiu .kv."""
  20.  
  21. class MyApp(App):
  22.     def build(self):
  23.         #Window.fullscreen=True
  24.         Window.size=(1360,768)
  25.         Window.bind(on_key_down=self.keydown)
  26.         Clock.schedule_interval(self.update, 1.0/fps)
  27.         return Builder.load_file('main.kv')
  28.  
  29.     def update(self,timestep):
  30.         moto=self.root.ids.moto
  31.         motofantasma=self.root.ids.motofantasma
  32.         minimapa=self.root.ids.minimapa
  33.  
  34.         if moto.currentFrame+1<=v.time*fps: #mentres no acabi el temps
  35.             moto.angle=v.array[moto.currentFrame][0]
  36.             minimapa.source=v.sections[moto.currentSection]
  37.  
  38.             if moto.currentFrame>0 and v.array[moto.currentFrame-1][1]!=v.array[moto.currentFrame][1]:
  39.                 moto.currentSection+=1
  40.                
  41.             moto.currentFrame+=1
  42.         moto.currentSection=0
  43.  
  44.     def keydown(self,*args):
  45.         print "a"
  46.         #if self.root.ids.motofantasma.opacity==1
  47.            
  48.  
  49. if __name__=='__main__':
  50.     fps=25.0
  51.     nvoltes=1
  52.     #motofantasma.switch()
  53.    
  54.     f=open("circuit1.txt","r")
  55.  
  56.     v=Volta(nvoltes,int(f.readline())) #(nombre de voltes, temps que dura una volta)
  57.     v.sections.append('img/'+f.name[:-4]+'-0.png')
  58.    
  59.     l=f.readline()
  60.     l=l.split(',')
  61.    
  62.     while l[0]!='':
  63.         v.array.append([int(l[0]),int(l[1])])
  64.        
  65.         if int(l[1])!=len(v.sections)-1:
  66.             v.sections.append('img/'+f.name[:-4]+'-'+str(len(v.sections))+'.png')
  67.  
  68.         l=f.readline()
  69.         l=l.split(',')
  70.  
  71.     x=0
  72.  
  73.     while nvoltes>1:
  74.         while x<v.time*fps:
  75.             v.array.append(v.array[x])
  76.             x+=1
  77.         nvoltes-=1
  78.         x=0
  79.        
  80.     f.close()          
  81.     MyApp().run()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top