a-robots-conundrum/robotgame/laser.py

49 lines
1.8 KiB
Python

# This file is part of ROBOTGAME
#
# ROBOTGAME is free software: you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# ROBOTGAME is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# ROBOTGAME. If not, see <http://www.gnu.org/licenses/>.
#
# ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '
#
# laser.py
# --------------------
# date created : Sun Aug 12 2012
# copyright : (C) 2012 Niels G. W. Serup
# maintained by : Niels G. W. Serup <ns@metanohi.name>
"""
A laser for drawing.
"""
import pygame
import worldobject
class Laser(worldobject.WorldObject):
def __init__(self, level, line):
self.__dict__.update(locals())
(self.x0, self.y0), (self.x1, self.y1) = line
self.x0d, self.y0d, self.x1d, self.y1d \
= self.x0 * 64, (self.y0 + 4) * 48, self.x1 * 64, (self.y1 + 4) * 48
worldobject.WorldObject.__init__(self, level, self.x0d,
max(self.y0d, self.y1d))
def update(self, e, t, dt):
worldobject.WorldObject.update(self, e, t, dt)
def draw(self, window):
pygame.draw.line(window, (255, 0, 0),
(self.x0d - self.level.camera_x + 32, self.y0d - 46 - self.level.camera_y),
(self.x1d - self.level.camera_x + 32, self.y1d - 46 - self.level.camera_y), 2)