diff --git a/.idea/Snakes-and-Ladders.iml b/.idea/PyLadder.iml
similarity index 53%
rename from .idea/Snakes-and-Ladders.iml
rename to .idea/PyLadder.iml
index 858c4d5..2946dc0 100644
--- a/.idea/Snakes-and-Ladders.iml
+++ b/.idea/PyLadder.iml
@@ -1,10 +1,12 @@
-
-
-
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/dbnavigator.xml b/.idea/dbnavigator.xml
deleted file mode 100644
index 807e7de..0000000
--- a/.idea/dbnavigator.xml
+++ /dev/null
@@ -1,454 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
index cb9a2ff..5ccec97 100644
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -1,30 +1,17 @@
-
-
-
-
-
-
+
diff --git a/.idea/misc.xml b/.idea/misc.xml
index e14d7d1..8d93904 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,4 +1,4 @@
-
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
index 1a93545..a7fb24e 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -2,7 +2,7 @@
-
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..9661ac7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/Webp.net-resizeimage (1).png:Zone.Identifier b/assets/Webp.net-resizeimage (1).png:Zone.Identifier
new file mode 100644
index 0000000..3012e29
--- /dev/null
+++ b/assets/Webp.net-resizeimage (1).png:Zone.Identifier
@@ -0,0 +1,4 @@
+[ZoneTransfer]
+ZoneId=3
+ReferrerUrl=https://resizeimage.net/
+HostUrl=https://resizeimage.net/mypic/mekOPk82f8hpm3Th/ZlmeK/multicolor.png
diff --git a/assets/bg_menu.jpg b/assets/bg_menu.jpg
new file mode 100644
index 0000000..3e8e437
Binary files /dev/null and b/assets/bg_menu.jpg differ
diff --git a/assets/loss_computer.png b/assets/loss_computer.png
new file mode 100644
index 0000000..bbb29f9
Binary files /dev/null and b/assets/loss_computer.png differ
diff --git a/assets/loss_computer.png:Zone.Identifier b/assets/loss_computer.png:Zone.Identifier
new file mode 100644
index 0000000..eb11698
--- /dev/null
+++ b/assets/loss_computer.png:Zone.Identifier
@@ -0,0 +1,4 @@
+[ZoneTransfer]
+ZoneId=3
+ReferrerUrl=https://www.flaticon.com/
+HostUrl=https://download.flaticon.com/download/icon/2673072?icon_id=2673072&author=1&team=1&keyword=Dislike&pack=2672975&style=Flat&style_id=3&format=png&color=%23000000&colored=2&size=128&selection=1&premium=0&type=standard&_gl=1*1d2wzap*_ga*ODA0NzA3MTYxLjE2MjM0NTcxNzc.*_ga_3Q8LH3P0VP*MTYyOTgxMDI5MC4xMC4xLjE2Mjk4MTE0NDMuMA..
diff --git a/assets/loss_player.png b/assets/loss_player.png
new file mode 100644
index 0000000..ddacfa1
Binary files /dev/null and b/assets/loss_player.png differ
diff --git a/assets/loss_player.png:Zone.Identifier b/assets/loss_player.png:Zone.Identifier
new file mode 100644
index 0000000..4f2d0bc
--- /dev/null
+++ b/assets/loss_player.png:Zone.Identifier
@@ -0,0 +1,5 @@
+[ZoneTransfer]
+ZoneId=3
+ReferrerUrl=https://www.flaticon.com/
+HostUrl=https://download.flaticon.com/download/icon/2673072?icon_id=2673072&author=1&team=1&keyword=Dislike&pack=2672975&style=Flat&style_id=3&format=png&color=%23000000&colored=2&size=128&selection=1&premium=0&type=standard&_gl=1*1d2wzap*_ga*ODA0NzA3MTYxLjE2MjM0NTcxNzc.*_ga_3Q8LH3P0VP*MTYyOTgxMDI5MC4xMC4xLjE2Mjk4MTE0NDMuMA..
+LastWriterPackageFamilyName=Microsoft.Windows.Photos_8wekyb3d8bbwe
diff --git a/assets/multicolor.png:Zone.Identifier b/assets/multicolor.png:Zone.Identifier
new file mode 100644
index 0000000..bd875bd
--- /dev/null
+++ b/assets/multicolor.png:Zone.Identifier
@@ -0,0 +1,4 @@
+[ZoneTransfer]
+ZoneId=3
+ReferrerUrl=https://www.remove.bg/
+HostUrl=https://o.remove.bg/downloads/bc025365-0f3f-4155-ae9e-7cca1f685c6e/multicolor-confetti-burst-background_166207-101-removebg-preview.png
diff --git a/assets/question/q1.jpg b/assets/question/q1.jpg
new file mode 100644
index 0000000..2902bf8
Binary files /dev/null and b/assets/question/q1.jpg differ
diff --git a/assets/question/q10.jpg b/assets/question/q10.jpg
new file mode 100644
index 0000000..d0b0711
Binary files /dev/null and b/assets/question/q10.jpg differ
diff --git a/assets/question/q11.jpg b/assets/question/q11.jpg
new file mode 100644
index 0000000..90e06c9
Binary files /dev/null and b/assets/question/q11.jpg differ
diff --git a/assets/question/q12.jpg b/assets/question/q12.jpg
new file mode 100644
index 0000000..d00eaea
Binary files /dev/null and b/assets/question/q12.jpg differ
diff --git a/assets/question/q13.jpg b/assets/question/q13.jpg
new file mode 100644
index 0000000..bbae645
Binary files /dev/null and b/assets/question/q13.jpg differ
diff --git a/assets/question/q14.jpg b/assets/question/q14.jpg
new file mode 100644
index 0000000..159f6b8
Binary files /dev/null and b/assets/question/q14.jpg differ
diff --git a/assets/question/q15.jpg b/assets/question/q15.jpg
new file mode 100644
index 0000000..ff8450d
Binary files /dev/null and b/assets/question/q15.jpg differ
diff --git a/assets/question/q16.jpg b/assets/question/q16.jpg
new file mode 100644
index 0000000..1fdf936
Binary files /dev/null and b/assets/question/q16.jpg differ
diff --git a/assets/question/q17.jpg b/assets/question/q17.jpg
new file mode 100644
index 0000000..4f04833
Binary files /dev/null and b/assets/question/q17.jpg differ
diff --git a/assets/question/q18.jpg b/assets/question/q18.jpg
new file mode 100644
index 0000000..81b732b
Binary files /dev/null and b/assets/question/q18.jpg differ
diff --git a/assets/question/q2.jpg b/assets/question/q2.jpg
new file mode 100644
index 0000000..7c6dca6
Binary files /dev/null and b/assets/question/q2.jpg differ
diff --git a/assets/question/q3.jpg b/assets/question/q3.jpg
new file mode 100644
index 0000000..25cfe40
Binary files /dev/null and b/assets/question/q3.jpg differ
diff --git a/assets/question/q4.jpg b/assets/question/q4.jpg
new file mode 100644
index 0000000..5158e0c
Binary files /dev/null and b/assets/question/q4.jpg differ
diff --git a/assets/question/q5.jpg b/assets/question/q5.jpg
new file mode 100644
index 0000000..abc4357
Binary files /dev/null and b/assets/question/q5.jpg differ
diff --git a/assets/question/q6.jpg b/assets/question/q6.jpg
new file mode 100644
index 0000000..2d9619a
Binary files /dev/null and b/assets/question/q6.jpg differ
diff --git a/assets/question/q7.jpg b/assets/question/q7.jpg
new file mode 100644
index 0000000..2c1cbee
Binary files /dev/null and b/assets/question/q7.jpg differ
diff --git a/assets/question/q8.jpg b/assets/question/q8.jpg
new file mode 100644
index 0000000..e1a11aa
Binary files /dev/null and b/assets/question/q8.jpg differ
diff --git a/assets/question/q9.jpg b/assets/question/q9.jpg
new file mode 100644
index 0000000..5779529
Binary files /dev/null and b/assets/question/q9.jpg differ
diff --git a/assets/wins_computer.png b/assets/wins_computer.png
new file mode 100644
index 0000000..01e6004
Binary files /dev/null and b/assets/wins_computer.png differ
diff --git a/assets/wins_computer.png:Zone.Identifier b/assets/wins_computer.png:Zone.Identifier
new file mode 100644
index 0000000..7933cb1
--- /dev/null
+++ b/assets/wins_computer.png:Zone.Identifier
@@ -0,0 +1,5 @@
+[ZoneTransfer]
+ZoneId=3
+ReferrerUrl=https://www.flaticon.com/
+HostUrl=https://download.flaticon.com/download/icon/1642423?icon_id=1642423&author=299&team=299&keyword=Success&pack=1642332&style=Lineal+Color&style_id=1022&format=png&color=%23000000&colored=2&size=256&selection=1&premium=0&type=standard&search=win&_gl=1*1k6qwmi*_ga*ODA0NzA3MTYxLjE2MjM0NTcxNzc.*_ga_3Q8LH3P0VP*MTYyOTgxMDI5MC4xMC4xLjE2Mjk4MTA3MDIuMA..&search=win
+LastWriterPackageFamilyName=Microsoft.Windows.Photos_8wekyb3d8bbwe
diff --git a/assets/wins_player.png b/assets/wins_player.png
new file mode 100644
index 0000000..11b6486
Binary files /dev/null and b/assets/wins_player.png differ
diff --git a/assets/wins_player.png:Zone.Identifier b/assets/wins_player.png:Zone.Identifier
new file mode 100644
index 0000000..e5cd703
--- /dev/null
+++ b/assets/wins_player.png:Zone.Identifier
@@ -0,0 +1,4 @@
+[ZoneTransfer]
+ZoneId=3
+ReferrerUrl=https://www.flaticon.com/
+HostUrl=https://download.flaticon.com/download/icon/1642423?icon_id=1642423&author=299&team=299&keyword=Success&pack=1642332&style=Lineal+Color&style_id=1022&format=png&color=%23000000&colored=2&size=256&selection=1&premium=0&type=standard&search=win&_gl=1*1k6qwmi*_ga*ODA0NzA3MTYxLjE2MjM0NTcxNzc.*_ga_3Q8LH3P0VP*MTYyOTgxMDI5MC4xMC4xLjE2Mjk4MTA3MDIuMA..&search=win
diff --git a/game.py b/game.py
index 6efe077..8c415f3 100644
--- a/game.py
+++ b/game.py
@@ -9,7 +9,6 @@
width = 1366
height = 768
-
# Icon layout and caption
icon = pygame.image.load("assets/icon.jpg")
game_layout = pygame.display.set_mode((width, height))
@@ -17,7 +16,6 @@
pygame.display.set_icon(icon)
pygame.display.update()
-
Board = pygame.image.load("assets/Snakes_ladders_big_image.png")
Menu = pygame.image.load("assets/menu.jpg")
Background = pygame.image.load("assets/game_background.jpg")
@@ -47,10 +45,25 @@
dice5 = pygame.image.load("assets/dice_image5.png")
dice6 = pygame.image.load("assets/dice_image6.png")
+# Sounds
+pygame.mixer.music.load("sound/song1.wav") # And menu first line
+snake_sound = pygame.mixer.Sound("sound/snake2.wav")
+ladder_sound = pygame.mixer.Sound("sound/ladder2.wav")
+win_sound = pygame.mixer.Sound("sound/win1.wav")
+lose_sound = pygame.mixer.Sound("sound/loss3.wav")
+dice_sound = pygame.mixer.Sound("sound/dice1.wav")
+
+# img Win & loss
+wins_player = pygame.image.load("assets/wins_player.png")
+loss_player = pygame.image.load("assets/loss_player.png")
+wins_computer = pygame.image.load("assets/wins_computer.png")
+loss_computer = pygame.image.load("assets/loss_computer.png")
+
# Position of mouse
mouse = pygame.mouse.get_pos()
-
+# Last Question
+last_question = []
# prompt text when player/computer wins the game , or when a player cant move due to movments being higher than 100
def display_text(text, x, y, fontsize):
Textsize = pygame.font.SysFont("ravie", fontsize)
@@ -250,7 +263,7 @@ def starter():
# while pygame.time.get_ticks() - time_clock < 2500:
# game_layout.blit(back1, (0, 0))
# pygame.display.update()
- # note we may reomve this one
+ # note we may reomve this one
# while True:
# time_clock = pygame.time.get_ticks()
# while pygame.time.get_ticks() - time_clock < 500:
@@ -268,7 +281,7 @@ def starter():
# while pygame.time.get_ticks() - time_clock < 500:
# game_layout.blit(back5, (0, 0))
# pygame.display.update()
-
+ #
# for event in pygame.event.get():
# if event.type == pygame.KEYDOWN:
# return
@@ -287,6 +300,7 @@ def ASAC():
pygame.display.update()
# Main Menu of our game
def menu():
+ pygame.mixer.music.play(-1)
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
@@ -328,7 +342,8 @@ def chosen():
def turn(score, go_up, swallowed,rounds):
# roll a dice using random number between 1 and 6
d = randint(1, 6)
- print(type(d))
+ # print(type(d))
+ pygame.mixer.Sound.play(dice_sound)
if d != 6:
dice(d,rounds)
six = False
@@ -345,11 +360,13 @@ def turn(score, go_up, swallowed,rounds):
ladd_score = ladders(score) # checking for ladders for player
if ladd_score != score:
go_up = True
+ pygame.mixer.Sound.play(ladder_sound)
clock = pygame.time.get_ticks()
score = ladd_score
snake_score = snakes(score)
if snake_score != score:
swallowed = True
+ pygame.mixer.Sound.play(snake_sound)
score = snake_score
# if score is not grater than 100
else:
@@ -388,7 +405,7 @@ def playing(btn1):
Quit()
green_color=(113, 207, 41, 1)
light_green_color=(0, 230, 0)
- print(btn1)
+ # print(btn1)
if btn1:
if button("Click to Roll", mouse[0], mouse[1], 70, 138, 300, 50, green_color, light_green_color, 30,btn1):
if rounds == 1:
@@ -400,6 +417,13 @@ def playing(btn1):
time = pygame.time.get_ticks()
while pygame.time.get_ticks() - time < 2500:
display_text("Congratulations You WON !", 1000, 50, 50)
+ pygame.mixer.music.pause()
+ while pygame.time.get_ticks() - time < 2500:
+ game_layout.blit(wins_player, (-5, height / 2 - 100))
+ game_layout.blit(loss_computer, (width - 120, height / 2))
+ pygame.display.update()
+ pygame.mixer.Sound.play(win_sound)
+ pygame.mixer.music.unpause()
pygame.display.update()
break
game_layout.blit(red_token, (comp_x_c ,comp_y_c ))
@@ -417,6 +441,13 @@ def playing(btn1):
time_clock = pygame.time.get_ticks()
while pygame.time.get_ticks() - time_clock < 2000:
display_text("Computer Wins !", 1066, 50, 50)
+ pygame.mixer.music.pause()
+ while pygame.time.get_ticks() - time_clock < 2500:
+ game_layout.blit(wins_computer, (width - 250, height / 2 - 100))
+ game_layout.blit(loss_player, (-5, height / 2))
+ pygame.display.update()
+ pygame.mixer.Sound.play(lose_sound)
+ pygame.mixer.music.unpause()
pygame.display.update()
break
if up:
@@ -432,7 +463,98 @@ def playing(btn1):
clock.tick()
pygame.display.update()
+
def math():
- return False
+ font = pygame.font.Font(None, 32)
+ input_box = pygame.Rect(585, 570, 140, 32)
+
+ questions = [["assets/question/q1.jpg", '15'],
+ ["assets/question/q2.jpg", '15'],
+ ["assets/question/q3.jpg", '15'],
+ ["assets/question/q4.jpg", '15'],
+ ["assets/question/q5.jpg", '15'],
+ ["assets/question/q6.jpg", '15'],
+ ["assets/question/q7.jpg", '15'],
+ ["assets/question/q8.jpg", '15'],
+ ["assets/question/q9.jpg", '15'],
+ ["assets/question/q10.jpg", '15'],
+ ["assets/question/q11.jpg", '15'],
+ ["assets/question/q12.jpg", '15'],
+ ["assets/question/q13.jpg", '15'],
+ ["assets/question/q14.jpg", '15'],
+ ["assets/question/q15.jpg", '15'],
+ ["assets/question/q16.jpg", '15'],
+ ["assets/question/q17.jpg", '15'],
+ ["assets/question/q18.jpg", '15']]
+ read_q = randint(0, 17)
+
+ get_question = True
+
+ while get_question:
+ if questions[read_q][0] in last_question:
+ read_q = randint(0, 17)
+ else:
+ last_question.append(questions[read_q][0])
+ get_question = False
+ print(last_question)
+ question = pygame.image.load(questions[read_q][0])
+ answer = questions[read_q][1]
+
+ color_inactive = pygame.Color('lightskyblue3')
+ color_active = pygame.Color('dodgerblue2')
+ color = color_inactive
+
+ active = False
+ text = ''
+ done = False
+ while not done:
+ for event in pygame.event.get():
+ if event.type == pygame.QUIT:
+ Quit()
+
+ if event.type == pygame.MOUSEBUTTONDOWN:
+ # If the user clicked on the input_box rect.
+ if input_box.collidepoint(event.pos):
+ # Toggle the active variable.
+ active = not active
+ else:
+ active = False
+ # Change the current color of the input box.
+ color = color_active if active else color_inactive
+ if event.type == pygame.KEYDOWN:
+ if active:
+ if event.key == pygame.K_RETURN:
+ # check if the player answer the question
+ if text:
+ if text == answer:
+ return True
+ else:
+ return False
+ elif event.key == pygame.K_BACKSPACE:
+ text = text[:-1]
+ else:
+ # x = re.findall('\d', text)
+ # if x :
+ text += event.unicode
+ # print(x)
+ pygame.draw.rect(game_layout, (30, 30, 30), pygame.Rect(433, 134, 500, 500))
+ game_layout.blit(question, (433, 134))
+
+ # Render the current text.
+ txt_surface = font.render(text, True, color)
+
+ # Resize the box if the text is too long.
+ width_box = max(200, txt_surface.get_width()+10)
+
+ input_box.w = width_box
+
+ # Blit the text.
+ game_layout.blit(txt_surface, (input_box.x+5, input_box.y+5))
+
+ # Blit the input_box rect.
+ pygame.draw.rect(game_layout, color, input_box, 2)
+
+ pygame.display.update()
+
starter()
-menu()
\ No newline at end of file
+menu()
diff --git a/sound/dice1.wav b/sound/dice1.wav
new file mode 100644
index 0000000..80e81d7
Binary files /dev/null and b/sound/dice1.wav differ
diff --git a/sound/ladder2.wav b/sound/ladder2.wav
new file mode 100644
index 0000000..e4b1e39
Binary files /dev/null and b/sound/ladder2.wav differ
diff --git a/sound/loss2.wav b/sound/loss2.wav
new file mode 100644
index 0000000..8f64f4f
Binary files /dev/null and b/sound/loss2.wav differ
diff --git a/sound/loss3.wav b/sound/loss3.wav
new file mode 100644
index 0000000..9a5c978
Binary files /dev/null and b/sound/loss3.wav differ
diff --git a/sound/loss4.wav b/sound/loss4.wav
new file mode 100644
index 0000000..f324b3f
Binary files /dev/null and b/sound/loss4.wav differ
diff --git a/sound/snake2.wav b/sound/snake2.wav
new file mode 100644
index 0000000..3267ca2
Binary files /dev/null and b/sound/snake2.wav differ
diff --git a/sound/song1.wav b/sound/song1.wav
new file mode 100644
index 0000000..6c79061
Binary files /dev/null and b/sound/song1.wav differ
diff --git a/sound/win1.wav b/sound/win1.wav
new file mode 100644
index 0000000..ff89c44
Binary files /dev/null and b/sound/win1.wav differ
diff --git a/sound/win2.wav b/sound/win2.wav
new file mode 100644
index 0000000..d501f8f
Binary files /dev/null and b/sound/win2.wav differ