diff --git a/Planning.txt b/Planning.txt new file mode 100644 index 0000000..b99423f --- /dev/null +++ b/Planning.txt @@ -0,0 +1,19 @@ +#Unknown name + +## Game description +The player will have to shoot a ball from the side +of the screen and land on a high point value. They +will get unlimited shots and can play forever +until they miss (hit an X), when the game will end. + +## Core mechanics +- The ball on the left side of the screen can be +moved up and down by the arrow keys. +- The power will be controlled by the left and +right arrow keys. +-Enter will launch the ball + +## Challenges +- How to control the balls path +- How to recognize what point value the ball hit. +- How to display power. diff --git a/__pycache__/aimer.cpython-310.pyc b/__pycache__/aimer.cpython-310.pyc new file mode 100644 index 0000000..1bb5468 Binary files /dev/null and b/__pycache__/aimer.cpython-310.pyc differ diff --git a/__pycache__/ball.cpython-310.pyc b/__pycache__/ball.cpython-310.pyc new file mode 100644 index 0000000..c7f945f Binary files /dev/null and b/__pycache__/ball.cpython-310.pyc differ diff --git a/__pycache__/launch.cpython-310.pyc b/__pycache__/launch.cpython-310.pyc new file mode 100644 index 0000000..d0a6158 Binary files /dev/null and b/__pycache__/launch.cpython-310.pyc differ diff --git a/__pycache__/lineGenerator.cpython-310.pyc b/__pycache__/lineGenerator.cpython-310.pyc new file mode 100644 index 0000000..5af535b Binary files /dev/null and b/__pycache__/lineGenerator.cpython-310.pyc differ diff --git a/__pycache__/linePiece.cpython-310.pyc b/__pycache__/linePiece.cpython-310.pyc new file mode 100644 index 0000000..3327890 Binary files /dev/null and b/__pycache__/linePiece.cpython-310.pyc differ diff --git a/__pycache__/numbersP.cpython-310.pyc b/__pycache__/numbersP.cpython-310.pyc new file mode 100644 index 0000000..b4302ae Binary files /dev/null and b/__pycache__/numbersP.cpython-310.pyc differ diff --git a/__pycache__/power.cpython-310.pyc b/__pycache__/power.cpython-310.pyc new file mode 100644 index 0000000..450ef8d Binary files /dev/null and b/__pycache__/power.cpython-310.pyc differ diff --git a/aimer.py b/aimer.py new file mode 100644 index 0000000..8df834e --- /dev/null +++ b/aimer.py @@ -0,0 +1,14 @@ +class Aimer: + character = '⟶' + name='arrow' + position = (0,1) + def handle_keystroke(self, keystroke, game): + x,y = self.position + if keystroke.name in ("KEY_UP", "KEY_DOWN"): + if keystroke.name == "KEY_UP": + new_position = (x, y-1) + else: + new_position = (x, y+1) + if game.on_board(new_position) and new_position!=(0,0): + if game.is_empty(new_position): + self.position = new_position \ No newline at end of file diff --git a/ball.py b/ball.py new file mode 100644 index 0000000..1aa8abe --- /dev/null +++ b/ball.py @@ -0,0 +1,43 @@ +class Ball: + character = 'O' + a=0 + acc=1 + samecount=0 + last=(0,0) + def __init__(self, height,a): + self.position = (0,height) + self.a=a + def play_turn(self, game): + self.acc+=.5 + x=int(self.acc) + if game.on_board((x,int(self.mather(self.acc,game.get_agent_by_name('arrow').position[1],self.a)))): + self.position = ((x,int(self.mather(self.acc,game.get_agent_by_name('arrow').position[1],self.a)))) + game.log(self.position) + if self.position==self.last: + self.samecount+=1 + else: + self.last=self.position + self.samecount=0 + if self.samecount>4: + posx=self.position[0] + game.remove_agent_by_name('theball') + a=(posx,29) + char=game.get_agents_by_position()[a][0].character + if char=="X": + game.end() + else: + game.state['score']+=int(char) + + + #game.log(game.get_agents_by_position(a)) + '''if len(game.get_agents_by_position()[self.position])==2: + b=game.get_agents_by_position()[self.position].copy() + game.log(b) + + b.remove('theball') + n=game.get_agent_by_name(b[0]) + log(n) + ''' + #y=(1/(4a))x^2) + def mather(self,x,y,a): + return int(round(y+(1/(a/2))*(x/2.8)**2)) \ No newline at end of file diff --git a/hit.py b/hit.py new file mode 100644 index 0000000..f55f6a7 --- /dev/null +++ b/hit.py @@ -0,0 +1,5 @@ +class Hit(): + display=False + def __init__(self,char): + if char=='X': + game.end diff --git a/idk.py b/idk.py new file mode 100644 index 0000000..8273d6f --- /dev/null +++ b/idk.py @@ -0,0 +1,24 @@ +from retro.game import Game +#from ball import Ball +from aimer import Aimer +from lineGenerator import LineGenerator +from power import Power +from numbersP import P1,P2,P3,P4,P5,P6,P7 +from launch import BallLaunch + + +board_size = (30, 30) +#ship = Spaceship(board_size) +generator=LineGenerator() +aim=Aimer() +power=Power() +p1=P1() +p2=P2() +p3=P3() +p4=P4() +p5=P5() +p6=P6() +p7=P7() +launch=BallLaunch() +game = Game([generator,aim,power,p1,p2,p3,p4,p5,p6,p7,launch], {"score": 0}, board_size=board_size,framerate=15) +game.play() \ No newline at end of file diff --git a/launch.py b/launch.py new file mode 100644 index 0000000..549c404 --- /dev/null +++ b/launch.py @@ -0,0 +1,14 @@ +from ball import Ball +class BallLaunch: + display = False + def handle_keystroke(self, keystroke, game): + try: + if keystroke.name in ("KEY_ENTER"): + try: + game.get_agent_by_name('theball') + except: + a=Ball(game.get_agent_by_name('arrow').position[1],game.get_agent_by_name('meter').position[0]-22) + a.name='theball' + game.add_agent(a) + except: + None \ No newline at end of file diff --git a/lineGenerator.py b/lineGenerator.py new file mode 100644 index 0000000..05c07f0 --- /dev/null +++ b/lineGenerator.py @@ -0,0 +1,51 @@ +import random +from linePiece import LinePiece7,LinePiece5,LinePiece3,LinePiece1,LinePieceX +class LineGenerator: + display = False + #def __init__(self): + #length:points + check=-1 + def play_turn(self, game): + if game.state['score']!=self.check: + if game.state['score']!=0: + for i in range(30): + game.remove_agent_by_name(str(i)) + self.check=game.state['score'] + choosefrom=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29] + choices=[] + for i in [1,3,5,8]: + tlist=[] + for k in range(i): + hold=random.choice(choosefrom) + choosefrom.remove(hold) + tlist.append(hold) + choices.append(tlist) + all=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29] + c =choices + for line in c: + if len(line)==8: + for i in line: + a=LinePiece7(i) + a.name=str(i) + game.add_agent(a) + elif len(line)==5: + for i in line: + a=LinePiece5(i) + a.name=str(i) + game.add_agent(a) + elif len(line)==3: + for i in line: + a=LinePiece3(i) + a.name=str(i) + game.add_agent(a) + elif len(line)==1: + for i in line: + a=LinePiece1(i) + a.name=str(i) + game.add_agent(a) + for ele in line: + all.remove(ele) + for i in all: + a=LinePieceX(i) + a.name=str(i) + game.add_agent(a) \ No newline at end of file diff --git a/linePiece.py b/linePiece.py new file mode 100644 index 0000000..e480b19 --- /dev/null +++ b/linePiece.py @@ -0,0 +1,20 @@ +class LinePiece7: + character = '1' + def __init__(self, width): + self.position = (width,29) +class LinePiece5: + character = '2' + def __init__(self, width): + self.position = (width,29) +class LinePiece3: + character = '3' + def __init__(self, width): + self.position = (width,29) +class LinePiece1: + character = '5' + def __init__(self, width): + self.position = (width,29) +class LinePieceX: + character = 'X' + def __init__(self, width): + self.position = (width,29) \ No newline at end of file diff --git a/numbers.py b/numbers.py new file mode 100644 index 0000000..0964893 --- /dev/null +++ b/numbers.py @@ -0,0 +1,21 @@ +class P1: + character = '1' + position = (23,1) +class P2: + character = '2' + position = (24,1) +class P3: + character = '3' + position = (25,1) +class P4: + character = '4' + position = (26,1) +class P5: + character = '5' + position = (27,1) +class P6: + character = '6' + position = (28,1) +class P7: + character = '7' + position = (29,1) \ No newline at end of file diff --git a/numbersP.py b/numbersP.py new file mode 100644 index 0000000..0964893 --- /dev/null +++ b/numbersP.py @@ -0,0 +1,21 @@ +class P1: + character = '1' + position = (23,1) +class P2: + character = '2' + position = (24,1) +class P3: + character = '3' + position = (25,1) +class P4: + character = '4' + position = (26,1) +class P5: + character = '5' + position = (27,1) +class P6: + character = '6' + position = (28,1) +class P7: + character = '7' + position = (29,1) \ No newline at end of file diff --git a/poetry.lock b/poetry.lock new file mode 100644 index 0000000..8fc60e7 --- /dev/null +++ b/poetry.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. +package = [] + +[metadata] +lock-version = "2.0" +python-versions = "^3.10" +content-hash = "53f2eabc9c26446fbcc00d348c47878e118afc2054778c3c803a0a8028af27d9" diff --git a/power.py b/power.py new file mode 100644 index 0000000..9e02465 --- /dev/null +++ b/power.py @@ -0,0 +1,16 @@ +class Power: + #▯ + character = '▮' + position = (23,0) + name='meter' + def handle_keystroke(self, keystroke, game): + x,y = self.position + if keystroke.name in ("KEY_RIGHT", "KEY_LEFT"): + if keystroke.name == "KEY_RIGHT": + new_position = (x+1, y) + else: + new_position = (x-1, y) + if game.on_board(new_position): + if game.is_empty(new_position): + if new_position in [(23,0),(24,0),(25,0),(26,0),(27,0),(28,0),(29,0)]: + self.position = new_position \ No newline at end of file