generated from mwc/project_game
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.
This commit is contained in:
parent
54b5fa7a9f
commit
ef8004afba
|
@ -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.
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -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
|
|
@ -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))
|
|
@ -0,0 +1,5 @@
|
||||||
|
class Hit():
|
||||||
|
display=False
|
||||||
|
def __init__(self,char):
|
||||||
|
if char=='X':
|
||||||
|
game.end
|
|
@ -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()
|
|
@ -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
|
|
@ -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)
|
|
@ -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)
|
|
@ -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)
|
|
@ -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)
|
|
@ -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"
|
|
@ -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
|
Loading…
Reference in New Issue