From ef8004afba7e50b319b0d73f6a97931d205e43b0 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 11 Mar 2024 11:22:42 -0400 Subject: [PATCH] Still working on a name for my game, the file that starts with idk runs everything. This has been done I really just need a name. If you have any ideas I would love to hear. Left and right arrows control power, up and down controls launch point, and enter launches the ball. Thanks. --- Planning.txt | 19 ++++++++ __pycache__/aimer.cpython-310.pyc | Bin 0 -> 732 bytes __pycache__/ball.cpython-310.pyc | Bin 0 -> 1355 bytes __pycache__/launch.cpython-310.pyc | Bin 0 -> 744 bytes __pycache__/lineGenerator.cpython-310.pyc | Bin 0 -> 1557 bytes __pycache__/linePiece.cpython-310.pyc | Bin 0 -> 1307 bytes __pycache__/numbersP.cpython-310.pyc | Bin 0 -> 1045 bytes __pycache__/power.cpython-310.pyc | Bin 0 -> 806 bytes aimer.py | 14 ++++++ ball.py | 43 ++++++++++++++++++ hit.py | 5 +++ idk.py | 24 ++++++++++ launch.py | 14 ++++++ lineGenerator.py | 51 ++++++++++++++++++++++ linePiece.py | 20 +++++++++ numbers.py | 21 +++++++++ numbersP.py | 21 +++++++++ poetry.lock | 7 +++ power.py | 16 +++++++ 19 files changed, 255 insertions(+) create mode 100644 Planning.txt create mode 100644 __pycache__/aimer.cpython-310.pyc create mode 100644 __pycache__/ball.cpython-310.pyc create mode 100644 __pycache__/launch.cpython-310.pyc create mode 100644 __pycache__/lineGenerator.cpython-310.pyc create mode 100644 __pycache__/linePiece.cpython-310.pyc create mode 100644 __pycache__/numbersP.cpython-310.pyc create mode 100644 __pycache__/power.cpython-310.pyc create mode 100644 aimer.py create mode 100644 ball.py create mode 100644 hit.py create mode 100644 idk.py create mode 100644 launch.py create mode 100644 lineGenerator.py create mode 100644 linePiece.py create mode 100644 numbers.py create mode 100644 numbersP.py create mode 100644 poetry.lock create mode 100644 power.py 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 0000000000000000000000000000000000000000..1bb5468a182e1636e22b72f69f42548e88a3706d GIT binary patch literal 732 zcmZWn&5qMB5VjpVo2^;|MJgP*=CaXhg}5LDT2>s83epN8A|xxs-ffyDE>23f$UU*| z0UUV&9>zyFt#|_9!c5Ad0%OhRnX%``o-u<#j{yBV{H6ztkguq0Qvk|+;ARN$h$y1y zIq*A{62*>59OPjCiy+Fz;}!^-q*RfVDVhd~rCbH6P+W;~l7=b-{~a$L6qU9MO!Vdb zXD>2q%`#>eppy#vshjSG568jG(}sO+VeWAw2w?JUzyA*9~F(%)x2HBq34aBo%r2SubS4HQhR=i zm+6_OE8nm6QeKAnMC>&P|Km<#jcJoAD~tM6E{k>|bE9-pE%W_kQ5Wq&GPh=`^HyT0 zB*Q=6o3H%UNmi?wmVa_#<;@77M{!-DeKzbQ{yh?$z8!V#+56XR44sRl#79Z#ds0?L zEg-J+eJNirvf1yG-F%YSEN`{75&p{#!gU0E#}?pxS!_3QgF_h+PI2{VXCKF#eaoi{ RfsQ`9yUBmA^TrVzl3$qAs(kzGsDho=HL33-E}hkQdpMpE=pE@sH#a6ZlqXSUkfYBP-MS09Q$L&n~d z@aYf`4ng$}*l$cT&EJ9+!GP)DB}+w){m(`K=@3*u0V~*mYc>cp9|#=`q!xn^bEM^< zr9&OPWrJ9^bc{LCiEd+V>ke?cPX3xrr;fi^0fwzOSQ;2|$FrPPn?Y;3_8F+&1Jk_W z$3epsYly=IKn8tpnFcOCt?IEISEb`wDx9o~>9LDO#dtWfCW8GtW)e()Kkk{Tvb|Y$ zGA@VeY-~p=uXNFyo#j9D=H=M_*gG}Vq{yurX0xJq1eYJ3UbtAPF|m!|gC(DYTI|DW z5-r67!7sUa{D00NJs~h!und=+6G8}zPXhDY`;chieMm}w2Ipff!4sTHba*1o8?w=I zpIr$cwRPligl-)NR}wp&C2OFi6O-;$*o2zU&!E{_GLD*hi6|!9Itkf6MH(&;wO~)Z zCT;hJ>m>d4iwiSjsxw0g^>4YNm225iL788DLlXbpg>_z;BK^XNEYF=7m)6BqsgA15 zXcx^goHy>)u&^o{7Nu237plbb88iU%@9)I48ag@6YU`33s=S&5WX}|{>W|`cD|hDx zs3xSF+Dh_KX0qJkE>V;kUfIkRX=JD%@Vl|DXmkGA-Q5A0td zncL7k0M&$ZpI>&oqw9C+ryXh^dJm;sTd7&4=TlmDm3lqTrfZG43)3|?{h7=@v9F1B zhS#kbH1sne@;|khNxu1zJkh=9_5GCl`M&^M{B-Tr&mM)M*kK<5qL(Je literal 0 HcmV?d00001 diff --git a/__pycache__/launch.cpython-310.pyc b/__pycache__/launch.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d0a615841b2a1b5422eefddb00b96e691d68f389 GIT binary patch literal 744 zcmZ8eOK%e~5T4m}l1-FK5GvFPi6hcpy5e!*fKWvhIDm4XNGQ2j?%E`q>?3%cMv20y z{1AHN7a{q|DdHbg92h%1BF388ow2{qGoP!2gAR~=Q$N&C1o-ZfeG4f$C9m&OkRUOK z0!N7O3S=O|&mhCAU=&Dp4sl~kXCOw)UWhzTU9xWhC8y-|5d{S!lt4fng*&1V+mYCg zL%$J=GM&6k-Ti-z(N9EvMqXc1SU=g|lzO@Z{b=3Z1Yb}F*VNm4S`y9y{W5{y39oS) zN_GrBYxt~r46=0uSHUN0ViR(=$2N2lVfdS4pK0h><7i;pulqyZAH3_owJkGI7u2zB z2(7E-mQ)1WD3noJyZ`N73UR}-QWVPG9xKDeSe1rfthg&_r;Cl|Rh^lvDs5XxxjPXv z%W9Q>u9N4T4(iLNS>6k?W@W4_GHgr}8MNwG{HCW|sNkCVBs zrYbeuA(PzedNNrT=Bo$PTtxz8(;?m>|qlhkkj|3*=pkY-oJM_`5!x=0VD3` z;oNpOFDkhpa&Ehve_V*%O-flyX7xN5D}6}!_zCvH9anP??i8t;6e3{QMPD1lp=C~I bua__FL7f)b;cfJ6clC3peeGuILJxld3p%e> literal 0 HcmV?d00001 diff --git a/__pycache__/lineGenerator.cpython-310.pyc b/__pycache__/lineGenerator.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5af535b7fa8c3bb61affd34df72c7a27c3d1f872 GIT binary patch literal 1557 zcmah}&2Jnv6t_K|&z(&-X`uxAajaGqT~!g~QkC){dVvTj7c`<8O~>wLvh%U=IE{j4 zPT|6l{~(1E;$JA-IU{lKmD7m-011`%W|Gw+q2QH&`=00hezxDUU5&>9f%e;1f6AX- zLjFK!y;6HrE-Ym(e8IrGshO}& z=_ll=-?E0DS(-QOl)j{t9A3SMY)DM!kcRJRYt2c^g$?nyTL!kR8ODRZ**e-ja~kU< zZQaH?a~l^`8vD!}tizp#gKhWPchB{_hPQs>1HWzq?KiD_++PLRgQE!r4|a`Rr9z0$z=7gb*U&A?Y>{t{_YhHW9WEt|DARcmv^0gzE@zA#5YOjqnZv zp4sjuz?3VTK%urmS%qQ)^ltwFL#CUsDV=C(>~vqI3uCLKoJ(^}$)b88<76&N9X~sX z%cPLTsM2M;|PP$)ZsRX|dHBPcz%2F6Bm!-mF7~YfoM2JC0VRjT|M`3mpW@kD! zyq5WM!{;~y%}fBgRV|+@n8O|BsEw`jtk#Au4BxMEm?X(_LsP?ZxPyi!#*(@Gk*E(r z@~;nOs;cy?NETT+kB>9GAE%X&v*I|tKRYTjy)#>?>OiJC#z|+WvAW0imM6wv=E+H{ zk5q|etDgZ(=mrhx1iD9g-$NR}FIh1t(~?{J zXZA1Y+EeM#x1Rcr94C%xz{XlM=#^%qN3*k=HySmDcKrH}I`SC%MPjx25bx0^pI|;R z$t3@Y{=@5&@}v*tLvg4;hEO4t2el_FP!%X2Dw0*GDpVkA=j>!Z#eVl1PIo8GpJSj{ zpG(&FB=7r+QxF#*F0{2XovF`SrRtUCt(3x+jmFeJpwF8y*Ie=o@0tmKpR>~I{yxTR z$!#>wC%VviR(dv=sNsbTXId76l9@U@{=SJ#o)_^b`Kq%^G1J9Bq`6e_XqL9(X{L*I zJU00kl@{VM8L4=2=I|yNGLX2`b9n!ci z#MLwz-mFy9L1L1$P{z=$9O8;;&>S7Z(dTgwK0B7bd@!FTfV&CF zRLE4xP_7onF%XTRA#Dp zn#Uw%11{OXk$m7v_@s+9o_6-Tns+-YE^Hf6!n8yQd?tQsOMcHOQYnrcNKZ{`HBlHzH z-s_soLb^AN;L)W0N*4Z}<~{hAXvsJJS>)8;{6rT1b8eyU-H@{FIz!oQ{Y7W~T={uSiRz4?jyox15G^XV0R j5k<$QOt+XLp{&oEMF)Q-e}o%P=eWhQvh zw@+U$*kTjd0zj;rsY;mykFLZ6g7y{cPCTtiRF|$!S(%B?6 zKV@?__t4t9v}*R5)$SK+c7Qnz+pQrt@ZYQ5nh2=%=syH*KVY`=eE+q0b$IaX*!oCc z>_0s=nAw7Y3RVpEAYh9vSPWnCTP=RO#qYHE-4?%h&AIgpU8Ys4bIbEMQ`XnHIMK0@ z)=x{JvZ9&=p5>()pW4ny&C1H?k+S>@f2Qv(o!MTlrs68h1u>Y;uLq&gx(c&+l;&q* znpOjmXsN<%n(Ty=Jgs)a!sww&DuJQG0w=Xy%$|Y{63gmR{BF=5!_^1y zpWNk?(+?ZXptt{Z?ZX@Jg}}muuw5ZCEhi9L*q#t?C-M05q>~I{6DRN>%uVdg8mgvy sO>6(Crn@)@M2XMaC!AplJ!){TA1v3V2`z<=)_=IX|54+OgIp)S0mxalJ^%m! literal 0 HcmV?d00001 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