From 462c4f21d785adf1e76ff57dd5311b344244dab8 Mon Sep 17 00:00:00 2001 From: RaffaeleFiorillo Date: Mon, 28 Nov 2022 21:24:15 -0100 Subject: [PATCH] initial commit with base structure of the project --- .idea/.gitignore | 3 ++ .idea/Stick-Man AI.iml | 8 ++++ .../inspectionProfiles/profiles_settings.xml | 6 +++ .idea/misc.xml | 7 ++++ .idea/modules.xml | 8 ++++ main.py | 22 ++++++++++ src/AI/AIBase.py | 3 ++ src/AI/AIRaffaele.py | 6 +++ src/AI/AIRoberto.py | 6 +++ src/AI/__init__.py | 2 + src/AI/__pycache__/AIBase.cpython-39.pyc | Bin 0 -> 413 bytes src/AI/__pycache__/AIRaffaele.cpython-39.pyc | Bin 0 -> 525 bytes src/AI/__pycache__/AIRoberto.cpython-39.pyc | Bin 0 -> 522 bytes src/AI/__pycache__/__init__.cpython-39.pyc | Bin 0 -> 253 bytes src/Game/Environment.py | 3 ++ src/Game/Game.py | 38 ++++++++++++++++++ src/Game/HUD.py | 6 +++ src/Game/Player.py | 10 +++++ src/Game/__init__.py | 1 + src/Game/__pycache__/Game.cpython-39.pyc | Bin 0 -> 1553 bytes src/Game/__pycache__/HUD.cpython-39.pyc | Bin 0 -> 538 bytes src/Game/__pycache__/Player.cpython-39.pyc | Bin 0 -> 631 bytes src/Game/__pycache__/__init__.cpython-39.pyc | Bin 0 -> 195 bytes 23 files changed, 129 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/Stick-Man AI.iml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 main.py create mode 100644 src/AI/AIBase.py create mode 100644 src/AI/AIRaffaele.py create mode 100644 src/AI/AIRoberto.py create mode 100644 src/AI/__init__.py create mode 100644 src/AI/__pycache__/AIBase.cpython-39.pyc create mode 100644 src/AI/__pycache__/AIRaffaele.cpython-39.pyc create mode 100644 src/AI/__pycache__/AIRoberto.cpython-39.pyc create mode 100644 src/AI/__pycache__/__init__.cpython-39.pyc create mode 100644 src/Game/Environment.py create mode 100644 src/Game/Game.py create mode 100644 src/Game/HUD.py create mode 100644 src/Game/Player.py create mode 100644 src/Game/__init__.py create mode 100644 src/Game/__pycache__/Game.cpython-39.pyc create mode 100644 src/Game/__pycache__/HUD.cpython-39.pyc create mode 100644 src/Game/__pycache__/Player.cpython-39.pyc create mode 100644 src/Game/__pycache__/__init__.cpython-39.pyc diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/Stick-Man AI.iml b/.idea/Stick-Man AI.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/.idea/Stick-Man AI.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..009ceba --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..c1aa5c8 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..187e67f --- /dev/null +++ b/main.py @@ -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() diff --git a/src/AI/AIBase.py b/src/AI/AIBase.py new file mode 100644 index 0000000..dfaa2bc --- /dev/null +++ b/src/AI/AIBase.py @@ -0,0 +1,3 @@ +class AIBase: + def __init__(self): + pass diff --git a/src/AI/AIRaffaele.py b/src/AI/AIRaffaele.py new file mode 100644 index 0000000..d872ed5 --- /dev/null +++ b/src/AI/AIRaffaele.py @@ -0,0 +1,6 @@ +from src.AI.AIBase import AIBase + + +class AIRaffaele(AIBase): + def __init__(self): + super().__init__() diff --git a/src/AI/AIRoberto.py b/src/AI/AIRoberto.py new file mode 100644 index 0000000..6819c50 --- /dev/null +++ b/src/AI/AIRoberto.py @@ -0,0 +1,6 @@ +from src.AI.AIBase import AIBase + + +class AIRoberto(AIBase): + def __init__(self): + super().__init__() diff --git a/src/AI/__init__.py b/src/AI/__init__.py new file mode 100644 index 0000000..510c271 --- /dev/null +++ b/src/AI/__init__.py @@ -0,0 +1,2 @@ +from src.AI.AIRaffaele import AIRaffaele +from src.AI.AIRoberto import AIRoberto diff --git a/src/AI/__pycache__/AIBase.cpython-39.pyc b/src/AI/__pycache__/AIBase.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..55fcef8b0d50569d4229451854105c7f9046f6e5 GIT binary patch literal 413 zcmY*U%}N6?5T0aLS&BsvAD{;>1@-8mh_tpKMchmAvIIg%qAt7L*39;xSL?(0O1b(7 z-aI+kb+Hb7-^`c!jq3M%Kz4Hat}n=c2C-`qi7^3>h;G1uVOzo*&%p2n3?ohN|BRCw z6Y!YGLdFba+%UtpkVPhnHyhy$hsjEM|TElWR$e2lhyaA9;q-=pbB z+@p0UX37RG=QLolwQRliiyHnL*G8gEyAlGg@U%&W7%Dl>JDZ@An1nl+j zH{az_x{?YjwX{$~NQnx|9BnbK!W`eWzKFutulD*6-9dUkVLA NxolTlh0ZSm`~b`tQ04#t literal 0 HcmV?d00001 diff --git a/src/AI/__pycache__/AIRaffaele.cpython-39.pyc b/src/AI/__pycache__/AIRaffaele.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d56a965986969e2851b95f0b7597bde917a5e3e6 GIT binary patch literal 525 zcmYjOy-ve05I*Mz(yC!$W$3^X3HksCRRoYwgy=xU5=FAC*ny~NTH+K5))w_OVC*Y- zW#Sc>xJxU@$#=d_XMgwECw#vPXvZh-=?m^(1lr~xxIou^3=$+OV9H{~;0B~6?G;E{ zv85eb(iubGe&Z*)oKI(RQBdCF{COdYZKa_y{!Uz~ih}d1gQVNAPZ`asqIc6+ onwB1G@F=ij9|aD=2p4^QMS_}Ii=?3=662k3RSfAj8>XK93rst5RR910 literal 0 HcmV?d00001 diff --git a/src/AI/__pycache__/AIRoberto.cpython-39.pyc b/src/AI/__pycache__/AIRoberto.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..558a77ff011fd1449cc85a6f05e2ba0f6b7cf2a5 GIT binary patch literal 522 zcmYjOy-ve05I*Mz(yC!#X6V3D3HksC5P?c4LUf>Fi6U7cb|Gq-6gwSYZBbtX#=eqQ zCSHMwyR<4f`Of$0?C(CG6W?zG+VROpI>-H+K+_xqSLnKnL4aU6Oj*Pj+=8%#y#!%P zwy+~hI3wt}KX?jy%b)scTuxa)d=p#%dL`*=if=5tVIPLHJNU zNmZ38Yj99*p%axpz)-;gKG_#A)Q1<@uxA-p&u3B@kMpd^D$Y@oqh&r`Gt=Tc%@eIT zU&HUk%~|}YrPA>rQIqankv+du@j&WHRnFp3m8Fx@`=sawVXRdev;+mmY& z1nm9rzq;$}l8PdkO3qE2^JyvOIprPBU*}1_snkry-%3kmo^!5R$hisol+i~idNut? n-O*z;9^$Zkl-CbJTr_t@dg@w(q^2Vhg`k0u`Os^#UML*7y*w^J%s=O literal 0 HcmV?d00001 diff --git a/src/Game/Environment.py b/src/Game/Environment.py new file mode 100644 index 0000000..c27b3c2 --- /dev/null +++ b/src/Game/Environment.py @@ -0,0 +1,3 @@ +class Environment: + def __init__(self): + pass diff --git a/src/Game/Game.py b/src/Game/Game.py new file mode 100644 index 0000000..2a83dd5 --- /dev/null +++ b/src/Game/Game.py @@ -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) diff --git a/src/Game/HUD.py b/src/Game/HUD.py new file mode 100644 index 0000000..218ede8 --- /dev/null +++ b/src/Game/HUD.py @@ -0,0 +1,6 @@ +class HUD: + def __init__(self, num): + self.number = num + + def draw(self, screen): + pass diff --git a/src/Game/Player.py b/src/Game/Player.py new file mode 100644 index 0000000..216890b --- /dev/null +++ b/src/Game/Player.py @@ -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) diff --git a/src/Game/__init__.py b/src/Game/__init__.py new file mode 100644 index 0000000..d9c44e7 --- /dev/null +++ b/src/Game/__init__.py @@ -0,0 +1 @@ +from src.Game.Game import Game diff --git a/src/Game/__pycache__/Game.cpython-39.pyc b/src/Game/__pycache__/Game.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5b422732eececb83e185c5ba351c6fb89d740400 GIT binary patch literal 1553 zcmZuxOK%fN5bo~jdDz$v%d$L#cwFZ|Bsi@igkXt;B7_ABTt-HtVY+d~o{XLDF>E4p zg8d)%F@LE~D{;zS-~v@Oab!r^>YD26?yB#rs&>}xwi%4>!~gQJWb7L*)`tg+Cot_M z2*ngHS%P0t@_msA-q^gvd(M=n=zSK=#6yv85+@>Kw9Uxg}yZ=hPL4c|~*QXTk4std7tPCn1}bq*ZPh7TI9 zpTV^MfSB_+OW9n29X1 z#QVq0TmsAYt!G<> z(?b`fX;Bq*nnvKsQi*v0zaGELkGgntb9Ev|DyxAyf~J&pK$)`zTQV&3E<5H}%hnKX zr{!caJ>~{I6WT`L4d>fBGxY|j7F{uZ)TV%BJ{JwiQ?whP)NI5TP=FDYMtMuwM2=-Y z_9*8kKj4_T0wNZT;eWs!i{fvnwD}Y5(go8)1nHzQ*(WEj)5g!ytwxIW5$%3g#*Z7plTy=el4v zRavdgMN~qgKNxNI@Y-pcMbKnD9`U0NCGYgWFNCly&IsYtZ|c5e+w9%7&wS2D9$4g9 zn0D=d0TKsopd26xAPIC7M~VlO>{#?q?tl+qMYw(aQCGF|hPrmLKAh@AzJ9y&#!3Be zQJY(EvUzY49}qMVweW2;|JoP^JNPb4i(Sn`k9Xh!2?5M{#0*=E-a$WZ;e)Giow|0K z?oZULM7@)y2eYhfc1#!Cm_JZZ`YF|f2P3UTCma~mV3I&47 i{5J_w^EXR>JCqDMc9CZnJ!(Kc#^$y72qV$qk@pj>3@@Jm literal 0 HcmV?d00001 diff --git a/src/Game/__pycache__/HUD.cpython-39.pyc b/src/Game/__pycache__/HUD.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..49d9c9a2e74eb77896a9a2c506ec7febe9b28338 GIT binary patch literal 538 zcmZXQy-ve05Xb$IhEO#NGeg%5FtC9TDr%&H5M8P+ktHj{2BM^Cu@fOsH_F5Gm9p{( zY)ss_suaXY|NFAf_mk5w>=Ur?>@zbEzp&^UhhhY>N8lzz5k)tk50((cW+dVn^#2%x zY6P;!;5137A_-Geu?v^QsUFPwEx(z^84m0XbJQ4Qk!(%ZM8et`+0to56TfN} z586bm^{g%*TMqS>m>yjHIUiq$xz)ysI5oxauF9XDYY}T()XSBa)p=H&+^5y>`c_zz ziAlQ90su}|Z*3rDUgfovxZFA-`aZzJ{lPy>3O6052MGci9CIWQGx%?_`X3hltr?D Z2HbVv_gw7UcEb)SxZG{J!ntn{`2|_jW(@!U literal 0 HcmV?d00001 diff --git a/src/Game/__pycache__/Player.cpython-39.pyc b/src/Game/__pycache__/Player.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..508269bbe9ce9cee9a09c92629d8a37f4a7962bb GIT binary patch literal 631 zcmZuu&1%~~5T4nURn@gg4>^{Ss}A)c$6`uC451qd{W@3rrB< z6tvKC1zJ9dMCf1&ap#SCAVw#D&PF-=yCNt!BDG)06p)|>x`$em>uW9b50RF{d!%0$-7#Tv{9 z%Ksgnd{1Y#Fg6`!W`1y1msi(KIx6hExw%cJO_|TXooDsI@i?_6PfxQ&k!~mrZXaBv zR9TmeQXQrekO2(waqqojTg{omR@mnkc=n&kY2g>VV2i(Lm(1KSPAoic7ig2+QxH`VVcanW!y{0A}=lkLfWpC@~I literal 0 HcmV?d00001 diff --git a/src/Game/__pycache__/__init__.cpython-39.pyc b/src/Game/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..132b92c0dafdb327cf59471a8c4ce7493cbb4271 GIT binary patch literal 195 zcmYe~<>g`k0u`OsWCbAo7{oyaOhAqU5Elyoi4=wu#vF!R#wbQch7_h?22JLdKv4!w z##=1ziMgqMnoLo=#YM?_AP$%)0%>2#P{a(Rz{D>*XRDad;?$zz7?;GNYz6PU%=C