Пример #1
0
        elif coin == 1:  # tails
            self.heading += self.rudder
            self.rt(self.rudder)
        else:
            self.heading = self.setheading(180)

        if self.heading < 0:
            self.heading += 360
        if self.heading > 360:
            self.heading -= 360


# Initial Game setup
game = spgl.Game(2500,
                 1200,
                 "black",
                 "SPGL Minimum Code Example by /u/wynand1004 AKA @TokyoEdTech",
                 splash_time=3)
heading = Player.heading
depth = Player.depth
enemy_heading = Enemy.heading
rudder = Player.rudder
desired = Player.desired_speed

# Create Sprites
# Create Enemy
enemy = Enemy("square", "brown", 0, 0)
# Create Player
player = Player("triangle", "white", 0, 0)
#player = Player("triangle", "white", -game.SCREEN_WIDTH / 2 , game.SCREEN_HEIGHT / 2 -1000)
Пример #2
0
		os.system("afplay {}&".format(filename))  
	 
    
        
class Boxes(spgl.Sprite):
    def __init__(self, shape, color, x, y):
        spgl.Sprite.__init__(self, shape, color, x, y)
    def play_sound(self, filename):
    	os.system("afplay {}&".format(filename))
    

    


# Initial Game setup
game = spgl.Game(800, 800, "grey", "Collect the Rainbow",10)
game.set_background("rainbow.gif")
game.lives = 3 
game.timer = 120 
game.play_sound("back.mp3 -v 0.1", 169)


# Create Sprites
player = Player("triangle", "white", random.randint(-350, 350), random.randint(-350,350), 1)
player.shapesize(0.5, 1, 0)
border = Border()
black1 = Black("circle", "black", 1500, 1500)
black2 = Black("circle", "black", 1500, 1500)
black3 = Black("circle", "black", 1500, 1500)
black4 = Black("circle", "black", 1500, 1500)
black5 = Black("circle", "black", 1500, 1500)
Пример #3
0
import spgl

# Create Classes

# Create Functions

# Initial Game setup
game = spgl.Game(800, 600, "black", "SPGL Minimum Code Example by Jonathan")

# Create Sprites

# Create Labels

# Create Buttons

# Set Keyboard Bindings

while True:
    # Call the game tick method
    game.tick()
Пример #4
0
# SPGL Minimal Code by /u/wynand1004 AKA @TokyoEdTech
# Requires SPGL Version 0.8 or Above
# SPGL Documentation on Github: https://wynand1004.github.io/SPGL
# Use this as the starting point for your own games

# Import SPGL
import spgl
import random
import math
import turtle
from tkinter import messagebox

game = spgl.Game(800, 600, "black", "splash.gif", 7)
game.play_sound("bgmusic.wav", 104)


# Create Classes
class Player(spgl.Sprite):
    def __init__(self, shape, color, x, y):
        spgl.Sprite.__init__(self, shape, color, x, y)
        self.lives = 5
        self.score = 0

    def rotate_up(self):
        self.left(10)

    def rotate_down(self):
        self.right(10)

    def motion(self, event):
        x1 = self.xcor()
        self.height = 600

    def draw_border(self):
        self.penup()
        self.goto(-self.width / 2, -self.height / 2)
        self.pendown()
        self.goto(-self.width / 2, self.height / 2)
        self.goto(self.width / 2, self.height / 2)
        self.goto(self.width / 2, -self.height / 2)
        self.goto(-self.width / 2, -self.height / 2)


# Create Functions

# Initial Game setup
game = spgl.Game(850, 850, "light blue",
                 "Collect balloons to fly to South American Wilderness!", 0)
game.score = 0
game.current_time = 30

# Create Sprites
# Keep List of Sprites
sprites = []


class Russell(spgl.Sprite):
    def __init__(self, shape, color, x, y):
        spgl.Sprite.__init__(self, shape, color, x, y)
        self.penup()
        self.shape("up.gif")
        self.goto(0, 0)
        self.speed = 10
Пример #6
0
    def draw_border(self):
        self.penup()
        self.goto(-self.width / 2, -self.height / 2)
        self.pendown()
        self.goto(-self.width / 2, self.height / 2)
        self.goto(self.width / 2, self.height / 2)
        self.goto(self.width / 2, -self.height / 2)
        self.goto(-self.width / 2, -self.height / 2)


# Create Functions

# Initial Game setup
game = spgl.Game(850, 850, "white",
                 "Collect the balloons to fly to South American Wilderness!",
                 5)
game.score = 0

# Create Sprites
# Keep List of Sprites
sprites = []


class Russell(spgl.Sprite):
    def __init__(self, shape, color, x, y):
        spgl.Sprite.__init__(self, shape, color, x, y)
        self.penup()
        self.shape("up.gif")
        self.goto(0, 0)
        self.speed = 11
Пример #7
0
# SPGL Minimal Code by /u/wynand1004 AKA @TokyoEdTech
# Requires SPGL Version 0.8 or Above
# SPGL Documentation on Github: https://wynand1004.github.io/SPGL
# Use this as the starting point for your own games

# Import SPGL
import spgl

# Create Classes

# Create Functions

# Initial Game setup
game = spgl.Game(
    800, 600, "black",
    "SPGL Minimum Code Example by /u/wynand1004 AKA @TokyoEdTech")

# Create Sprites

# Create Labels

# Create Buttons

# Set Keyboard Bindings

while True:
    # Call the game tick method
    game.tick()
Пример #8
0
				screen_x = -350 + (x * 16)
				screen_y = 300 - (y * 30)
				
				enlarge = Powerup("square", "royalblue", screen_x, screen_y, "enlarge")
				powerups.append(enlarge)
				
			elif level[y][x] == "d":
				screen_x = -350 + (x * 16)
				screen_y = 300 - (y * 30)
				
				double_brick = Double_Break_Brick("square", "white", screen_x, screen_y)
				double_bricks.append(double_brick)


# Initial Game setup
game = spgl.Game(800, 600, "black", "Dakinoid By Dakina", 3)

draw_level(level_1)

# Create Sprites
paddle = Paddle("square", "white", 0, -250, 100, 20)
paddle.width = 120
paddle.height = 20
paddle.shapesize(stretch_wid=1, stretch_len=5, outline=None)
ball = Ball("circle", "skyblue", 0, -229)
ball.width = 20
ball.height = 20


# Create Labels
print("lives = {}".format(lives))
Пример #9
0
    def tick(self):
        self.fd(self.speed)

        # Border detection
        if self.ycor() > 290:
            self.sety(290)
            self.setheading(270)
        elif self.ycor() < -290:
            self.sety(-290)
            self.setheading(90)


# Create Functions

# Initial Game setup
game = spgl.Game(800, 600, "black", "Emu Test", 0)

# Create Sprites
player = Player("triangle", "white", -300, 0)
player.shapesize(1, 3, 0)

ball = Ball("circle", "white", -300, 0)

obstacle = Obstacle("square", "red", 0, 0)

# Create Labels

# Create Buttons

# Set mouse motion binding
canvas = spgl.turtle.getcanvas()
Пример #10
0
        self.fd(self.speed)


class Mushroom(spgl.Sprite):
    def __init__(self, shape, color, x, y):
        spgl.Sprite.__init__(self, shape, color, x, y)
        self.frame = 0
        self.speed = -13
        self.shape("mushroom.gif")

    def tick(self):
        self.fd(self.speed)


# Initial Game setup
game = spgl.Game(800, 600, "black", "Aishna Capstone Project", 1)
game.gravity = -1.15

# Create Sprites
ground = Game("groundd.gif", "blue", 0, -110)

title = Game("supermario.gif", "green", 10, 200)

player = Player("mario_run.gif", "blue", -200, -100)
player.set_image("mario_run.gif", 58, 50)

shell = Shell("shell.gif", "red", random.randint(300, 1000), -6)
shell.set_image("shell.gif", 53, 55)

plant = Plant("plant.gif", "white", random.randint(100, 1000), -100)
plant.set_image("plant.gif", 49, 24)
Пример #11
0
    #uses bounding box from spgl, but takes sprite_2 coordinates from wall_coordinates
    #for some reason it's triggering with -30 as y-cor when it's nowhere near -30. The wall centers should be -70.
    x_collision = (math.fabs(sprite.xcor() - coordinates[0]) *
                   2) < (sprite.width + 5)
    y_collision = (math.fabs(sprite.ycor() - coordinates[1]) *
                   2) < (sprite.height + 5)
    return (x_collision and y_collision)


def clear_label_after_time(label):
    spgl.turtle.Screen().ontimer(lambda: label.update(""), t=2000)


#---------------Initialization---------------
# Initial Window
game = spgl.Game(1000, 600, "black", "THE BLIND GUARDIAN'S  Crypt", 5)
game.mode = "maze"

#Maze design
maze = [
    "xxxxxxxxxxxxxxxx    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "x                         x          x                                                            x",
    "x                         x          x                                                            x",
    "x                         x          x                                                            x",
    "x         xxxxxxxxxxxxxxxxx          xxxxxxxxxxxxxxxxxxxxxx    xxxxxxxxxxxxxxxxxxxxxxxxxxxxx      x",
    "x         x                                               x    x                                  x",
    "x         x                                               x    x                                  x",
    "x         x                                               x    x                                  x",
    "xxxxx     xxxxxxxxxxxxxxxx      xxxxxxxxxxxxxxxxxxx       x    x      xxxxxxxxxxxxxxxxxxxxxxxxx   x",
    "x k x                                             x                                           x   x",
    "x   x                                             x                                           x   x",
Пример #12
0
    def tick(self):
        if self.status == "ready":
            self.goto(-1000, 1000)

        elif self.status == "firing":
            self.fd(self.speed)

        #Border check
        if self.xcor() < -game.SCREEN_WIDTH / 2 or self.xcor() > game.SCREEN_WIDTH / 2 or \
            self.ycor()< -game.SCREEN_HEIGHT / 2 or self.ycor()> game.SCREEN_HEIGHT / 2:
            self.goto(-1000, 1000)
            self.status = "ready"


# Initial Game setup
game = spgl.Game(800, 600, "black", "Debris (SPGL Demo) by @TokyoEdTech", 5)

# Game attributes
game.highscore = 0

# Load high score
highscore = game.load_data("highscore")
if highscore:
    game.highscore = highscore
else:
    game.highscore = 0

# Create Sprites
# Create Player
player = Player("triangle", "white", -400, 0)
Пример #13
0
        spgl.Sprite.__init__(self, shape, color, x, y)
        self.speed = 1


class Donkeykong(spgl.Sprite):
    def __init__(self, shape, color, x, y):
        spgl.Sprite.__init__(self, shape, color, x, y)


class Peach(spgl.Sprite):
    def __init__(self, shape, color, x, y):
        spgl.Sprite.__init__(self, shape, color, x, y)


# Initial Game setup
game = spgl.Game(800, 600, "black", "Sana Kureshi - SUPER MARIO BROS.", 15)
game.coins = 10
game.gravity = -0.3
game.play_sound("background_sound.wav -v 0.6", 57)

# Create Sprites / player
player = Player("triangle", "white", 300, -250)
player.set_image("mario.gif", 50, 60)

donkeykong = Donkeykong("circle", "red", 310, 250)
donkeykong.set_image("donkeykong.gif", 50, 60)

peach = Peach("circle", "red", 255, 255)
peach.set_image("peach.gif", 50, 70)

pipe = Pipe("triangle", "blue", 300, -250)
Пример #14
0
		if self.frame > len(self.frames)-1:
			self.frame = 0
			
		self.set_image(self.frames[self.frame], 40, 40)
		
		
	def move(self):
		self.fd(self.speed)
		
		if self.xcor() >= 380:
			self.destroy()

# Create Functions

# Initial Game setup
game = spgl.Game(800, 600, "blue", "Capstone Project by Sarah T-B", 0)

# Create Sprites
player = Player("triangle", "mediumvioletred", -350, 0, 700.00)
sharks = []
powerups = []
seaweeds = []
y_cors = [-200, 0, 200]

# Create multiple sprites per class
for i in range(0,2):
	shark = Shark("square", "dimgray", random.randint(350, 600), random.choice(y_cors))
	sharks.append(shark)
	powerup = Powerup("square", "gold", random.randint(350, 600), random.choice(y_cors))
	powerups.append(powerup)
	seaweed = Seaweed("square", "seagreen", random.randint(350, 600), random.choice(y_cors))
Пример #15
0

class Gate(spgl.Sprite):
    def __init__(self, shape, color, x, y):
        spgl.Sprite.__init__(self, shape, color, x, y)


class House(spgl.Sprite):
    def __init__(self, shape, color, x, y):
        spgl.Sprite.__init__(self, shape, color, x, y)


# Create Functions

# Initial Game setup
game = spgl.Game(800, 450, "black", "Math Dash", 5)
game.gravity = -0.9
game.set_background("full_background.gif")
game.play_sound("pac_man.wav -v 0.6", 7)  # Repeat every 7 seconds

# Create Sprites
# Create Person
player = Player("Layer 12.gif", "white", -300, -100)
player.questions_answered = 0
dog = Dog("Dog.gif", "darkgoldenrod", -390, -120)
question1 = Question("question_small.gif", "yellow", -200, -70)
question2 = Question("question_small.gif", "yellow", -120, -10)
question3 = Question("question_small.gif", "yellow", 0, 10)
question4 = Question("question_small.gif", "yellow", 80, -50)
question5 = Question("question_small.gif", "yellow", 150, 0)
question6 = Question("question_small.gif", "yellow", 220, 20)
Пример #16
0
#import SPGL
import spgl
import turtle
import math
import random
import time

#chances =6
# hangman face shown

#Initial game setup / Title
game = spgl.Game(1000, 800, "black", "Hangman", 7)

#Words List
words = [
    "sacred", "adult", "bob", "madeline", "because", "whatever", "hangman",
    "chairs", "backpack", "bodywash", "clothing", "computer", "python",
    "program", "glasses", "sweatpant", "mattress", "friends", "clocks",
    "biology", "algebra", "suitcase", "knives", "ninjas", "shampoo",
    "madeline", "okay", "because", "whatever"
]

#Create classes


class Hangman(object):
    def __init__(self):
        self.correct_answer = random.choice(words)
        self.player_guess = "_______________________________________"
        self.score = 0
        self.chances = 5
Пример #17
0
        
class Question(spgl.Sprite):
    def __init__(self, shape, color, x, y):
        spgl.Sprite.__init__(self, shape, color, x, y)
        
class Gate(spgl.Sprite):
    def __init__(self, shape, color, x, y):
        spgl.Sprite.__init__(self, shape, color, x, y) 
        
class House(spgl.Sprite):
	def __init__(self, shape, color, x, y):
		spgl.Sprite.__init__(self, shape, color, x, y)    
# Create Functions

# Initial Game setup
game = spgl.Game(800, 600, "black", "The Math Quest", 0)

# Create Sprites
# Create Person
player = Player("triangle", "white", -300, 0)
dog = Dog("turtle", "darkgoldenrod", -390, 0)
question = Question("square", "yellow", -200, 10)
question = Question("square", "yellow", -100, 70)
question = Question("square", "yellow", 0, 30)
question = Question("square", "yellow", 100, 0)
question = Question("square", "yellow", 200, 40)
question = Question("square", "yellow", 270, 50)
gate = Gate("square", "dimgray", 300, 0)
gate.shapesize(5, 1, 0)
house = House("square", "slategrey", 350, 0)
house.shapesize(4, 2, 0)
Пример #18
0
            self.setx(530)
            self.left(180)
        if self.xcor() < -530:
            self.setx(-530)
            self.left(180)
        if self.ycor() > 290:
            self.sety(290)
            self.left(180)
        if self.ycor() < -290:
            self.sety(-290)
            self.left(180)


# Create Functions
# Initial Game setup
game = spgl.Game(1100, 600, "black", "Uhhh Uhhh...Get It Across", 0)

# Create Sprites
player = Player("triangle", "white", -500, 0)
player.shapesize(1, 3, 0)
ball = Ball("circle", "yellow", -470, 0)
obstacle_1 = Obstacle("square", "red", 0, 100)
obstacle_2 = Obstacle("square", "red", 500, 300)
obstacle_3 = Obstacle("square", "red", 250, -200)

# sprite_name.set_image("image_name.gif", width, height)
obstacle_1.set_image("brick.gif", 70, 100)
obstacle_2.set_image("brick.gif", 70, 100)
obstacle_3.set_image("brick.gif", 70, 100)
player.set_image("MainGuySpriteSheet.gif", 65, 65)
Пример #19
0

class Explosion(object):
    def __init__(self):
        self.particles = []
        for _ in range(30):
            color = random.choice(["red", "yellow", "orange"])
            self.particles.append(Particle("circle", color))

    def explode(self, x, y):
        for particle in self.particles:
            particle.explode(x, y)


# Initial Game setup
game = spgl.Game(800, 600, "black",
                 "SPGL Game Demo by /u/wynand1004 AKA @TokyoEdTech", 0)

# Game attributes
game.highscore = 0

# Load high score
highscore = game.load_data("highscore")
if highscore:
    game.highscore = highscore
else:
    game.highscore = 0

# Create Sprites
# Create Player
player = Player("triangle", "white", -400, 0)
Пример #20
0
	def turn_down(self):
		game.play_sound("turn.wav")
		if self.direction != "up":
			self.direction = "down"
		
		
# Create Functions

def end_game():
	game.exit()
	
#Draw border


# Initial Game setup
game = spgl.Game(800, 600, "black", "TRON",0)

# Create Sprites
player = Player ("square", "blue", 100, 0)
player2 = Player ("square", "red", -100, 0)
# Create Labels
lbl_player_score = spgl.Label("Player 1: 0", "white", 320, 280)
lbl_player2_score = spgl.Label("Player 2: 0", "white", -380, 280)

# Create Buttons

# Set Keyboard Bindings
game.set_keyboard_binding(spgl.KEY_LEFT, player.turn_left)
game.set_keyboard_binding(spgl.KEY_RIGHT, player.turn_right)
game.set_keyboard_binding(spgl.KEY_UP, player.turn_up)
game.set_keyboard_binding(spgl.KEY_DOWN, player.turn_down)
Пример #21
0
            self.goto(-game.SCREEN_WIDTH / 2, self.ycor())

        if self.xcor() < -game.SCREEN_WIDTH / 2:
            self.goto(game.SCREEN_WIDTH / 2, self.ycor())

        if self.ycor() > game.SCREEN_HEIGHT / 2:
            self.goto(self.xcor(), -game.SCREEN_HEIGHT / 2)

        if self.ycor() < -game.SCREEN_HEIGHT / 2:
            self.goto(self.xcor(), game.SCREEN_HEIGHT / 2)


# Create Functions

# Initial Game setup
game = spgl.Game(800, 600, "black", "Namrata capstone porject", 0)
game.set_background("galaxy_stars_universe_light_planet_63624_800x600.gif")

# Create Sprites
goal = Goal("square", "green", 340, -150)

goal.set_image("7-2-earth-png-pic-thumb.gif", 200, 200)

player = Player("circle", "blue", -390, 0)
player.set_image("Webp.net-resizeimage copy 2.gif", 79, 78)

points = []

for count in range(9):
    points.append(Point("Webp.net-resizeimage copy 3.gif", "yellow", 42, 48))
Пример #22
0
        if self.xcor() < -game.SCREEN_WIDTH / 2:
            self.goto(game.SCREEN_WIDTH / 2, self.ycor())

        if self.ycor() > game.SCREEN_HEIGHT / 2:
            self.goto(self.xcor(), -game.SCREEN_HEIGHT / 2)

        if self.ycor() < -game.SCREEN_HEIGHT / 2:
            self.goto(self.xcor(), game.SCREEN_HEIGHT / 2)


# Create Functions

# Initial Game setup

game = spgl.Game(800, 600, "black", "Namrata capstone project", 20)
game.set_background("galaxy_stars_universe_light_planet_63624_800x600.gif")
game.play_sound("music.wav -v 0.1")

# Create Sprites
goal = Goal("square", "green", 340, -150)

goal.set_image("7-2-earth-png-pic-thumb.gif", 150, 150)

player = Player("circle", "blue", -390, 0)
player.set_image("Webp.net-resizeimage copy 2.gif", 60, 60)

points = []

for count in range(9):
    points.append(Point("Webp.net-resizeimage copy 3.gif", "yellow", 42, 48))
Пример #23
0
# SPGL Minimal Code by /u/wynand1004 AKA @TokyoEdTech
# Requires SPGL Version 0.8 or Above
# SPGL Documentation on Github: https://wynand1004.github.io/SPGL
# Use this as the starting point for your own games

# Import SPGL
import spgl
import math
import turtle
import random

# Initial Game setup
game = spgl.Game(1100, 700, "white", "Filler", 0)

# List for the colors
colors = ["O", "Y", "T", "B", "P", "C"]

# Create Classes


class Title(spgl.Sprite):
    def __init__(self, shape, color, x, y):
        spgl.Sprite.__init__(self, shape, color, x, y)
        self.shape("title.gif")
        self.goto(280.0, 220.0)


class Grid():
    def click(self, x, y, to_color):
        # Track the from_color and to_color
        from_color = self.grid[0][0]
Пример #24
0
        self.frame += 1
        if self.frame > len(self.frames) - 1:
            self.frame = 0

        self.set_image(self.frames[self.frame], 40, 40)

    def move(self):
        self.fd(self.speed)

        # Destroy Fireball once off screen
        if self.xcor() >= 380:
            self.destroy()


# Initial Game setup
game = spgl.Game(800, 600, "blue", "Stuck at Sea! by Sarah T-B", 3)
game.level = 1

# Create Sprites
player = Player("triangle", "mediumvioletred", -350, 0, 700.00)
sharks = []
powerups = []
seaweeds = []
fishingnets = []
y_cors = [-200, 0, 200]

# Create multiple sprites per class
for i in range(0, 2):
    shark = Shark("square", "dimgray", random.randint(350, 600),
                  random.choice(y_cors))
    sharks.append(shark)
Пример #25
0
import os
import random
import math
import spgl
import turtle
import time

#Size of things
#Columns = 10
#Rows = 20
#CANVAS PIXELS
#Width 530/398/265
#Height 265/133

#Game Setup
game = spgl.Game(800, 1000, "black", "Tetris", 0)

#Set up screen


#Classes
class Grid(object):
    def __init__(self):
        self.width = 10
        self.height = 20
        self.grid = []

        for grid_y in range(self.height):
            self.grid.append([])

        for grid_y in range(self.height):