How to use window_height method in Selene

Best Python code snippet using selene_python

layouts.py

Source:layouts.py Github

copy

Full Screen

1import json2import os3import random4import pygame5from pygame.locals import *6from time import sleep7from . import interface8"""9Здесь рисую маленькие всплывающие окна10Сначала отрисовывается рамка, потом окно, потом кнопки11И прочее содержимое12"""13# colors14COLOR_WHITE = (255, 255, 255)15COLOR_BLACK = (0, 0, 0)16COLOR_BRIGHT_GREY = (200, 200, 200)17COLOR_RED = (255, 0, 0)18COLOR_BLUE = (0, 0, 255)19# return true if quit20def interruption_menu(window_surface, WINDOW_WIDTH, WINDOW_HEIGHT):21 pygame.mouse.set_visible(True)22 button_continue = interface.Button(WINDOW_WIDTH / 2 + 100, WINDOW_HEIGHT / 4,23 WINDOW_WIDTH / 3, WINDOW_HEIGHT / 8, "Continue")24 button_quit = interface.Button(WINDOW_WIDTH / 2 + 100, WINDOW_HEIGHT / 2,25 WINDOW_WIDTH / 3, WINDOW_HEIGHT / 8, "Quit")26 while True:27 for event in pygame.event.get():28 mouse_pos = pygame.mouse.get_pos()29 if event.type == KEYUP:30 if event.key == K_ESCAPE:31 pygame.mouse.set_visible(False)32 return False33 if button_continue.is_over(mouse_pos):34 if event.type == pygame.MOUSEBUTTONDOWN:35 pygame.mouse.set_visible(False)36 return False37 if button_quit.is_over(mouse_pos):38 if event.type == pygame.MOUSEBUTTONDOWN:39 return True40 pygame.draw.rect(window_surface, COLOR_BLACK,41 (WINDOW_WIDTH / 2 + 100 - 5, WINDOW_HEIGHT / 5 - 5,42 WINDOW_WIDTH / 3 + 10, WINDOW_HEIGHT / 2 + 10))43 pygame.draw.rect(window_surface, COLOR_BRIGHT_GREY,44 (WINDOW_WIDTH/2 + 100, WINDOW_HEIGHT/5, WINDOW_WIDTH / 3, WINDOW_HEIGHT / 2))45 button_continue.draw(window_surface)46 button_quit.draw(window_surface)47 pygame.display.update()48def stats_layout(window_surface, WINDOW_WIDTH, WINDOW_HEIGHT):49 font = pygame.font.SysFont(None, 46)50 drawable = list()51 handler = open("../stats/high_score.json", 'r')52 data = json.load(handler)53 handler.close()54 for i in range(len(data)):55 text_view = interface.TextView(font, COLOR_BLACK, WINDOW_WIDTH / 2 - 200, WINDOW_HEIGHT / 5 + i*48,56 data[str(i+1)][0] + " " + str(data[str(i+1)][1]))57 drawable.append(text_view)58 button_close = interface.Button(WINDOW_WIDTH / 2 - 260 + WINDOW_WIDTH / 3 - WINDOW_WIDTH / 20, WINDOW_HEIGHT / 5 - 50,59 WINDOW_WIDTH / 20, WINDOW_HEIGHT / 20, "x")60 while True:61 for event in pygame.event.get():62 mouse_pos = pygame.mouse.get_pos()63 if event.type == KEYUP:64 if event.key == K_ESCAPE:65 return66 if button_close.is_over(mouse_pos):67 if event.type == pygame.MOUSEBUTTONDOWN:68 return69 pygame.draw.rect(window_surface, COLOR_BLACK,70 (WINDOW_WIDTH / 2 - 268, WINDOW_HEIGHT / 5 - 58, WINDOW_WIDTH / 3+16, 3 * WINDOW_HEIGHT / 4+16))71 pygame.draw.rect(window_surface, COLOR_BRIGHT_GREY,72 (WINDOW_WIDTH / 2 - 260, WINDOW_HEIGHT / 5 - 50, WINDOW_WIDTH / 3, 3*WINDOW_HEIGHT / 4))73 for elem in drawable:74 elem.draw(window_surface)75 button_close.draw(window_surface)76 pygame.display.update()77def victory_layout(window_surface, WINDOW_WIDTH, WINDOW_HEIGHT, boss, score, new_record, new_skin):78 rect = pygame.Rect((0, 0), (2*WINDOW_WIDTH/3, 2*WINDOW_HEIGHT/3))79 rect_border = pygame.Rect((0, 0), (2*WINDOW_WIDTH/3+10, 2*WINDOW_HEIGHT/3+10))80 rect.center = (WINDOW_WIDTH/2, WINDOW_HEIGHT/2)81 rect_border.center = (WINDOW_WIDTH/2, WINDOW_HEIGHT/2)82 font0 = pygame.font.SysFont(None, 140)83 font1 = pygame.font.SysFont(None, 80)84 font2 = pygame.font.SysFont(None, 60)85 text_victory = interface.TextView(font0, COLOR_BLACK, 150, 2*WINDOW_HEIGHT / 6, "Level complete!")86 text_victory.rect.center = (WINDOW_WIDTH/2, WINDOW_HEIGHT/4)87 if boss:88 text_formula = interface.TextView(font1, COLOR_BLACK, 150, 2*WINDOW_HEIGHT / 6, "Score = (score+life*1000)*100/time")89 else:90 text_formula = interface.TextView(font1, COLOR_BLACK, 150, 2*WINDOW_HEIGHT / 6, "Score = score + life*1000")91 text_formula.rect.topleft = (WINDOW_WIDTH/4 - 70, WINDOW_HEIGHT/3 + 60)92 text_press_esc = interface.TextView(font2, COLOR_WHITE, 150, 2 * WINDOW_HEIGHT / 6, "Press ESC to continue")93 text_press_esc.rect.center = (4*WINDOW_WIDTH / 5, 8*WINDOW_HEIGHT / 9)94 pygame.draw.rect(window_surface, COLOR_BLACK, rect_border)95 pygame.draw.rect(window_surface, COLOR_BRIGHT_GREY, rect)96 text_victory.draw(window_surface)97 text_formula.draw(window_surface)98 text_formula.next_line(90)99 text_formula.draw_this(window_surface, "Your score is " + str(score))100 if new_record:101 sleep(0.5)102 new_top_sound = pygame.mixer.Sound('../sound/short_tracks/health.wav')103 new_top_sound.play()104 text_formula.color = COLOR_RED105 text_formula.next_line(100)106 text_formula.draw_this(window_surface, "New level record!")107 if new_skin:108 sleep(0.5)109 text_formula.color = COLOR_BLUE110 text_formula.next_line(100)111 text_formula.draw_this(window_surface, "New skin available!")112 text_press_esc.draw(window_surface)113 pygame.display.update()114 while True:115 for event in pygame.event.get():116 if event.type == KEYUP:117 if event.key == K_ESCAPE:118 return119def defeat_layout(window_surface, WINDOW_WIDTH, WINDOW_HEIGHT):120 font0 = pygame.font.SysFont(None, 200)121 font1 = pygame.font.SysFont(None, 80)122 text_view_message = interface.TextView(font0, COLOR_WHITE, 150, 2*WINDOW_HEIGHT / 6,123 "Game over, bro =(")124 text_view_message.draw(window_surface)125 text_view_press_esc = interface.TextView(font1, COLOR_WHITE, WINDOW_WIDTH / 2 - 200, 3*WINDOW_HEIGHT / 5,126 "Press ESC to exit...")127 text_view_press_esc.draw(window_surface)128 pygame.display.update()129 while True:130 for event in pygame.event.get():131 if event.type == KEYUP:132 if event.key == K_ESCAPE:133 return134# returning player135def create_profile_layout(window_surface, player, WINDOW_WIDTH, WINDOW_HEIGHT):136 player.save_current_state()137 clock = pygame.time.Clock()138 rect = pygame.Rect((0, 0), (2 * WINDOW_WIDTH / 3, WINDOW_HEIGHT / 3))139 rect_border = pygame.Rect((0, 0), (2 * WINDOW_WIDTH / 3 + 10, WINDOW_HEIGHT / 3 + 10))140 rect.center = (WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2)141 rect_border.center = (WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2)142 input_box = interface.InputBox(WINDOW_WIDTH/4, 4*WINDOW_HEIGHT/8, 220, 80)143 font0 = pygame.font.SysFont(None, 100)144 font1 = pygame.font.SysFont(None, 78)145 input_box.font = font1146 text_write_name = interface.TextView(font0, COLOR_BLACK, 150, 2 * WINDOW_HEIGHT / 6, "Write your name here")147 text_write_name.rect.center = (WINDOW_WIDTH / 2, 2*WINDOW_HEIGHT / 5)148 button_done = interface.Button(2*WINDOW_WIDTH / 3, 4*WINDOW_HEIGHT / 8,149 WINDOW_WIDTH / 15, WINDOW_HEIGHT / 10, "Done")150 done = False151 while not done:152 for event in pygame.event.get():153 mouse_pos = pygame.mouse.get_pos()154 if event.type == pygame.QUIT:155 done = True156 if button_done.is_over(mouse_pos):157 if event.type == pygame.MOUSEBUTTONDOWN:158 print(input_box.text)159 name = input_box.text.strip()160 if not name:161 done = True162 continue163 path = '../stats/players/' + name + '.json'164 if os.path.isfile(path):165 print("Exist")166 player = interface.load_player_by_path(path)167 else:168 print("Not exist")169 interface.create_empty_profile(name)170 player = interface.load_player_by_path(path)171 input_box.text = ''172 done = True173 if event.type == KEYUP:174 if event.key == K_ESCAPE:175 done = True176 elif event.key == pygame.K_RETURN: # if enter177 print(input_box.text)178 name = input_box.text.strip()179 if not name:180 done = True181 continue182 path = '../stats/players/' + name + '.json'183 if os.path.isfile(path):184 print("Exist")185 player = interface.load_player_by_path(path)186 else:187 print("Not exist")188 interface.create_empty_profile(name)189 player = interface.load_player_by_path(path)190 input_box.text = ''191 done = True192 input_box.handle_event(event)193 input_box.update()194 pygame.draw.rect(window_surface, COLOR_BLACK, rect_border)195 pygame.draw.rect(window_surface, COLOR_BRIGHT_GREY, rect)196 text_write_name.draw(window_surface)197 input_box.draw(window_surface)198 button_done.draw(window_surface)199 pygame.display.update()200 clock.tick(30)201 return player202# returning player203def change_skin_layout(window_surface, player, WINDOW_WIDTH, WINDOW_HEIGHT):204 rect = pygame.Rect((0, 0), (2 * WINDOW_WIDTH / 3, 2 * WINDOW_HEIGHT / 3))205 rect_border = pygame.Rect((0, 0), (2 * WINDOW_WIDTH / 3 + 10, 2 * WINDOW_HEIGHT / 3 + 10))206 rect.center = (WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2)207 rect_border.center = (WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2)208 font0 = pygame.font.SysFont(None, 120)209 text_title = interface.TextView(font0, COLOR_BLACK, 150, 2 * WINDOW_HEIGHT / 6, "Select skin")210 text_title.rect.center = (WINDOW_WIDTH / 2, WINDOW_HEIGHT / 4)211 skin_levels = [1, 6, 8, 9, 10, 12]212 buttons = list()213 for i, skin in enumerate(skin_levels):214 if skin in player.skins:215 button = interface.Button(WINDOW_WIDTH / 5 + (i % 3) * (WINDOW_WIDTH / 6 + 40) + 50,216 WINDOW_HEIGHT / 3 + int(i / 3) * (WINDOW_HEIGHT / 8 + 70),217 WINDOW_WIDTH / 8, WINDOW_HEIGHT / 6, str(skin))218 button.font = pygame.font.SysFont(None, 64)219 else:220 button = interface.Button(WINDOW_WIDTH / 5 + (i % 3) * (WINDOW_WIDTH / 6 + 40) + 50,221 WINDOW_HEIGHT / 3 + int(i / 3) * (WINDOW_HEIGHT / 8 + 70),222 WINDOW_WIDTH / 8, WINDOW_HEIGHT / 6, str(skin), True)223 button.font = pygame.font.SysFont(None, 64)224 buttons.append(button)225 while True:226 mouse_pos = pygame.mouse.get_pos() # gets mouse position227 for event in pygame.event.get():228 if event.type == KEYUP:229 if event.key == K_ESCAPE:230 return player231 for button in buttons:232 if button.is_over(mouse_pos):233 if event.type == pygame.MOUSEBUTTONDOWN and not button.is_off:234 player.current_skin = int(button.text)235 print("Current skin is", player.current_skin)236 return player237 pygame.draw.rect(window_surface, COLOR_BLACK, rect_border)238 pygame.draw.rect(window_surface, COLOR_BRIGHT_GREY, rect)239 text_title.draw(window_surface)240 for button in buttons:241 button.draw(window_surface)242 pygame.display.update()243def future_layout(window_surface, WINDOW_WIDTH, WINDOW_HEIGHT):244 rect = pygame.Rect((0, 0), (2 * WINDOW_WIDTH / 3, 2 * WINDOW_HEIGHT / 3))245 rect_border = pygame.Rect((0, 0), (2 * WINDOW_WIDTH / 3 + 10, 2 * WINDOW_HEIGHT / 3 + 10))246 rect.center = (WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2)247 rect_border.center = (WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2)248 font0 = pygame.font.SysFont(None, 120)249 font1 = pygame.font.SysFont(None, 70)250 text_title = interface.TextView(font0, COLOR_BLACK, 150, 2 * WINDOW_HEIGHT / 6, "Developers")251 text_title.rect.center = (WINDOW_WIDTH / 2, WINDOW_HEIGHT / 4)252 pygame.draw.rect(window_surface, COLOR_BLACK, rect_border)253 pygame.draw.rect(window_surface, COLOR_BRIGHT_GREY, rect)254 text_title.draw(window_surface)255 text_future = interface.TextView(font1, COLOR_BLACK, 150, 2 * WINDOW_HEIGHT / 6)256 text_future.rect.center = (WINDOW_WIDTH / 5, WINDOW_HEIGHT / 3)257 text_future.next_line(82)258 text_future.draw_this(window_surface, "Vladislav Cepelev (teamlead)")259 text_future.next_line(82)260 text_future.draw_this(window_surface, "Alexander Zorkin (programmer)")261 text_future.next_line(82)262 text_future.draw_this(window_surface, "Rufina Rafikova (programmer/storywriter)")263 text_future.next_line(82)264 text_future.draw_this(window_surface, "Anastasia Politova (game designer)")265 pygame.display.update()266 while True:267 for event in pygame.event.get():268 if event.type == KEYUP:269 return270 if event.type == MOUSEBUTTONDOWN:271 return272def two_players_victory_layout(window_surface, WINDOW_WIDTH, WINDOW_HEIGHT, score, time):273 rect = pygame.Rect((0, 0), (2 * WINDOW_WIDTH / 3, 2 * WINDOW_HEIGHT / 3))274 rect_border = pygame.Rect((0, 0), (2 * WINDOW_WIDTH / 3 + 10, 2 * WINDOW_HEIGHT / 3 + 10))275 rect.center = (WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2)276 rect_border.center = (WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2)277 font0 = pygame.font.SysFont(None, 140)278 font1 = pygame.font.SysFont(None, 80)279 font2 = pygame.font.SysFont(None, 60)280 text_victory = interface.TextView(font0, COLOR_BLACK, 150, 2 * WINDOW_HEIGHT / 6, "Nice game!")281 text_victory.rect.center = (WINDOW_WIDTH / 2, 2*WINDOW_HEIGHT / 8)282 pygame.draw.rect(window_surface, COLOR_BLACK, rect_border)283 pygame.draw.rect(window_surface, COLOR_BRIGHT_GREY, rect)284 handler = open("../stats/multiplayer_score.json", 'r')285 data = json.load(handler)286 handler.close()287 text_victory.draw(window_surface)288 score_and_time_text = interface.TextView(font1, COLOR_BLACK, 150, 2 * WINDOW_HEIGHT / 6)289 score_and_time_text.rect.center = (WINDOW_WIDTH / 5, WINDOW_HEIGHT / 3 + 30)290 score_and_time_text.draw_this(window_surface, "Your score is " + str(score))291 score_and_time_text.next_line(82)292 score_and_time_text.draw_this(window_surface, "Your time is " + str(time))293 score_and_time_text.next_line(82)294 handler = open("../stats/multiplayer_score.json", 'w')295 score_and_time_text.color = COLOR_RED296 if score > data["Top score"] and time > data["Top time"]:297 score_and_time_text.draw_this(window_surface, "New top score and time!")298 data["Top score"] = score299 data["Top time"] = time300 elif score > data["Top score"]:301 score_and_time_text.draw_this(window_surface, "New top score!")302 data["Top score"] = score303 elif time > data["Top time"]:304 score_and_time_text.draw_this(window_surface, "New top time!")305 data["Top time"] = time306 score_and_time_text.color = COLOR_BLACK307 json.dump(data, handler)308 handler.close()309 score_and_time_text.next_line(82)310 score_and_time_text.draw_this(window_surface, "Top score: " + str(data["Top score"]))311 score_and_time_text.next_line(82)312 score_and_time_text.draw_this(window_surface, "Top time: " + str(data["Top time"]))313 text_press_esc = interface.TextView(font2, COLOR_WHITE, 150, 2 * WINDOW_HEIGHT / 6, "Press ESC to exit")314 text_press_esc.rect.center = (4*WINDOW_WIDTH / 5, 7*WINDOW_HEIGHT / 8)315 text_press_esc.draw(window_surface)316 pygame.display.update()317 while True:318 for event in pygame.event.get():319 if event.type == KEYUP:320 if event.key == K_ESCAPE:321 return322def giving_port_layout(window_surface, WINDOW_WIDTH, WINDOW_HEIGHT):323 rect = pygame.Rect((0, 0), (2 * WINDOW_WIDTH / 3, 2 * WINDOW_HEIGHT / 3))324 rect_border = pygame.Rect((0, 0), (2 * WINDOW_WIDTH / 3 + 10, 2 * WINDOW_HEIGHT / 3 + 10))325 rect.center = (WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2)326 rect_border.center = (WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2)327 port = random.randint(10000, 14000)328 font0 = pygame.font.SysFont(None, 140)329 text_victory = interface.TextView(font0, COLOR_BLACK, 150, 2 * WINDOW_HEIGHT / 6, "Your port is " + str(port))330 text_victory.rect.center = (WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2)331 pygame.display.update()332 button_done = interface.Button(2 * WINDOW_WIDTH / 3, 5 * WINDOW_HEIGHT / 8 + 60,333 WINDOW_WIDTH / 6, WINDOW_HEIGHT / 8, "We are ready!")334 while True:335 for event in pygame.event.get():336 mouse_pos = pygame.mouse.get_pos()337 if event.type == QUIT:338 exit(0)339 if event.type == KEYUP:340 if event.key == K_ESCAPE:341 return port342 if button_done.is_over(mouse_pos):343 if event.type == pygame.MOUSEBUTTONDOWN:344 return port345 pygame.draw.rect(window_surface, COLOR_BLACK, rect_border)346 pygame.draw.rect(window_surface, COLOR_BRIGHT_GREY, rect)347 text_victory.draw(window_surface)348 button_done.draw(window_surface)...

Full Screen

Full Screen

fond.py

Source:fond.py Github

copy

Full Screen

...1415scene = turtle.Screen()16scene.setup(width=1.0, height=1.0)17x=-0.5*window_width()18y=-0.15*window_height()19couleurC="deep sky blue"20couleurS="medium sea green"212223def fond(xCote,yCote,yCotee,x,y,couleurC,couleurS,tailleC,hauteur,largeur):24 #speed("fastest")25 tracer(0)26 dessineRect(4,xCote,yCote,x,y,couleurC)#dessine le ciel27 right(90)28 dessineRect(4,yCotee,xCote,x,y,couleurS)#dessine le sol 2930 31 right(200)32 #on décine les montagnes 33 i=x34 color("gainsboro")35 begin_fill()36 forward(0.5*window_height())37 right(140)38 forward39 forward(0.5*window_height())40 up()41 forward(-0.2*window_height())42 down()43 left(135)44 forward(0.15*window_height())45 right(130)46 forward(0.164*window_height())47 left(65)48 up()49 x=x+2*0.5*window_height()*cos(math.radians(70))50 goto(x,y)51 down()52 left(70)53 forward(0.65*window_height())54 right(140)55 forward(0.65*window_height())56 up()57 forward(-0.3*window_height())58 down()59 left(135)60 forward(0.2*window_height())61 right(130)62 forward(0.51*window_height())63 left(65)64 65 x=x+2.5*0.65*window_height()*cos(math.radians(70))66 6768 69#permt de compléter la chaine de montagne en répétant les 3 premières 70 while i<0.5*window_width():71 up()72 goto(x,y)73 left(70)74 down()75 forward(0.5*window_height())76 right(140)77 forward78 forward(0.5*window_height())79 up()80 forward(-0.2*window_height())81 down()82 left(135)83 forward(0.15*window_height())84 right(130)85 forward(0.164*window_height())86 left(65)87 up()88 x=x+2*0.5*window_height()*cos(math.radians(70))89 goto(x,y)90 down()91 left(70)92 forward(0.65*window_height())93 right(140)94 forward(0.65*window_height())95 left(70)96 x=x+2*0.60*window_height()*cos(math.radians(70))97 i=x98 x=-0.5*window_width()99 goto(x,y)100 end_fill()101102 #on dessine la neige de la première montagne 103 color("white")104 up()105 x=x+2*0.5*window_height()*cos(math.radians(70))106 goto(x,y)107 left(70)108 forward(0.53*window_height())109 down()110 begin_fill()111 forward(0.12*window_height())112 right(140)113 forward(0.12*window_height())114 right(35)115 forward(0.03*window_height())116 right(135)117 forward(0.03*window_height())118 left(135)119 forward(0.05*window_height())120 right(140)121 forward(0.05*window_height())122 left(135)123 forward(0.03*window_height())124 right(140)125 forward(0.03*window_height())126 end_fill()127 128 #on dessine la neige de la deuxième montagne129 right(110)130 up()131 x=x+2.5*0.65*window_height()*cos(math.radians(70))132 x=x+2*0.5*window_height()*cos(math.radians(70))133 goto(x,y)134 left(70)135 forward(0.53*window_height())136 down()137 begin_fill()138 forward(0.12*window_height())139 right(140)140 forward(0.12*window_height())141 right(35)142 forward(0.03*window_height())143 right(135)144 forward(0.03*window_height())145 left(135)146 forward(0.05*window_height())147 right(140)148 forward(0.05*window_height())149 left(135)150 forward(0.03*window_height())151 right(140)152 forward(0.03*window_height())153 end_fill()154155 #on dessine la neige de la troisième montagne156 right(110)157 up()158 x=x+2*0.60*window_height()*cos(math.radians(70))159 x=x+2*0.5*window_height()*cos(math.radians(70))160 goto(x,y)161 left(70)162 forward(0.53*window_height())163 down()164 begin_fill()165 forward(0.12*window_height())166 right(140)167 forward(0.12*window_height())168 right(35)169 forward(0.03*window_height())170 right(135)171 forward(0.03*window_height())172 left(135)173 forward(0.05*window_height())174 right(140)175 forward(0.05*window_height())176 left(135)177 forward(0.03*window_height())178 right(140)179 forward(0.03*window_height())180 end_fill()181182 #on déssine la carte183 up()184 left(250)185 s=0186 ps=-0.47*window_width()187 while s<window_width()-150:188 sapinf(0.47,-0.47*window_width()+s,-0.15*window_height(),"dark green","green","forest green")189 s=s+0.041*window_width()190 s2=0191 while s2<window_width():192 sapinf(0.60,-0.445*window_width()+s2,-0.17*window_height(),"dark green","green","forest green")193 s2=s2+0.06*window_width()194195 #on place les pions sur le fond196 sapin(0.8,-0.37*window_width(),-0.36*window_height(),"sea green")197 boule(0.84,-0.18*window_width(),-0.4*window_height(),"crimson")198 etoile(0.8,-0.065*window_width(),-0.28*window_height(),"gold")199 cadeau(0.7,0.28*window_width(),-0.4*window_height(),"royal blue")200 bonhommeNeige(0.5,0.15*window_width(),-0.4*window_height(),"white smoke")201 202203204205206207208 up()209 goto((0.40*window_height())/2,0.01*window_height())210 down()211 color("ivory")212 begin_fill()213 carte(tailleC,hauteur,largeur)214 end_fill()215 goto((0.96*(0.40*window_height()))/2,0.018*window_height())216 #color("white")217 pensize(5)218 pencolor("black")219 carte(tailleC,0.96*hauteur,0.92*largeur)220 ...

Full Screen

Full Screen

levels.py

Source:levels.py Github

copy

Full Screen

1class Level:2 """Represents a level in the game."""3 def __init__(self, name, points, rectangles, end_rect):4 self.name = name5 self.points = points6 self.rectangles = rectangles7 self.end_rect = end_rect8def level1(window_width, window_height, line_length) -> Level:9 points = [10 (25, window_height - 20),11 (20, window_height - 20 - line_length)12 ]13 rectangles = [14 (200, window_height - 300, 100, 100)15 ]16 end_rect = (window_width - 100, 0, 100, 100)17 return Level("Level 1", points, rectangles, end_rect)18def level2(window_width, window_height, line_length) -> Level:19 points = [20 (25, window_height - 20),21 (20, window_height - 20 - line_length)22 ]23 rectangles = [24 (window_width - 500, window_height - 100, 200, 100),25 (window_width - 300, window_height - 150, 200, 150),26 (window_width - 100, window_height - 200, 100, 200),27 (0, 0, window_width, window_height - 300),28 ]29 end_rect = (window_width - 100, window_height - 300, 100, 100)30 return Level("Level 2", points, rectangles, end_rect)31def level3(window_width, window_height, line_length) -> Level:32 points = [33 (100, window_height - 20),34 (100 + line_length, window_height - 20)35 ]36 rectangles = [37 (0, 0, 50, window_height),38 (window_width - 50, 0, 50, window_height),39 (50, window_height - 200, 400, 25),40 (300, 100, 400, 25),41 ]42 end_rect = (window_width - 150, 0, 100, 100)43 return Level("Level 3", points, rectangles, end_rect)44def level4(window_width, window_height, line_length) -> Level:45 points = [46 (30, window_height - 20),47 (30 + line_length, window_height - 20)48 ]49 rectangles = [50 (0, 0, 5, window_height),51 (5, 0, window_width - 5, 5),52 (150, 135, window_width - 150, window_height - 135),53 ]54 end_rect = (window_width - 100, 5, 100, 130)55 return Level("Level 4", points, rectangles, end_rect)56def level5(window_width, window_height, line_length) -> Level:57 points = [58 (25, window_height - 20),59 (20, window_height - 20 - line_length)60 ]61 rectangles = [62 (0, 0, 100, window_height - 150),63 (100, 0, 100, window_height - 250),64 (200, window_height - 100, 100, 100),65 (200, 0, 100, window_height - 350),66 (300, window_height - 200, 100, 200),67 (300, 0, window_width - 300, window_height - 450),68 (400, window_height - 300, 100, 300),69 (500, window_height - 350, window_width - 500, 350),70 ]71 end_rect = (window_width - 100, window_height - 450, 100, 100)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Selene automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful