Skip to content

Commit

Permalink
Added bullet class
Browse files Browse the repository at this point in the history
  • Loading branch information
MysteryCoder456 committed Sep 26, 2019
1 parent 2edd0b9 commit a73b777
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
5 changes: 2 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

## New Features

1. Added drift.
2. Added boundary collisions.
1. Added Bullet class.

## Changes

1. Rockets now gradually speed up instead of abruptly moving.
None
29 changes: 29 additions & 0 deletions scripts/bullet.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import pygame
from math import radians, cos, sin


class Bullet:
def __init__(self, x, y, hdg, color):
self.x = x
self.y = y
self.radius = 10
self.draw_x = self.x - self.radius
self.draw_y = self.y - self.radius
self.heading = hdg
self.speed = 7
self.x_vel = 0
self.y_vel = 0
self.color = color

def render(self, window):
pygame.draw.ellipse(window, self.color, (self.draw_x, self.draw_y, self.radius * 2, self.radius * 2))

def update(self):
self.x_vel = cos(radians(self.heading)) * self.speed
self.y_vel = sin(radians(self.heading)) * self.speed

self.x += self.x_vel
self.y += self.y_vel

self.draw_x = self.x - self.radius
self.draw_y = self.y - self.radius
1 change: 1 addition & 0 deletions scripts/rocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def __init__(self, x, y, color):

self.color = color
self.collider_size = 28
self.bullets = []

def render(self, window):
v = self.vertices
Expand Down

0 comments on commit a73b777

Please sign in to comment.