Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Flames_Game/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Flames Game

*Requirements*
- Python: Download it from: https://www.python.org/downloads/
- tkinter

Run the file and give your input of both names and click "Flame" button.
Enjoy the game

### A visuals of the game
<img src="https://github.com/oyerohabib/Python-project-Scripts/blob/oyerohabib-3/Flames_Game/flame-game.png">
Binary file added Flames_Game/flame-game.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
91 changes: 91 additions & 0 deletions Flames_Game/flames_game_gui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
from tkinter import *


def clear_all():
Player1_field.delete(0, END)
Player2_field.delete(0, END)
Status_field.delete(0, END)
# set focus on the Player1_field entry box
Player1_field.focus_set()


def tell_status():
p1 = Player1_field.get()
p2 = Player2_field.get()
p1 = p1.replace(" ", "")
p2 = p2.replace(" ", "")
p1 = list(p1)
p2 = list(p2)

Status_field.insert(10, result_flame(p1, p2))


def result_flame(x, y):
for i in x[:]:
if i in y:
x.remove(i)
y.remove(i)
count = len(x) + len(y)
result = ["Friends", "Love", "Affection", "Marriage", "Enemy", "Siblings"]
while len(result) > 1:
split_index = (count % len(result) - 1)
if (split_index >= 0):
right = result[split_index + 1:]
left = result[: split_index]
result = right + left
else:
result = result[: len(result) - 1]
return result


if __name__ == "__main__":
# Create a GUI window
root = Tk()
# Set the background colour of GUI window
root.configure(background='light pink')
# Set the configuration of GUI window
root.geometry("350x125")
# set the name of tkinter GUI window
root.title("Flames Game")
# Create a Player 1 Name: label
label1 = Label(root, text="Name 1 ", fg='black', bg='light green')
# Create a Player 2 Name: label
label2 = Label(root, text="Name 2 ", fg='black', bg='light blue')
# Create a Relation Status: label
label3 = Label(root, text="Relationship Status", fg='black', bg='#FFE4C4')
# grid method is used for placing
# the widgets at respective positions
# in table like structure.
label1.grid(row=1, column=0, sticky="E")
label2.grid(row=2, column=0, sticky="E")
label3.grid(row=4, column=0, sticky="E")
# Create a text entry box
# for filling or typing the information.
Player1_field = Entry(root)
Player2_field = Entry(root)
Status_field = Entry(root)
# grid method is used for placing
# the widgets at respective positions
# in table like structure.
# ipadx keyword argument set width of entry space.
Player1_field.grid(row=1, column=1, ipadx="50")
Player2_field.grid(row=2, column=1, ipadx="50")
Status_field.grid(row=4, column=1, ipadx="50")
# Create a Submit Button and attached
# to tell_status function
button1 = Button(root, text="Flame", bg="#FF7F50",
fg="black", command=tell_status)

# Create a Clear Button and attached
# to clear_all function
button2 = Button(root, text="Clear", bg="#CD5C5C",
fg="black", command=clear_all)

# grid method is used for placing
# the widgets at respective positions
# in table like structure.
button1.grid(row=3, column=1)
button2.grid(row=5, column=1)

# Start the GUI
root.mainloop()
16 changes: 16 additions & 0 deletions Turtle-Race-Game/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Turtle-Race

### A randomly simulated turtle race! You can watch different color turtles race across the screen and keep track of the wins/losses of each turtle.


## Requirements
- turtle

### How to install
- open the cmd
- navigate to the file directory
- do a pip install turtle
- python main.py

## A visual look of the game
<img src="https://github.com/oyerohabib/Python-project-Scripts/blob/oyerohabib/Turtle-Race-Game/Turtle-game.png">
Binary file added Turtle-Race-Game/Turtle-game.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
114 changes: 114 additions & 0 deletions Turtle-Race-Game/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
import math
import random
import turtle
#import time

win_length = 500
win_height = 500

turtles = 8

turtle.screensize(win_length, win_height)


class racer(object):
def __init__(self, color, pos):
self.pos = pos
self.color = color
self.turt = turtle.Turtle()
self.turt.shape('turtle')
self.turt.color(color)
self.turt.penup()
self.turt.setpos(pos)
self.turt.setheading(90)

def move(self):
r = random.randrange(1, 20)
self.pos = (self.pos[0], self.pos[1] + r)
self.turt.pendown()
self.turt.forward(r)

def reset(self):
self.turt.penup()
self.turt.setpos(self.pos)


def setupFile(name, colors):
file = open(name, 'w')
for color in colors:
file.write(color + ' 0 \n')
file.close()


def startGame():
tList = []
turtle.clearscreen()
turtle.hideturtle()
colors = ["red", "green", "blue", 'yellow', 'pink', 'orange', 'purple', 'black', 'grey']
start = -(win_length/2) + 20
for t in range(turtles):
newPosX = start + t*(win_length)//turtles
tList.append(racer(colors[t],(newPosX, -230)))
tList[t].turt.showturtle()

run = True
while run:
for t in tList:
t.move()

maxColor = []
maxDis = 0
for t in tList:
if t.pos[1] > 230 and t.pos[1] > maxDis:
maxDis = t.pos[1]
maxColor = []
maxColor.append(t.color)
elif t.pos[1] > 230 and t.pos[1] == maxDis:
maxDis = t.pos[1]
maxColor.append(t.color)

if len(maxColor) > 0:
run = False
print('The winner is: ')
for win in maxColor:
print(win)

oldScore = []
file = open('scores.txt', 'r')
for line in file:
l = line.split()
color = l[0]
score = l[1]
oldScore.append([color, score])

file.close()

file = open('scores.txt', 'w')

for entry in oldScore:
for winner in maxColor:
if entry[0] == winner:
entry[1] = int(entry[1]) + 1

file.write(str(entry[0]) + ' ' + str(entry[1]) + '\n')


file.close()


start = input('Would you like to play, type "yes" or "no": ').lower()
if start == "yes":
print('----------GAME IN PROGRESS--------')
startGame()
else:
quit()

while True:
print('-----------------------------------')
start = input('Would you like to play again, type "yes" or "no": ').lower()
if start == "yes":
print('----------GAME IN PROGRESS--------')
startGame()
else:
print('----------THANK YOU FOR PLAYING--------')
quit()
Empty file added Turtle-Race-Game/scores.txt
Empty file.
8 changes: 0 additions & 8 deletions WebScraping/posts/0.txt

This file was deleted.

4 changes: 0 additions & 4 deletions WebScraping/posts/1.txt

This file was deleted.