I'm new to programming and my character goes out of the screen when I run the code. How can I make it stay inside the screen? Also, I have this wall.png which will work as the wall. How do I put the wall as the limit of the screen so it doesn't go away from the screen?
code:
import os, sys
import pygame
from pygame.locals import *
from ayuda import *
pygame.init
class PyManMain:
def __init__(self, width=600,height=600):
pygame.init()
self.width = width
self.height = height
self.screen = pygame.display.set_mode((self.width
, self.height))
def MainLoop(self):
self.LoadSprites();
pygame.key.set_repeat(500, 30)
self.background = pygame.Surface(self.screen.get_size())
self.background = self.background.convert()
self.background.fill((50,85,40))
while 1:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
elif event.type == KEYDOWN:
if ((event.key == K_RIGHT)
or (event.key == K_LEFT)
or (event.key == K_UP)
or (event.key == K_DOWN)):
self.snake.move(event.key)
lstCols = pygame.sprite.spritecollide(self.snake
, self.pellet_sprites
, True)
self.snake.pellets = self.snake.pellets + len(lstCols)
self.screen.blit(self.background, (0, 0))
self.pellet_sprites.draw(self.screen)
self.snake_sprites.draw(self.screen)
pygame.display.flip()
def LoadSprites(self):
self.snake = Snake()
self.snake_sprites = pygame.sprite.RenderPlain((self.snake))
nNumHorizontal = int(self.width/64)
nNumVertical = int(self.height/64)
self.pellet_sprites = pygame.sprite.Group()
for x in range(nNumHorizontal):
for y in range(nNumVertical):
self.pellet_sprites.add(Pellet(pygame.Rect(x*64, y*64, 64, 64)))
class Snake(pygame.sprite.Sprite):
def __init__(self):
pygame.sprite.Sprite.__init__(self)
self.image, self.rect = load_image('personaje.png',-1)
self.pellets = 0
self.x_dist = 5
self.y_dist = 5
def move(self, key):
xMove = 0;
yMove = 0;
if (key == K_RIGHT):
xMove = self.x_dist
elif (key == K_LEFT):
xMove = -self.x_dist
elif (key == K_UP):
yMove = -self.y_dist
elif (key == K_DOWN):
yMove = self.y_dist
self.rect.move_ip(xMove,yMove);
class Pellet(pygame.sprite.Sprite):
def __init__(self, rect=None):
pygame.sprite.Sprite.__init__(self)
self.image, self.rect = load_image('cofrefront.png',-1)
if rect != None:
self.rect = rect
if __name__ == "__main__":
MainWindow = PyManMain()
MainWindow.MainLoop()
I think I know what your problem is. You would like your character (snake) to stay inside the screen when he reaches the edges of the window. To achieve this, you need to modify the move function of the Snake class :). My modifications would look like this:
def move(self, key):
xMove = 0;
yMove = 0;
if (key == K_RIGHT) and self.rect.right + self.x_dist <= 600 :
xMove = self.x_dist
elif (key == K_LEFT) and self.rect.left - self.x_dist >= 0:
xMove = -self.x_dist
elif (key == K_UP) and self.rect.top - self.y_dist >= 0:
yMove = -self.y_dist
elif (key == K_DOWN) and self.rect.bottom + self.y_dist <= 600:
yMove = self.y_dist
self.rect.move_ip(xMove,yMove);
Essentially what I did above, is before I let the character move left,right,up and down, I check whether he would be outside the visible screen. If after the movement he still is inside the screen, I let him move. If not, I block he's movement :)
Hope that helped,
Cheers!
Alex
Related
Here is my sample program. When I need to draw a line for x axis and y label for y axis .so can any one please help me how to add a line and lables to scene.i tried different ways but i didn't get the proper output.So please help me how to add labels to scene.Give me any suggestion to solve this task.Thank you in advance.
Given bellow is my tried code:
import sys
from pyface.qt import QtGui, QtCore
# class ScanView(QtGui.QGraphicsView):
# def __init__(self,X=5, Y=5,parent=None):
# super(ScanView, self).__init__(parent)
class DemoApp(QtGui.QMainWindow):
def __init__(self, parent=None):
super(DemoApp, self).__init__()
self.w= QtGui.QGridLayout()
self.v= QtGui.QGraphicsView()
self.w.addWidget(self.v)
self.widget = QtGui.QWidget()
self.widget.setLayout(self.w)
self.setCentralWidget(self.widget)
self._squares = []
n_rows, n_cols = 3, 2
squareLB = 50
label = QtGui.QLabel("xaxis")
label1 = QtGui.QLabel("yaxis")
self._scene = QtGui.QGraphicsScene()
mytext1 = QtGui.QGraphicsSimpleTextItem('label')
self._scene.addItem(mytext1)
mytext2 = QtGui.QGraphicsSimpleTextItem('label1')
self._scene.addItem(mytext2)
self.v.setScene(self._scene)
self.pen = QtGui.QPen(QtCore.Qt.DotLine)
self.pen.setColor(QtCore.Qt.red)
width, height = (2 + 2)*squareLB, (3 + 2)*squareLB
self._scene = QtGui.QGraphicsScene(0, 0, max(708, width), height)
p = squareLB if width > 708 else (708.0-2*squareLB)/2.0
for i in range(n_rows):
for j in range(n_cols):
it = self._scene.addRect(QtCore.QRectF(0,0,squareLB,squareLB),self.pen)
it.setPos(p + j*squareLB, i*squareLB)
self._squares.append(it)
self.v.setScene(self._scene)
class Settings(QtGui.QMainWindow):
def __init__(self, parent=None):
super(Settings, self).__init__(parent)
self.folder = QtGui.QPushButton("Folder", clicked=self.showSettings)
central_widget = QtGui.QWidget()
self.setCentralWidget(central_widget)
vbox = QtGui.QVBoxLayout()
vbox.addWidget(self.folder)
self.scrollArea = QtGui.QScrollArea(widgetResizable=True)
self.scrollArea.setBackgroundRole(QtGui.QPalette.Light)
hlay = QtGui.QHBoxLayout(central_widget)
hlay.addLayout(vbox)
hlay.addWidget(self.scrollArea)
self.setGeometry(200, 100, 300, 300)
def showSettings(self):
self.view = DemoApp()
self.newwidget = QtGui.QWidget()
hlay = QtGui.QHBoxLayout(self.newwidget)
hlay.addWidget(self.view)
self.scrollArea.setWidget(self.newwidget)
def main():
app = QtGui.QApplication(sys.argv)
ex = Settings()
ex.show()
sys.exit(app.exec_())
if __name__ == '__main__':
main()
You can use QpainterPath to draw the arrow and a little math to set the position:
class DemoApp(QtGui.QMainWindow):
def __init__(self, parent=None):
super(DemoApp, self).__init__()
self._squares = []
n_rows, n_cols = 5, 4
squareLB = 50
self.widget = QtGui.QWidget()
grid= QtGui.QGridLayout(self.widget)
self.v = QtGui.QGraphicsView()
grid.addWidget(self.v)
self.setCentralWidget(self.widget)
width, height = (2 + 2)*squareLB, (3 + 2)*squareLB
self._scene = QtGui.QGraphicsScene(0, 0, max(708, width), height)
self.v.setScene(self._scene)
pen = QtGui.QPen(QtCore.Qt.red, 0.0, QtCore.Qt.DotLine)
p = squareLB if width > 708 else (708.0-2*squareLB)/2.0
for i in range(n_rows):
for j in range(n_cols):
it = self._scene.addRect(QtCore.QRectF(0,0,squareLB,squareLB), pen)
it.setPos(p + j*squareLB, i*squareLB)
self._squares.append(it)
path_x = QtGui.QPainterPath()
path_x.lineTo(squareLB*n_cols/2, 0)
path_x.lineTo(squareLB*n_cols/2 - 0.2*squareLB, -0.2*squareLB)
path_x.lineTo(squareLB*n_cols/2, 0)
path_x.lineTo(squareLB*n_cols/2 - 0.2*squareLB, +0.2*squareLB)
pen = QtGui.QPen("green")
pen.setWidth(2)
item_path = self._scene.addPath(path_x, pen)
item_path.setPos(p, (i+1.2)*squareLB)
mytext1 = self._scene.addText("X")
mytext1.setPos(p + j*squareLB/2, (i+1.2)*squareLB)
path_y = QtGui.QPainterPath()
path_y.lineTo(0, -squareLB*n_rows/2)
path_y.lineTo(-0.2*squareLB, -squareLB*n_rows/2 + 0.2*squareLB)
path_y.lineTo(0, -squareLB*n_rows/2)
path_y.lineTo(+0.2*squareLB, -squareLB*n_rows/2 + 0.2*squareLB)
pen = QtGui.QPen("red")
pen.setWidth(2)
item_path = self._scene.addPath(path_y, pen)
item_path.setPos(p - 0.2*squareLB, (i+1)*squareLB)
mytext1 = self._scene.addText("Y")
mytext1.setPos(p - 0.7*squareLB, (i+1)*squareLB/2)
Lets say I have class Truck. There are many instances of this class, on arrival to specific point instance should "unload" it's cargo - simply not move for N seconds, while other trucks should keep moving, unless they arrived to their unloading points.
I do the stop part by setting movement vector to (0,0) and then resetting it back to original.
But how to wait N seconds without freezing other cars? From what I've found so far I think I need to somehow apply pygame.time.set_timer, but it is really confusing for me.
Something along these lines should work: Stop the truck when the target is reached (truck.vel = Vector2(0, 0)) and then set its waiting_time and start_time attributes (I just do it in the __init__ method here).
import pygame as pg
from pygame.math import Vector2
class Truck(pg.sprite.Sprite):
def __init__(self, pos, waiting_time, *groups):
super().__init__(*groups)
self.image = pg.Surface((50, 30))
self.image.fill(pg.Color('steelblue2'))
self.rect = self.image.get_rect(center=pos)
self.vel = Vector2(0, 0)
self.pos = Vector2(pos)
self.waiting_time = waiting_time # In seconds.
self.start_time = pg.time.get_ticks()
def update(self):
current_time = pg.time.get_ticks()
# * 1000 to convert to milliseconds.
if current_time - self.start_time >= self.waiting_time*1000:
# If the time is up, start moving again.
self.vel = Vector2(1, 0)
self.pos += self.vel
self.rect.center = self.pos
def main():
screen = pg.display.set_mode((640, 480))
clock = pg.time.Clock()
all_sprites = pg.sprite.Group()
truck = Truck((70, 70), 4, all_sprites)
truck2 = Truck((70, 300), 2, all_sprites)
done = False
while not done:
for event in pg.event.get():
if event.type == pg.QUIT:
done = True
all_sprites.update()
screen.fill((30, 30, 30))
all_sprites.draw(screen)
pg.display.flip()
clock.tick(30)
if __name__ == '__main__':
pg.init()
main()
pg.quit()
Here's the dt version:
import pygame as pg
from pygame.math import Vector2
class Truck(pg.sprite.Sprite):
def __init__(self, pos, waiting_time, *groups):
super().__init__(*groups)
self.image = pg.Surface((50, 30))
self.image.fill(pg.Color('steelblue2'))
self.rect = self.image.get_rect(center=pos)
self.vel = Vector2(0, 0)
self.pos = Vector2(pos)
self.waiting_time = waiting_time
def update(self, dt):
self.waiting_time -= dt
if self.waiting_time <= 0:
self.vel = Vector2(1, 0)
self.pos += self.vel
self.rect.center = self.pos
def main():
screen = pg.display.set_mode((640, 480))
clock = pg.time.Clock()
all_sprites = pg.sprite.Group()
truck = Truck((70, 70), 4, all_sprites)
truck2 = Truck((70, 300), 2, all_sprites)
done = False
while not done:
dt = clock.tick(30) / 1000
for event in pg.event.get():
if event.type == pg.QUIT:
done = True
all_sprites.update(dt)
screen.fill((30, 30, 30))
all_sprites.draw(screen)
pg.display.flip()
if __name__ == '__main__':
pg.init()
main()
pg.quit()
I want to use wxpython to show the trajectory of a random walk in real-time. However, the panel is updated only once at the end showing the entire random walk instead of updating step by step and showing the time course.
My first idea was to use wx.ClientDC().DrawPoint() but the result was as described above where I did not see single points being drawn but only the final result was shown.
So instead I thought about using wx.MemoryDC to draw the trajectory to a bitmap stored in memory and then use wx.ClientDC.DrawBitmap() to copy the buffered image to the screen at set time intervals in case flipping the image was the bottleneck. The result is still the same so I am hoping for you help.
The purpose of this exercise is to replace the random walk with positional data coming from an eye tracker with a frame rate of 1000 Hz and I would like to be able to visualize the trajectory in as close to real-time as possible (the monitor's frame rate is 120Hz).
This is my code (most of it comes from here):
import wx
import random
import time
from time import asctime
#-------------------------------------------------------------------
def jmtime():
return '[' + asctime()[11:19] + '] '
#-------------------------------------------------------------------
class MyDrawingArea(wx.Window):
def __init__(self, parent, id):
sty = wx.NO_BORDER
wx.Window.__init__(self, parent, id, style=sty)
self.parent = parent
self.SetBackgroundColour(wx.WHITE)
self.SetCursor(wx.CROSS_CURSOR)
# Some initalisation, just to reminds the user that a variable
# called self.BufferBmp exists. See self.OnSize().
self.BufferBmp = None
wx.EVT_SIZE(self, self.OnSize)
wx.EVT_PAINT(self, self.OnPaint)
wx.EVT_LEFT_DOWN(self,self.OnClick)
def OnSize(self, event):
print jmtime() + 'OnSize in MyDrawingArea'
# Get the size of the drawing area in pixels.
self.wi, self.he = self.GetSizeTuple()
# Create BufferBmp and set the same size as the drawing area.
self.BufferBmp = wx.EmptyBitmap(self.wi, self.he)
memdc = wx.MemoryDC()
memdc.SelectObject(self.BufferBmp)
# Drawing job
ret = self.DoSomeDrawing(memdc)
if not ret: #error
self.BufferBmp = None
wx.MessageBox('Error in drawing', 'CommentedDrawing', wx.OK | wx.ICON_EXCLAMATION)
def OnPaint(self, event):
print jmtime() + 'OnPaint in MyDrawingArea'
dc = wx.PaintDC(self)
dc.BeginDrawing()
if self.BufferBmp != None:
print jmtime() + '...drawing'
dc.DrawBitmap(self.BufferBmp, 0, 0, True)
else:
print jmtime() + '...nothing to draw'
dc.EndDrawing()
def OnClick(self,event):
pos = event.GetPosition()
dc = wx.ClientDC(self)
dc.SetPen(wx.Pen(wx.BLACK,1,wx.SOLID))
dcwi, dche = dc.GetSizeTuple()
x = pos.x
y = pos.y
time_start = time.time()
memdc = wx.MemoryDC()
memdc.SelectObject(self.BufferBmp)
memdc.SetPen(wx.Pen(wx.BLACK,1,wx.SOLID))
count = 1
runtime = 5
while (time.time() - time_start) < runtime:
x,y = random_walk(x,y,dcwi,dche)
memdc.DrawPoint(x,y)
if (time.time() - time_start) > count * runtime * 0.1:
print jmtime() + 'Random walk in MyDrawingArea'
count += 1
dc.BeginDrawing()
dc.DrawBitmap(self.BufferBmp, 0, 0, True)
dc.EndDrawing()
dc.BeginDrawing()
dc.DrawBitmap(self.BufferBmp, 0, 0, True)
dc.EndDrawing()
# End of def OnClick
def DoSomeDrawing(self, dc):
try:
print jmtime() + 'DoSomeDrawing in MyDrawingArea'
dc.BeginDrawing()
#~ raise OverflowError #for test
# Clear everything
dc.SetBrush(wx.Brush(wx.WHITE, wx.SOLID))
dc.Clear()
dc.EndDrawing()
return True
except:
return False
#-------------------------------------------------------------------
class MyPanel(wx.Panel):
def __init__(self, parent, id):
wx.Panel.__init__(self, parent, id, wx.DefaultPosition, wx.DefaultSize)
self.drawingarea = MyDrawingArea(self, -1)
self.SetAutoLayout(True)
gap = 30 #in pixels
lc = wx.LayoutConstraints()
lc.top.SameAs(self, wx.Top, gap)
lc.left.SameAs(self, wx.Left, gap)
lc.right.SameAs(self, wx.Width, gap)
lc.bottom.SameAs(self, wx.Bottom, gap)
self.drawingarea.SetConstraints(lc)
#-------------------------------------------------------------------
# Usual frame. Can be resized, maximized and minimized.
# The frame contains one panel.
class MyFrame(wx.Frame):
def __init__(self, parent, id):
wx.Frame.__init__(self, parent, id, 'CommentedDrawing', wx.Point(0, 0), wx.Size(500, 400))
self.panel = MyPanel(self, -1)
wx.EVT_CLOSE(self, self.OnCloseWindow)
def OnCloseWindow(self, event):
print jmtime() + 'OnCloseWindow in MyFrame'
self.Destroy()
#-------------------------------------------------------------------
class MyApp(wx.App):
def OnInit(self):
frame = MyFrame(None, -1)
frame.Show(True)
self.SetTopWindow(frame)
return True
#-------------------------------------------------------------------
def random_walk(x,y,sizex = 250, sizey = 200):
rn = random.randrange(0,2)
x_new = x + (1-rn) - rn
while x_new < 0 or x_new > sizex:
rn = random.randrange(0,2)
x_new = x + (1-rn) - rn
rn = random.randrange(0,2)
y_new = y + (1-rn) - rn
while y_new < 0 or y_new > sizex:
rn = random.randrange(0,2)
y_new = y + (1-rn) - rn
return x_new, y_new
# end of def random_walk
#-------------------------------------------------------------------
def main():
print 'main is running...'
app = MyApp(0)
app.MainLoop()
#-------------------------------------------------------------------
if __name__ == "__main__" :
main()
#eof-------------------------------------------------------------------
This is the solution I came up with. Instead of using dc.DrawBitmap() to copy the buffered image to the screen I used Update() and Refresh() to trigger a paint event. However, what I still don't understand is why I cannot use DrawBitmap() to accomplish the same.
The only difference is that OnPaint() uses PaintDC() and in OnClick() I use ClientDC().
Anyways, this is my current code for OnClick():
def OnClick(self,event):
pos = event.GetPosition()
x = pos.x
y = pos.y
time_start = time.time()
memdc = wx.MemoryDC()
memdc.SelectObject(self.BufferBmp)
dcwi, dche = memdc.GetSizeTuple()
memdc.SetPen(wx.Pen(wx.BLACK,1,wx.SOLID))
runtime = 10
while (time.time() - time_start) < runtime:
x,y = random_walk(x,y,dcwi,dche)
memdc.SelectObject(self.BufferBmp)
memdc.DrawPoint(x,y)
memdc.SelectObject(wx.NullBitmap)
self.Update()
self.Refresh()
print jmtime() + 'Random walk in MyDrawingArea done'
I have the code below and I want to modify it in many parts :
how can I use Raspbery Pi camera instead USB camera?
I will be grateful for anyone who gives me a hint or write the right code.
The code is :
import cv2.cv as cv
import smbus
import cv2
bus = smbus.SMBus(1)
address = 0x04
def sendData(value):
bus.write_byte(address, value)
return -1
def readData():
state = bus.read_byte(address)
return state
def ColorProcess(img):
imgHSV = cv.CreateImage(cv.GetSize(img) ,8 ,3)
cv.CvtColor(img, imgHSV, cv.CV_BGR2HSV)
imgProcessed = cv.CreateImage(cv.GetSize(img) ,8 ,1)
cv.InRangeS(imgHSV, (100, 94, 84), (109, 171, 143), imgProcessed)
return imgProcessed
def main():
width = 320
height = 240
capture = cv.CreateCameraCapture(0)
cv.SetCaptureProperty(capture, cv.CV_CAP_PROP_FRAME_WIDTH, width)
cv.SetCaptureProperty(capture, cv.CV_CAP_PROP_FRAME_HEIGHT, height)
cv.NamedWindow("output", 1)
cv.NamedWindow("processed", 1)
while True:
frame = cv.QueryFrame(capture)
cv.Smooth(frame, frame, cv.CV_BLUR, 3)
imgColorProcessed = ColorProcess(frame)
mat = cv.GetMat(imgColorProcessed)
moments = cv.Moments(mat, 0)
area = cv.GetCentralMoment(moments, 0, 0)
moment10 = cv.GetSpatialMoment(moments, 1, 0)
moment01 = cv.GetSpatialMoment(moments, 0, 1)
if (area > 60000):
posX = int(moment10/area)
posY = int(moment01/area)
ali = long(2000000)
state = readData()
if state == 1:
sendData(posX)
sendData(posY)
print 'x: ' + str(posX) + 'y: ' + str(posY)
cv.ShowImage("processed", imgColorProcessed)
cv.ShowImage("output", frame)
if cv.WaitKey(10) >= 0:
break
return;
if __name__ == "__main__":
main()
I will high appreciate any help.
Thanks.
Run this command in LX Terminal in Pi.It will take care of drivers.
sudo modprobe bcm2835-v4l2
Well. All I wanted is to shoot some bullets in my game. I tried so hard but I can't!
First I store the bullets angle and position in bullets_array's list. Second, I gave to it velocity by 'sin' and 'cos' and I limited its motion on 640px and 480px in a loop. Then I displayed it on player_x, player_y.
It was supposed to start on player_x, player_y, to walk by cos and sin laws and to destroy on the bordelines of the screen.
But it is shown the following sentence:
line 53
vel_x = math.cos(bullet[0])*10 TypeError: 'float' object has no
attribute 'getitem'
Here is the code.
#
# Title: Shoot The Zombies
# Author(s): John Redbeard, ("http://john-redbeard.tumblr.com/")
#
import pygame
from pygame.locals import *
import math
# Initiate Pygame
pygame.init()
width, height = 640, 480
screen=pygame.display.set_mode((width, height))
pygame.display.set_caption("Shoot the Zombies")
fps = 60
fpsclock = pygame.time.Clock()
# Load images
player = pygame.image.load("images/player.png")
player_x = 100
player_y = 100
posplayer_x = 0
posplayer_y = 0
grass = pygame.image.load("images/grass.png")
bullet = pygame.image.load("images/bullet.png")
bullets_array = []
target = pygame.image.load("images/target.png")
# Main Loop Game
while True:
pygame.mouse.set_visible(False)
screen.fill(False)
# Load on screen the grass in isometric way
for x in range(width/grass.get_width()+1):
for y in range(height/grass.get_height()+1):
screen.blit(grass,(x*100,y*100))
# Load on screen the rotated-positioned-player
mouse_position = pygame.mouse.get_pos()
angle = math.atan2(mouse_position[0] - player_x, mouse_position[1] - player_y)
player_rotate = pygame.transform.rotate(player, 360+angle*57.29)
player_position = (player_x - player_rotate.get_rect().width/2, player_y - player_rotate.get_rect().height/2)
screen.blit(player_rotate, player_position)
# load on screen the rotated-posioted-bullets
for bullet in bullets_array:
vel_x = math.cos(bullet[0])*10
vel_y = math.sin(bullet[1])*10
bullet[0] += vel_x
bullet[1] += vel_y
if bullet[0] >640 or bullet[1] > 480:
bullets_array.remove(bullet)
bullet1 = pygame.transform.rotate(bullet, 360+angle*57.29)
screen.blit(bullet1, (player_x, player_y))
# Load on screen the target
screen.blit(target, (mouse_position))
# Display window
pygame.display.flip()
# Run events
for event in pygame.event.get():
if event.type==pygame.QUIT:
pygame.quit()
exit(False)
# Event: W/A/S/D (Keyboard) moving player
elif event.type == KEYDOWN:
if event.key == K_w:
posplayer_y -= 3
elif event.key == K_a:
posplayer_x -= 3
elif event.key == K_s:
posplayer_y += 3
elif event.key == K_d:
posplayer_x += 3
elif event.type == KEYUP:
if event.key == K_w:
posplayer_y = 0
elif event.key == K_a:
posplayer_x = 0
elif event.key == K_s:
posplayer_y= 0
elif event.key == K_d:
posplayer_x = 0
# Event: Mouse click shoot the bullet
elif event.type == MOUSEBUTTONDOWN:
bullets_array.append(math.atan2(mouse_position[0] - player_x, mouse_position[1] - player_y))
player_x += posplayer_x
player_y +=posplayer_y
fpsclock.tick(fps)
You added float values to bullets_array:
bullets_array.append(math.atan2(mouse_position[0] - player_x, mouse_position[1] - player_y))
That's just one math.atan2() call; it produces one floating point value.
You then on expect there to be two values:
for bullet in bullets_array:
vel_x = math.cos(bullet[0])*10
vel_y = math.sin(bullet[1])*10
You cannot index a floating point value.
If you expected there to be two values, you'll have to create a tuple with two floats, not add just the one float. You certainly did not
store the bullets angle and position in bullets_array's list