Added Turtle Crossing (finished), also added start of Drone Invaders (very unfinished)
This commit is contained in:
parent
88f86dc04f
commit
79469d1bae
31 changed files with 377 additions and 1 deletions
19
Turtle/Drone Invaders/bomb.py
Normal file
19
Turtle/Drone Invaders/bomb.py
Normal 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
|
50
Turtle/Drone Invaders/boundedturtle.py
Normal file
50
Turtle/Drone Invaders/boundedturtle.py
Normal 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
|
29
Turtle/Drone Invaders/drone.py
Normal file
29
Turtle/Drone Invaders/drone.py
Normal 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
|
21
Turtle/Drone Invaders/droneinvaders.py
Normal file
21
Turtle/Drone Invaders/droneinvaders.py
Normal 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
|
||||
|
||||
|
BIN
Turtle/Drone Invaders/images/Drone.gif
Normal file
BIN
Turtle/Drone Invaders/images/Drone.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 139 B |
BIN
Turtle/Drone Invaders/images/Drone64.gif
Normal file
BIN
Turtle/Drone Invaders/images/Drone64.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 289 B |
BIN
Turtle/Drone Invaders/images/Drone64.png
Normal file
BIN
Turtle/Drone Invaders/images/Drone64.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 425 B |
15
Turtle/Drone Invaders/lasercannon.py
Normal file
15
Turtle/Drone Invaders/lasercannon.py
Normal 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
|
||||
|
||||
|
14
Turtle/Drone Invaders/main.py
Normal file
14
Turtle/Drone Invaders/main.py
Normal 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()
|
18
Turtle/Drone Invaders/scoreboard.py
Normal file
18
Turtle/Drone Invaders/scoreboard.py
Normal 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
|
BIN
Turtle/Drone Invaders/sounds/explosion.wav
Normal file
BIN
Turtle/Drone Invaders/sounds/explosion.wav
Normal file
Binary file not shown.
BIN
Turtle/Drone Invaders/sounds/laser.wav
Normal file
BIN
Turtle/Drone Invaders/sounds/laser.wav
Normal file
Binary file not shown.
BIN
Turtle/Drone Invaders/sounds/mixed_themes.ogg
Normal file
BIN
Turtle/Drone Invaders/sounds/mixed_themes.ogg
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue