Skip to content

Commit

Permalink
2.0
Browse files Browse the repository at this point in the history
2.0
  • Loading branch information
kerem3338 authored Oct 30, 2021
1 parent 5da34f0 commit 1e8065e
Showing 1 changed file with 65 additions and 10 deletions.
75 changes: 65 additions & 10 deletions animator.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,95 @@
import os
import sys
import time

version = "1.0"
from playsound import playsound
#["foo", "bar", "baz"].index("bar")
class Animator:
def __init__(self, sleep=1.0):
self.scene_count = 0
self.scenes_count = 0
self.scenes = []
self.sleep = sleep
self.version = "2.0"

def version(self):
return "1.0"
return self.version

def lenght(self):
return self.scenes_count*self.sleep

def scene(self, scene):
"""add new scene"""
self.scenes.append(scene)
self.scene_count += 1
self.scenes_count += 1

def shape(self, shape, position=None):
square = "##\n##"
if shape == "square":
return square
else:
print(f"InvalidShape: {shape}")

def copy_last(self, copy_count=None):
if copy_count is None:
last_scene = len(self.scenes)-1
self.scenes.append(self.scenes[last_scene])
self.scenes_count +=1
else:
for i in range(copy_count):
self.scenes_count += 1
last_scene = len(self.scenes)-1
self.scenes.append(self.scenes[last_scene])

def copy_from_id(self, id, copy_count=None):
if copy_count is None:
scene = self.scenes[id]
self.scenes.append(scene)
self.scenes_count += 1
else:
for i in range(copy_count):
self.scenes_count += 1
self.scenes.append(self.scenes[id])


def play_sound(self, soundfile, background:bool=True):
if background is True:
playsound(soundfile, False)
elif background is False:
playsound(soundfile)
else:
print(f"InvalidArgument: {backgound}")

def scene_from_id(self, id):
print(self.scenes[id])

def list_scenes(self):
for i in range(len(self.scenes)):
print(self.scenes[i])

def scenes_count(self):
return scene_count
"""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"""
return self.scenes_count

def set_sleep(self,sleep):
self.sleep = sleep

def clear(self):
"""clear screen"""
if os.name == "nt":

os.system("cls")
else:
os.system("clear")

def play(self):
for i in range(len(self.scenes)):
self.clear()
print(self.scenes[i])
time.sleep(self.sleep)
self.clear()
def export(self, exportfile):
print("Yakında...")


def export_scenes(self, exportfile, encoding="utf8"):
with open(exportfile, "w", encoding=encoding) as exportfile:
exportfile.write("Created using Boip Animator {self.version}")
for i in range(len(self.scenes)):
exportfile.write("\n")
exportfile.write(self.scenes[i])

0 comments on commit 1e8065e

Please sign in to comment.