Skip to content

Commit

Permalink
Reformatted scripts and updated indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
SVijayB committed Mar 17, 2021
1 parent 5d357f7 commit da304f8
Show file tree
Hide file tree
Showing 209 changed files with 2,787 additions and 1,990 deletions.
24 changes: 13 additions & 11 deletions Arcade Module/Clock.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,26 @@
win_width = 900
win_height = 700

x_axis = win_width // 2 # X-Axis
y_axis = win_height // 2 # Y-Axis
rad = 60/360
x_axis = win_width // 2 # X-Axis
y_axis = win_height // 2 # Y-Axis
rad = 60 / 360
lenth = 300


def on_draw(new_time):
on_draw.angle = on_draw.angle + rad
x = lenth * m.sin(on_draw.angle) + x_axis #Sin for X axis
y = lenth * m.cos(on_draw.angle) + y_axis #Cos for Y axis
x = lenth * m.sin(on_draw.angle) + x_axis # Sin for X axis
y = lenth * m.cos(on_draw.angle) + y_axis # Cos for Y axis

arcade.start_render()
arcade.draw_line(x_axis,y_axis,x,y,arcade.color.RED,5)
arcade.draw_circle_outline(x_axis,y_axis,lenth,arcade.color.BLUE,10)
arcade.draw_line(x_axis, y_axis, x, y, arcade.color.RED, 5)
arcade.draw_circle_outline(x_axis, y_axis, lenth, arcade.color.BLUE, 10)


on_draw.angle = 0

if __name__=="__main__":
arcade.open_window(win_width,win_height,"CLOCK")
if __name__ == "__main__":
arcade.open_window(win_width, win_height, "CLOCK")
arcade.set_background_color(arcade.color.BLACK)
arcade.schedule(on_draw,1)
arcade.run()
arcade.schedule(on_draw, 1)
arcade.run()
55 changes: 31 additions & 24 deletions Arcade Module/Movement.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
rec_height = 50
speed = 5


class Rectangle:
def __init__(self,x,y,rec_width,rec_height,angle,colour):
def __init__(self, x, y, rec_width, rec_height, angle, colour):
self.x = x
self.y = y

self.new_x = 0 # New position
self.new_x = 0 # New position
self.new_y = 0

self.angle = angle
Expand All @@ -21,29 +22,34 @@ def __init__(self,x,y,rec_width,rec_height,angle,colour):
self.colour = colour

def draw(self):
arcade.draw_rectangle_filled(self.x,self.y,self.rec_width,self.rec_height,self.colour,self.angle)
arcade.draw_rectangle_filled(
self.x, self.y, self.rec_width, self.rec_height, self.colour, self.angle
)

def move(self):
self.x = self.x + self.new_x
if(self.x < (rec_width//2)):
self.x = rec_width//2
if(self.x > win_width - (rec_width // 2)):
if self.x < (rec_width // 2):
self.x = rec_width // 2
if self.x > win_width - (rec_width // 2):
self.x = win_width - (rec_width // 2)

self.y = self.y + self.new_y
if(self.y < (rec_height//2)):
self.y = rec_height//2
if(self.y > win_height - (rec_height // 2)):
if self.y < (rec_height // 2):
self.y = rec_height // 2
if self.y > win_height - (rec_height // 2):
self.y = win_height - (rec_height // 2)


class movement(arcade.Window):
def __init__(self,width,height):
super().__init__(width,height,title="MOVEMENT")
def __init__(self, width, height):
super().__init__(width, height, title="MOVEMENT")

def start(self):
x = win_width//2
y = win_height//2
self.player = Rectangle(x,y,rec_width,rec_width,angle=0,colour=arcade.color.RED)
x = win_width // 2
y = win_height // 2
self.player = Rectangle(
x, y, rec_width, rec_width, angle=0, colour=arcade.color.RED
)

def on_update(self, dt):
self.player.move()
Expand All @@ -53,23 +59,24 @@ def on_draw(self):
self.player.draw()

def on_key_press(self, key, modif):
if (key == arcade.key.UP):
if key == arcade.key.UP:
self.player.new_y = speed
elif (key == arcade.key.DOWN):
elif key == arcade.key.DOWN:
self.player.new_y = -speed
elif (key == arcade.key.LEFT):
elif key == arcade.key.LEFT:
self.player.new_x = -speed
elif (key == arcade.key.RIGHT):
elif key == arcade.key.RIGHT:
self.player.new_x = speed

def on_key_release(self, key, modif):
if (key == arcade.key.UP or key == arcade.key.DOWN):
if key == arcade.key.UP or key == arcade.key.DOWN:
self.player.new_y = 0
if (key == arcade.key.LEFT or key == arcade.key.RIGHT):
if key == arcade.key.LEFT or key == arcade.key.RIGHT:
self.player.new_x = 0

if __name__=="__main__":

if __name__ == "__main__":
print("Use Arrow Keys to move the square")
move = movement(win_width,win_height)
move = movement(win_width, win_height)
move.start()
arcade.run()
arcade.run()
45 changes: 29 additions & 16 deletions Arcade Module/Smiley.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,42 @@
import arcade # pip install arcade
import arcade # pip install arcade

# Setting size for main window
Window_width = 700
Window_height = 700

# Creating and opening the window
arcade.open_window(Window_width,Window_height,"Smiley")
arcade.open_window(Window_width, Window_height, "Smiley")
arcade.set_background_color(arcade.color.BLACK)
arcade.start_render() # Always use this before starting
arcade.start_render() # Always use this before starting

# Base Structure
x = 350; y = 350; radius = 200
arcade.draw_circle_filled(x,y,radius,arcade.color.YELLOW)
x = 350
y = 350
radius = 200
arcade.draw_circle_filled(x, y, radius, arcade.color.YELLOW)

#Right Eye
x = 420; y = 420; radius = 25
arcade.draw_circle_filled(x,y,radius,arcade.color.BLACK)
# Right Eye
x = 420
y = 420
radius = 25
arcade.draw_circle_filled(x, y, radius, arcade.color.BLACK)

#Left Eye
x = 280; y = 420; radius = 25
arcade.draw_circle_filled(x,y,radius,arcade.color.BLACK)
# Left Eye
x = 280
y = 420
radius = 25
arcade.draw_circle_filled(x, y, radius, arcade.color.BLACK)

#Curve
x = 340; y= 310; width = 120; height = 100; start_angle = 180; end_angle = 360
arcade.draw_arc_outline(x,y,width,height,arcade.color.BLACK,start_angle,end_angle,10)
# Curve
x = 340
y = 310
width = 120
height = 100
start_angle = 180
end_angle = 360
arcade.draw_arc_outline(
x, y, width, height, arcade.color.BLACK, start_angle, end_angle, 10
)

arcade.finish_render() # Ends the arcade
arcade.run() # Keeps the window running until closed
arcade.finish_render() # Ends the arcade
arcade.run() # Keeps the window running until closed
11 changes: 6 additions & 5 deletions Arcade Module/Snow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import math
import arcade


class Snow:
def __init__(self, height, width):
self.x = 0
Expand All @@ -13,7 +14,6 @@ def reset_pos(self, height, width):


class MyGame(arcade.Window):

def __init__(self, width, height):
super().__init__(width, height)
self.stream = None
Expand All @@ -31,20 +31,21 @@ def start(self, height, width):
self.stream.append(snow)
arcade.set_background_color(arcade.color.BLACK)

def on_draw(self): # This is a default function.
def on_draw(self): # This is a default function.
arcade.start_render()
for snow in self.stream:
arcade.draw_circle_filled(snow.x, snow.y,snow.size, arcade.color.WHITE)
arcade.draw_circle_filled(snow.x, snow.y, snow.size, arcade.color.WHITE)

def on_update(self, delta_time): # This is a default function.
def on_update(self, delta_time): # This is a default function.
for snow in self.stream:
snow.y = snow.y - snow.speed * delta_time
if snow.y < 0:
snow.reset_pos(800, 600)
snow.x = snow.x + snow.speed * math.cos(snow.angle) * delta_time
snow.angle = snow.angle + delta_time


if __name__ == "__main__":
window = MyGame(800, 600)
window.start(800, 600)
arcade.run()
arcade.run()
69 changes: 42 additions & 27 deletions Arcade Module/Still Imaging.py
Original file line number Diff line number Diff line change
@@ -1,48 +1,63 @@
import arcade
import arcade
import random

win_width = 800
win_height = 600
win_height = 600

# Drawing the background Screen :
def screen():
arcade.draw_rectangle_filled(win_width/2, win_height*2/3, win_width-1, win_height*2/3, arcade.color.SKY_BLUE)
arcade.draw_rectangle_filled(win_width/2, win_height/6, win_width-1, win_height/3, arcade.color.LIGHT_GREEN)

def birds(x,y):
arcade.draw_rectangle_filled(
win_width / 2,
win_height * 2 / 3,
win_width - 1,
win_height * 2 / 3,
arcade.color.SKY_BLUE,
)
arcade.draw_rectangle_filled(
win_width / 2,
win_height / 6,
win_width - 1,
win_height / 3,
arcade.color.LIGHT_GREEN,
)


def birds(x, y):
# Left Curve :
arcade.draw_arc_outline(x, y, 40, 40, arcade.color.BLACK, 0, 90,3)
arcade.draw_arc_outline(x, y, 40, 40, arcade.color.BLACK, 0, 90, 3)
# Right Curve :
arcade.draw_arc_outline(x+40, y, 40, 40, arcade.color.BLACK, 90, 180,3)
arcade.draw_arc_outline(x + 40, y, 40, 40, arcade.color.BLACK, 90, 180, 3)


def trees(a, b):
# The Bark of the Tree :
arcade.draw_rectangle_filled(a, b, 20, 40, arcade.color.BROWN)
# Drawing the Top of the Tree :
line = b + 20
list = ((a - 40, line), (a, line + 100), (a + 40, line))
arcade.draw_polygon_filled(list, arcade.color.DARK_GREEN)

def trees(a,b):
# The Bark of the Tree :
arcade.draw_rectangle_filled(a,b,20,40,arcade.color.BROWN)
# Drawing the Top of the Tree :
line = b+20
list = ((a-40,line),(a,line+100),(a+40,line))
arcade.draw_polygon_filled(list,arcade.color.DARK_GREEN)

def sun():
arcade.draw_circle_filled(600,500,50,arcade.color.SUNGLOW)
arcade.draw_circle_filled(600, 500, 50, arcade.color.SUNGLOW)

if __name__=="__main__":
arcade.open_window(win_width,win_height,"Still Imaging")

if __name__ == "__main__":
arcade.open_window(win_width, win_height, "Still Imaging")
arcade.start_render()
screen()
sun()

for i in range (10):
x = random.randrange(0,win_width)
y = random.randrange(win_height/2,win_height-20)
birds(x,y)
for i in range(10):
x = random.randrange(0, win_width)
y = random.randrange(win_height / 2, win_height - 20)
birds(x, y)

for a in range (45,win_width,90):
trees(a,win_height/3)
for a in range(45, win_width, 90):
trees(a, win_height / 3)

for a in range (65, win_width,90):
trees(a,(win_height/3)-120)
for a in range(65, win_width, 90):
trees(a, (win_height / 3) - 120)

arcade.finish_render()
arcade.run()

24 changes: 13 additions & 11 deletions Arcade Module/Timer.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
import arcade
from tkinter import Tk, messagebox
import sys



class Timer(arcade.Window):
def __init__(self,width=300,height=150):
super().__init__(width,height)
def __init__(self, width=300, height=150):
super().__init__(width, height)
self.time = 0.0

def Window(self,time):
def Window(self, time):
arcade.set_background_color(arcade.color.BLACK)
self.time = time

def on_draw(self):
arcade.start_render()
min = int(self.time)//60
sec = int(self.time)%60
min = int(self.time) // 60
sec = int(self.time) % 60
result = f"Time : {min}:{sec}"
arcade.draw_text(result,60,60,arcade.color.RED,35)
if(min<0):
arcade.draw_text(result, 60, 60, arcade.color.RED, 35)
if min < 0:
root = Tk()
root.withdraw()
messagebox.showinfo("Info Box","Countdown Has Reached Zero")
messagebox.showinfo("Info Box", "Countdown Has Reached Zero")
sys.exit(0)

def on_update(self,new_time):
def on_update(self, new_time):
self.time = self.time - new_time

if __name__=="__main__":

if __name__ == "__main__":
try:
time = int(input("Enter how many seconds you want to count : "))
except:
Expand Down
Loading

0 comments on commit da304f8

Please sign in to comment.