diff --git a/controller.py b/controller.py index d350eff..f47b07f 100644 --- a/controller.py +++ b/controller.py @@ -2,8 +2,3 @@ def start(): view.start_view() - i = input() - if i == 'y': - return view.start_game() - else: - return view.end_view() diff --git a/five.jpg b/five.jpg new file mode 100644 index 0000000..d12c9c9 Binary files /dev/null and b/five.jpg differ diff --git a/four.jpg b/four.jpg new file mode 100644 index 0000000..532547a Binary files /dev/null and b/four.jpg differ diff --git a/hand_cricket_confirm.py b/hand_cricket_confirm.py new file mode 100644 index 0000000..5a0731b --- /dev/null +++ b/hand_cricket_confirm.py @@ -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() diff --git a/hand_cricket_main.py b/hand_cricket_main.py new file mode 100644 index 0000000..1499b7a --- /dev/null +++ b/hand_cricket_main.py @@ -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() diff --git a/logic.py b/logic.py index 975172e..46eeae4 100644 --- a/logic.py +++ b/logic.py @@ -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') @@ -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: diff --git a/one.jpg b/one.jpg new file mode 100644 index 0000000..4c249e8 Binary files /dev/null and b/one.jpg differ diff --git a/six.jpg b/six.jpg new file mode 100644 index 0000000..736af69 Binary files /dev/null and b/six.jpg differ diff --git a/three.jpg b/three.jpg new file mode 100644 index 0000000..6ee9f90 Binary files /dev/null and b/three.jpg differ diff --git a/two.jpg b/two.jpg new file mode 100644 index 0000000..784d7c3 Binary files /dev/null and b/two.jpg differ diff --git a/view.py b/view.py index 52b221d..fb2c845 100644 --- a/view.py +++ b/view.py @@ -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!')