Skip to content
Open
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
5 changes: 0 additions & 5 deletions controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,3 @@

def start():
view.start_view()
i = input()
if i == 'y':
return view.start_game()
else:
return view.end_view()
Binary file added five.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added four.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
125 changes: 125 additions & 0 deletions hand_cricket_confirm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
import pygame,logic,hand_cricket_main
import os,sys
from collections import Counter
import popen
from pygame.locals import *


# def main():
# pygame.init()
# screen = pygame.display.set_mode((1920, 1080))
#
# clock = pygame.time.Clock()
#
# while 1:
# mouse = pygame.mouse.get_pos()
# click = pygame.mouse.get_pressed()
# screen.fill((255, 255, 0))
# font = pygame.font.SysFont("comicsansms", 72)
# button_font = pygame.font.SysFont("comicsansms", 30)
# text = font.render("Alpha Hand-Cricket", True, (0, 128, 0))
#
# re_button_text = button_font.render("Replay", True, (0, 0, 0))
# ex_button_text = button_font.render("Exit", True, (0, 0, 0))
#
# # image = cam.get_image()
# pygame.draw.rect(screen, (0, 255, 0),(1550,20,100,50))
# screen.blit(re_button_text,(1565,35))
# pygame.draw.rect(screen, (255, 0, 0),(1700,20,100,50))
# screen.blit(ex_button_text,(1730,35))
# screen.blit(text,(760,35))
#
# # screen.blit(image, (1200,520))
# pygame.display.update()
#
# if(click[0]==1):
# print("close")
# if(1800>mouse[0]>1700 and 70>mouse[1]>20):
# sys.exit()
#
# if(click[0]==1):
# if(1650>mouse[0]>1550 and 70>mouse[1]>20):
# logic.main()
# #
# # for event in pygame.event.get():
# # if event.type == pygame.QUIT:
# # sys.exit()

def user_move():
o=popen.output()
number=Counter(o)
s = max(number.values())
i = number.values().index(s)
move=int(number.items()[i][0])
return move


def confirm():
pygame.init()
screen = pygame.display.set_mode((1920, 1080))

clock = pygame.time.Clock()

def pic(o):
if(o==1):
return pygame.image.load("/home/kushald/Downloads/one.jpg")
elif(o==2):
return pygame.image.load("/home/kushald/Downloads/two.jpg")
elif(o==3):
return pygame.image.load("/home/kushald/Downloads/three.jpg")
elif(o==4):
return pygame.image.load("/home/kushald/Downloads/four.jpg")
elif(o==5):
return pygame.image.load("/home/kushald/Downloads/five.jpg")
elif(o==6):
return pygame.image.load("/home/kushald/Downloads/six.jpg")
else:
return pygame.image.load("/home/kushald/Downloads/screen-2.jpg")

play=True


while play:
mouse = pygame.mouse.get_pos()
click = pygame.mouse.get_pressed()
screen.fill((255, 255, 0))
font = pygame.font.SysFont("comicsansms", 72)
button_font = pygame.font.SysFont("comicsansms", 30)
text = font.render("Click on PLAY to begin the game", True, (0, 128, 0))

re_button_text = button_font.render("PLAY", True, (0, 0, 0))
ex_button_text = button_font.render("EXIT", True, (0, 0, 0))

# image = cam.get_image()
pygame.draw.rect(screen, (0, 255, 0),(1550,20,100,50))
screen.blit(re_button_text,(1570,35))
pygame.draw.rect(screen, (255, 0, 0),(1700,20,100,50))
screen.blit(ex_button_text,(1725,35))
screen.blit(text,(760,735))

# o=popen.output()
# number=Counter(o)
# s = max(number.values())
# i = number.values().index(s)
# move=int(number.items()[i][0])
# ones = pic(move)
# if(ones==None):
# play=False
# # else:
# screen.blit(ones,(760,350))


# screen.blit(image, (1200,520))
pygame.display.update()

if(click[0]==1):
if(1800>mouse[0]>1700 and 70>mouse[1]>20):
sys.exit()

if(click[0]==1):
if(1650>mouse[0]>1550 and 70>mouse[1]>20):
logic.main()

for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
44 changes: 44 additions & 0 deletions hand_cricket_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import pygame,logic
import os,sys
from pygame.locals import *


def main():
pygame.init()
screen = pygame.display.set_mode((1920, 1080))

clock = pygame.time.Clock()
print("MAIN")
while 1:
mouse_main = pygame.mouse.get_pos()
print(mouse_main)
click_main = pygame.mouse.get_pressed()
screen.fill((255, 255, 0))
font = pygame.font.SysFont("comicsansms", 72)
button_font = pygame.font.SysFont("comicsansms", 30)
text = font.render("Alpha Hand-Cricket", True, (0, 128, 0))

re_button_text = button_font.render("Replay", True, (0, 0, 0))
ex_button_text = button_font.render("Exit", True, (0, 0, 0))

# image = cam.get_image()
pygame.draw.rect(screen, (0, 255, 0),(1550,20,100,50))
screen.blit(re_button_text,(1565,35))
pygame.draw.rect(screen, (255, 0, 0),(1700,20,100,50))
screen.blit(ex_button_text,(1730,35))
screen.blit(text,(760,35))

# screen.blit(image, (1200,520))
pygame.display.flip()

if(click_main[0]==1):
if(1800>mouse_main[0]>1700 and 70>mouse_main[1]>20):
sys.exit()

if(click_main[0]==1):
if(1650>mouse_main[0]>1550 and 70>mouse_main[1]>20):
logic.main()
#
# for event in pygame.event.get():
# if event.type == pygame.QUIT:
# sys.exit()
5 changes: 3 additions & 2 deletions logic.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from os import system, name
from random import randint
from time import sleep
import hand_cricket_confirm

def clear():
_ = system('clear' if name =='posix' else 'cls')
Expand All @@ -20,8 +21,8 @@ def display_header(innings_number, runs, is_user_batting, target):

def user_plays():
while True:
print('Choose a number: ', end='')
num = int(input().strip())
# print('Choose a number: ', end='')
num = hand_cricket_confirm.user_move() #int(input().strip())
if num in range(7):
return num
else:
Expand Down
Binary file added one.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added six.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added three.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added two.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 3 additions & 4 deletions view.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# from model import User
import logic
import logic,hand_cricket_main,hand_cricket_confirm

def start_game():
logic.main()
hand_cricket_main.main()

def start_view():
print('Alpha Hand Cricket !!')
print('Enter y to begin the game')
hand_cricket_confirm.confirm()

def end_view():
print('Goodbye!')