Added Turtle Crossing (finished), also added start of Drone Invaders (very unfinished)

This commit is contained in:
ben 2022-07-21 16:07:13 -05:00
parent 88f86dc04f
commit 79469d1bae
31 changed files with 377 additions and 1 deletions

View file

@ -0,0 +1,19 @@
from boundedturtle import BoundedTurtle
import math
from drone import Drone
from pygame import mixer
class Bomb(BoundedTurtle):
def __init__(self, initHeading, speed, xMin, xMax, yMin, yMax, scoreboard):
pass
def move(self):
pass
def distance(self, other):
p1 = self.position()
p2 = other.position()
return math.dist(p1, p2)
def remove(self):
pass

View file

@ -0,0 +1,50 @@
from abc import abstractmethod
from turtle import Turtle
class BoundedTurtle(Turtle):
def __init__(self, speed, xMin, xMax, yMin, yMax):
super().__init__()
self.__xMin = xMin
self.__xMax = xMax
self.__yMin = yMin
self.__yMax = yMax
self.__speed = speed
def outOfBounds(self):
xPos, yPos = self.position()
out = False
if xPos < self.__xMin or xPos > self.__xMax:
out = True
if yPos < self.__yMin or yPos > self.__yMax:
out = True
return out
def belowBottomBound(self):
x_pos, y_pos = self.position()
out = False
if y_pos < self.__yMin:
out = True
return out
def getSpeed(self):
return self.__speed
def getXMin(self):
return self.__xMin
def getXMax(self):
return self.__xMax
def getYMin(self):
return self.__yMin
def getYMax(self):
return self.__yMax
@abstractmethod
def remove(self):
pass
@abstractmethod
def move(self):
pass

View file

@ -0,0 +1,29 @@
from boundedturtle import BoundedTurtle
import random
class Drone(BoundedTurtle):
droneList = [] #static variable
@staticmethod
def getDrones():
return [x for x in Drone.droneList if x.__alive]
@staticmethod
def destory_all():
for drone in Drone.droneList:
drone.remove()
Drone.droneList = []
def __init__(self, speed, xMin, xMax, yMin, yMax):
pass
def move(self):
pass
@property
def alive(self):
pass
def remove(self):
pass

View file

@ -0,0 +1,21 @@
from turtle import Screen
from drone import Drone
from lasercannon import LaserCannon
from scoreboard import Scoreboard
import time
class DroneInvaders:
def __init__(self, xMin, xMax, yMin, yMax):
pass
def play(self):
pass
def addDrone(self):
pass
def quit(self):
pass

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 289 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 425 B

View file

@ -0,0 +1,15 @@
from turtle import Turtle
from bomb import Bomb
from pygame import mixer
class LaserCannon(Turtle):
def __init__(self, xMin, xMax, yMin, yMax, screen, scoreboard):
pass
def aim(self, x, y):
pass
def shoot(self):
pass

View file

@ -0,0 +1,14 @@
from droneinvaders import DroneInvaders
import pygame
from pygame import mixer
pygame.init()
mixer.music.load('sounds/mixed_themes.ogg')
mixer.music.set_volume(0.05)
mixer.music.play(loops=-1)
if __name__ == '__main__':
di = DroneInvaders(-1, 1, -1, 1)
di.play()

View file

@ -0,0 +1,18 @@
from turtle import Turtle
class Scoreboard(Turtle):
def __init__(self, x, y):
pass
def draw_scoreboard(self):
pass
def reset(self):
pass
def game_over(self):
pass
def increment(self, amount):
pass

Binary file not shown.

Binary file not shown.

Binary file not shown.