Skip to content

Commit 1e8065e

Browse files
authored
2.0
2.0
1 parent 5da34f0 commit 1e8065e

File tree

1 file changed

+65
-10
lines changed

1 file changed

+65
-10
lines changed

animator.py

+65-10
Original file line numberDiff line numberDiff line change
@@ -14,40 +14,95 @@
1414
import os
1515
import sys
1616
import time
17-
18-
version = "1.0"
17+
from playsound import playsound
18+
#["foo", "bar", "baz"].index("bar")
1919
class Animator:
2020
def __init__(self, sleep=1.0):
21-
self.scene_count = 0
21+
self.scenes_count = 0
2222
self.scenes = []
2323
self.sleep = sleep
24+
self.version = "2.0"
25+
2426
def version(self):
25-
return "1.0"
27+
return self.version
28+
29+
def lenght(self):
30+
return self.scenes_count*self.sleep
31+
2632
def scene(self, scene):
2733
"""add new scene"""
2834
self.scenes.append(scene)
29-
self.scene_count += 1
35+
self.scenes_count += 1
36+
37+
def shape(self, shape, position=None):
38+
square = "##\n##"
39+
if shape == "square":
40+
return square
41+
else:
42+
print(f"InvalidShape: {shape}")
43+
44+
def copy_last(self, copy_count=None):
45+
if copy_count is None:
46+
last_scene = len(self.scenes)-1
47+
self.scenes.append(self.scenes[last_scene])
48+
self.scenes_count +=1
49+
else:
50+
for i in range(copy_count):
51+
self.scenes_count += 1
52+
last_scene = len(self.scenes)-1
53+
self.scenes.append(self.scenes[last_scene])
54+
55+
def copy_from_id(self, id, copy_count=None):
56+
if copy_count is None:
57+
scene = self.scenes[id]
58+
self.scenes.append(scene)
59+
self.scenes_count += 1
60+
else:
61+
for i in range(copy_count):
62+
self.scenes_count += 1
63+
self.scenes.append(self.scenes[id])
64+
65+
66+
def play_sound(self, soundfile, background:bool=True):
67+
if background is True:
68+
playsound(soundfile, False)
69+
elif background is False:
70+
playsound(soundfile)
71+
else:
72+
print(f"InvalidArgument: {backgound}")
73+
74+
def scene_from_id(self, id):
75+
print(self.scenes[id])
76+
3077
def list_scenes(self):
3178
for i in range(len(self.scenes)):
3279
print(self.scenes[i])
80+
3381
def scenes_count(self):
34-
return scene_count
82+
"""NOT:Sahne içinde kullanılırsa bulunduğu sahneyi eklemez örnek: eğer projenizde 6 sahne varsa 5 sahne gösterecektir eğer sahnenin içinde kullanmazsanız sahne sayınızı normal bir şekilde gösterecektir"""
83+
return self.scenes_count
84+
3585
def set_sleep(self,sleep):
3686
self.sleep = sleep
37-
87+
3888
def clear(self):
3989
"""clear screen"""
4090
if os.name == "nt":
4191

4292
os.system("cls")
4393
else:
4494
os.system("clear")
95+
4596
def play(self):
4697
for i in range(len(self.scenes)):
4798
self.clear()
4899
print(self.scenes[i])
49100
time.sleep(self.sleep)
50101
self.clear()
51-
def export(self, exportfile):
52-
print("Yakında...")
53-
102+
103+
def export_scenes(self, exportfile, encoding="utf8"):
104+
with open(exportfile, "w", encoding=encoding) as exportfile:
105+
exportfile.write("Created using Boip Animator {self.version}")
106+
for i in range(len(self.scenes)):
107+
exportfile.write("\n")
108+
exportfile.write(self.scenes[i])

0 commit comments

Comments
 (0)