diff --git a/Kivy/tech-with-tim/main.py b/Kivy/tech-with-tim/main.py new file mode 100755 index 0000000..bbc94d5 --- /dev/null +++ b/Kivy/tech-with-tim/main.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python +import kivy +from kivy.app import App +from kivy.uix.label import Label +from kivy.uix.gridlayout import GridLayout +from kivy.uix.textinput import TextInput + +class MyGrid(GridLayout): + def __init__(self, **kwargs): + super(MyGrid, self).__init__(**kwargs) + self.cols = 2 + self.add_widget(Label(text="Name:")) + self.name = TextInput(multiline=False) + self.add_widget(self.name) + +class MyApp(App): + def build(self): + return MyGrid() + +if __name__ == "__main__": + MyApp().run() diff --git a/Pong/main.py b/Pong/main.py new file mode 100644 index 0000000..2312039 --- /dev/null +++ b/Pong/main.py @@ -0,0 +1,75 @@ +from kivy.app import App +from kivy.uix.widget import Widget +from kivy.properties import ( + NumericProperty, ReferenceListProperty, ObjectProperty +) +from kivy.vector import Vector +from kivy.clock import Clock + + +class PongPaddle(Widget): + score = NumericProperty(0) + + def bounce_ball(self, ball): + if self.collide_widget(ball): + vx, vy = ball.velocity + offset = (ball.center_y - self.center_y) / (self.height / 2) + bounced = Vector(-1 * vx, vy) + vel = bounced * 1.1 + ball.velocity = vel.x, vel.y + offset + + +class PongBall(Widget): + velocity_x = NumericProperty(0) + velocity_y = NumericProperty(0) + velocity = ReferenceListProperty(velocity_x, velocity_y) + + def move(self): + self.pos = Vector(*self.velocity) + self.pos + + +class PongGame(Widget): + ball = ObjectProperty(None) + player1 = ObjectProperty(None) + player2 = ObjectProperty(None) + + def serve_ball(self, vel=(4, 0)): + self.ball.center = self.center + self.ball.velocity = vel + + def update(self, dt): + self.ball.move() + + # bounce of paddles + self.player1.bounce_ball(self.ball) + self.player2.bounce_ball(self.ball) + + # bounce ball off bottom or top + if (self.ball.y < self.y) or (self.ball.top > self.top): + self.ball.velocity_y *= -1 + + # went of to a side to score point? + if self.ball.x < self.x: + self.player2.score += 1 + self.serve_ball(vel=(4, 0)) + if self.ball.x > self.width: + self.player1.score += 1 + self.serve_ball(vel=(-4, 0)) + + def on_touch_move(self, touch): + if touch.x < self.width / 3: + self.player1.center_y = touch.y + if touch.x > self.width - self.width / 3: + self.player2.center_y = touch.y + + +class PongApp(App): + def build(self): + game = PongGame() + game.serve_ball() + Clock.schedule_interval(game.update, 1.0 / 60.0) + return game + + +if __name__ == '__main__': + PongApp().run() diff --git a/Pong/pong.kv b/Pong/pong.kv new file mode 100644 index 0000000..c547fb0 --- /dev/null +++ b/Pong/pong.kv @@ -0,0 +1,50 @@ + +: + size: 50, 50 + canvas: + Ellipse: + pos: self.pos + size: self.size + +: + size: 25, 200 + canvas: + Rectangle: + pos:self.pos + size:self.size + +: + ball: pong_ball + player1: player_left + player2: player_right + + canvas: + Rectangle: + pos: self.center_x - 5, 0 + size: 10, self.height + + Label: + font_size: 70 + center_x: root.width / 4 + top: root.top - 50 + text: str(root.player1.score) + + Label: + font_size: 70 + center_x: root.width * 3 / 4 + top: root.top - 50 + text: str(root.player2.score) + + PongBall: + id: pong_ball + center: self.parent.center + + PongPaddle: + id: player_left + x: root.x + center_y: root.center_y + + PongPaddle: + id: player_right + x: root.width - self.width + center_y: root.center_y diff --git a/Tests/nvimtest.py b/Tests/nvimtest.py new file mode 100644 index 0000000..ca5cdfe --- /dev/null +++ b/Tests/nvimtest.py @@ -0,0 +1,14 @@ +print('salut') +a = 1 +a += 1 +print(a) + +class Stuff: + def __init__(self): + self.a = 1 + +s = Stuff() +print(s.a) + + +print diff --git a/Tests/test-nerdtree.py b/Tests/test-nerdtree.py new file mode 100644 index 0000000..7d6cf2c --- /dev/null +++ b/Tests/test-nerdtree.py @@ -0,0 +1,23 @@ +print('salut') + +a = 1 + +print(a.denominator) + + +# print(a.to_bytes()) +class Salut: + + def __init__(self, truc): + self.truc = truc + + def stuff(self) -> dict: + return {'truc': self.truc} + +s = Salut('bidule') + +s.truc + +b = s.stuff() +wesh = b.pop('truc') +print(wesh.replace('dule', 'de')) diff --git a/webpfix.py b/webpfix.py index 62bdf04..fc5edc6 100644 --- a/webpfix.py +++ b/webpfix.py @@ -12,16 +12,16 @@ def jpgtomp3(): for file in os.listdir(os.getcwd()): if file.endswith('.jpg'): print(file) - name = file[:-4] - print(f"ffmpeg -i '{name}.mp3' -i '{name}.jpg' -map_metadata 0 \ --map 0 -map 1 -acodec copy '{name}.mp3'") - os.system(f"ffmpeg -i '{name}.mp3' -i '{name}.jpg' -map_metadata 0 \ --map 0 -map 1 -acodec copy '{name}.tempo.mp3'") + name = file[:-4].replace('"', "'") + print(f'ffmpeg -i "{name}.mp3" -i "{name}.jpg" -map_metadata 0 \ +-map 0 -map 1 -acodec copy "{name}.tempo.mp3"') + os.system(f'ffmpeg -i "{name}.mp3" -i "{name}.jpg" -map_metadata 0 \ +-map 0 -map 1 -acodec copy "{name}.tempo.mp3"') def rename(): for file in os.listdir(os.getcwd()): if file.endswith('.tempo.mp3'): - name = file[:-len('.tempo.mp3')] + name = file[:-len('.tempo.mp3')].replace('"', "'") os.rename(f"{name}.tempo.mp3", f"{name}.mp3")