Skip to content

Commit

Permalink
initial commit with base structure of the project
Browse files Browse the repository at this point in the history
  • Loading branch information
RaffaeleFiorillo committed Nov 28, 2022
1 parent d5e9445 commit 462c4f2
Show file tree
Hide file tree
Showing 23 changed files with 129 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/Stick-Man AI.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from src.Game import Game
from src.AI import AIRaffaele, AIRoberto
import pygame
pygame.init()

WIDTH, HEIGHT = 1080, 720
BG_COLOR = (0, 0, 0) # default is (0, 150, 150)
BG = pygame.Surface((WIDTH, HEIGHT))
BG.fill(BG_COLOR) # set screen with background color
FPS = 1
CLOCK = pygame.time.Clock()
SCREEN = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Stick-Man A.I.")


def main():
partita = Game(SCREEN, CLOCK, [AIRaffaele, AIRoberto])
partita.start()


if __name__ == "__main__":
main()
3 changes: 3 additions & 0 deletions src/AI/AIBase.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class AIBase:
def __init__(self):
pass
6 changes: 6 additions & 0 deletions src/AI/AIRaffaele.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from src.AI.AIBase import AIBase


class AIRaffaele(AIBase):
def __init__(self):
super().__init__()
6 changes: 6 additions & 0 deletions src/AI/AIRoberto.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from src.AI.AIBase import AIBase


class AIRoberto(AIBase):
def __init__(self):
super().__init__()
2 changes: 2 additions & 0 deletions src/AI/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from src.AI.AIRaffaele import AIRaffaele
from src.AI.AIRoberto import AIRoberto
Binary file added src/AI/__pycache__/AIBase.cpython-39.pyc
Binary file not shown.
Binary file added src/AI/__pycache__/AIRaffaele.cpython-39.pyc
Binary file not shown.
Binary file added src/AI/__pycache__/AIRoberto.cpython-39.pyc
Binary file not shown.
Binary file added src/AI/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
3 changes: 3 additions & 0 deletions src/Game/Environment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Environment:
def __init__(self):
pass
38 changes: 38 additions & 0 deletions src/Game/Game.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import random
from src.Game.Player import Player
import pygame


class Game:
def __init__(self, screen, clock, AIs):
self.screen: pygame.Surface = screen
self.clock = clock
rand = random.choice([1, 0]) # alternate between player 1 and 2
self.player_1 = Player(AIs[0], rand)
self.player_2 = Player(AIs[1], 1-rand)

def start(self):
self.game_loop()

def draw_background(self):
pygame.draw.line(self.screen, (0, 255, 255), (0, 480), (1080, 480))

def draw_hud(self):
pass

def refresh(self):
self.draw_background()
self.player_1.draw(self.screen)
self.player_2.draw(self.screen)
self.draw_hud()
pygame.display.update()

def game_loop(self):
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
exit()
"""elif event.type == pygame.MOUSEBUTTONUP and event.button == 1: # mouse click
pass"""
self.refresh()
self.clock.tick(30)
6 changes: 6 additions & 0 deletions src/Game/HUD.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class HUD:
def __init__(self, num):
self.number = num

def draw(self, screen):
pass
10 changes: 10 additions & 0 deletions src/Game/Player.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from src.Game.HUD import HUD


class Player:
def __init__(self, ai, num):
self.AI = ai
self.HUD = HUD(num)

def draw(self, screen):
self.HUD.draw(screen)
1 change: 1 addition & 0 deletions src/Game/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from src.Game.Game import Game
Binary file added src/Game/__pycache__/Game.cpython-39.pyc
Binary file not shown.
Binary file added src/Game/__pycache__/HUD.cpython-39.pyc
Binary file not shown.
Binary file added src/Game/__pycache__/Player.cpython-39.pyc
Binary file not shown.
Binary file added src/Game/__pycache__/__init__.cpython-39.pyc
Binary file not shown.

0 comments on commit 462c4f2

Please sign in to comment.