- By Muhammad Umar Anzar
- Seat No. B19102104
- University Of Karachi
- UBIT department of computer science
- Semester 5
- Subject Computer Theory (Automata)
A basic two-player 2D soccer game created in Python with the Pygame framework.
The goal was to include a finite state machine in a project.
- Language: python3
- Library: pygame
- requirements to play : Two user and only one keyboard
-
Python
pygame
is used to make the entire GUI game, andauto-py-to-exe
is used to make the executable file. -
The player's entire movement is controlled by a finite state machine (Deterministic Finite Automata). To handle the movement
key release
andkey pressed
events, a new condition and additionalset array
are introduced. When a user presses numerous keys and only one or two of them are released, the unique condition causes the transition to return to the initial state and utilizing the set array, the keys that haven’t been released yet cause the transition to new states following the keys that are already pressed.
self.TransitionsTable = [
[1,2,3,4,5], #initial 0
[1,1,3,4,5], #right 1
[2,2,3,4,5], #left 2
[1,2,3,3,5], #up 3
[1,2,4,4,5], #down 4
[1,2,3,4,5] #sprint 5
]