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
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* Lucas Almeida (lalmeida32)
* Gustavo Sampaio (GusSampaio)
* Angelo Antonio Bertoli Guido (angelobguido)
* Jesus Sena Fernandes (SenaJesus)



Expand Down
21 changes: 21 additions & 0 deletions sucury.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ def main_menu(): #Main Menu Screen
button.update(SCREEN)

for event in pygame.event.get():
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_F11:
fullscreen()
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
Expand Down Expand Up @@ -350,6 +353,22 @@ def grid_resize():

pygame.display.update()

##
## Toggle fullscreen on game window
##

def fullscreen():
global WIDTH, HEIGHT, SCREEN, width_temp, height_temp
if bool(SCREEN.get_flags() & pygame.FULLSCREEN): # Check if FULLSCREEN flag is activated
SCREEN = pygame.display.set_mode((width_temp, height_temp)) # Returns window size to original
WIDTH, HEIGHT = width_temp, height_temp
draw_grid()
else:
width_temp, height_temp = WIDTH, HEIGHT
SCREEN = pygame.display.set_mode((0, 0), pygame.FULLSCREEN) # Enables FULLSCREEN flag
WIDTH, HEIGHT = pygame.display.get_surface().get_size()
draw_grid()

Comment on lines +360 to +371
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a problem in this function. The way we are placing objects at the screen depends on the WIDTH and HEIGHT. When you die and resets at fullscreen, the game is crashing. It happens when you enter fullscreen and press start too.

##
## Draw the color menu
##
Expand Down Expand Up @@ -406,6 +425,8 @@ def play():

# Key pressed
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_F11: # F11: toggle fullscreen
fullscreen()
if game_on:
if event.key == pygame.K_DOWN and snake.ymov == 0: # Down arrow: move down
snake.ymov = 1
Expand Down