def make_room(width, height): global size, camera, zombie_pics, zombie size = (width, height) camera = gamebox.Camera(size[0] * CELLSIZE + 2 * EDGEBUFFER, size[1] * CELLSIZE + 2 * EDGEBUFFER) zombie_pics = gamebox.load_sprite_sheet("Monster-zombie.png", 8, 7) zombie = gamebox.from_image(EDGEBUFFER + CELLSIZE / 2, EDGEBUFFER + CELLSIZE / 2, zombie_pics[0]) zombie.width = CELLSIZE look_right()
# Health Meter """ We plan on giving players three lives to get across the path of obstacles. Upon losing a life, players will be sent back to the starting location. If they lose all three lives, they will lose the game and we will indicate that visually. """ # Music/Sound Effects """ This is another option we will be able to pursue, especially if we find a source file of the original audio. """ import pygame import gamebox camera = gamebox.Camera(442, 500) background = gamebox.from_image(221, 250, 'background.png') roadlines = gamebox.from_image(221, 405, 'road_lines.png') roadlines2 = gamebox.from_image(221, 440, 'road_lines.png') roadlines3 = gamebox.from_image(221, 370, 'road_lines.png') roadlines4 = gamebox.from_image(221, 335, 'road_lines.png') roadlines5 = gamebox.from_image(221, 300, 'road_lines.png') show_splash = True ticks = 0 def splash(keys): global show_splash camera.clear('blue') camera.draw( gamebox.from_text(camera.x, camera.y - 150, "Frogger", "Arial", 40,
# ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- # # ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- # # ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- # # ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- # import pygame # Gets the pygame library import gamebox # Gets the gamebox library import random # Imports the random library """ This is a bricks like game made as an assignment for CS-1111 Game project. This project was done using the gamebox module developed by Professor Luther Tychonievich. This is the section of the game that runs a simple bricks game. """ width = 800 # This is the width of the screen height = 600 # This is the height of the screen camera = gamebox.Camera(width, height) # Sets the camera to view in these many pixels walls = \ [ gamebox.from_color(400, 600, "yellow", 1000, 20), # This is the bottom wall on the screen gamebox.from_color(400, 0, "yellow", 1000, 20), # This is the top wall on the screen ] def bricks(keys): for wall in walls: # For every wall in the game camera.draw(wall) # Draws the wall for the game. camera.display()
import pygame import gamebox camera = gamebox.Camera(800, 600) # width, height of the window box = gamebox.from_image( 600, 200, "https://www.python.org/static/opengraph-icon-200x200.png") walls = [ gamebox.from_color(camera.x, camera.bottom, "black", 500, 50), gamebox.from_color(400, 200, "black", 50, 500), gamebox.from_color(80, 120, "black", 50, 50) ] goal = gamebox.from_text(100, 400, 'goal', 'Arial', 20, 'blue') def tick(keys): camera.clear('cyan') if pygame.K_RIGHT in keys: box.x += 10 if pygame.K_LEFT in keys: box.x -= 10 if pygame.K_UP in keys: box.y -= 10 if pygame.K_DOWN in keys: box.y += 10 for wall in walls: box.move_to_stop_overlapping(wall, -30, -30) camera.draw(box) for wall in walls:
#Overview: we will make an underwater/ocean themed game where the user plays a fish/turtle/mermaid and has to #collect shells, and avoid being eaten by sharks import pygame import gamebox, sys import random import urllib, os.path # # if 'urlretrieve' not in dir(urllib): # from urllib.request import urlretrieve as _urlretrieve # else: # _urlretrieve = urllib.urlretrieve # pygame.init() camera = gamebox.Camera(1024, 576) score = 0 scoreboard = gamebox.from_text(750, 10, "SCORE: " + str(score), "Arial", 20, "white") fish = gamebox.from_image(350, 300, 'f3.png') fish.scale_by(0.1) underline = gamebox.from_color(350, 350, "black", 100, 20) r1 = gamebox.from_image(100, 600, 'r1.png') # gamebox.from_color(250, 600, 'black', 50, 100), # gamebox.from_color(400, 600, 'black', 70, 30), r2 = gamebox.from_image(600, 600, 'r2.png') r1.scale_by(0.5) r2.scale_by(0.25) rocks = [r1, r2]
scores.write(score + '\n') def readScore(): with open("highscores.txt", 'r') as scores: max = 0 for line in scores: line = int(line) if line > max: max = int(line) return str(max) # title and instruction screens Width, Length = 800, 700 camera = gamebox.Camera(Width, Length) imageLink = "https://virginia.box.com/shared/static/" # used to shorten code in the future # music music = gamebox.load_sound(imageLink + "cb5aac92sf9r1zm9ztmb5vxu7g19s4pa") musicplayer3 = music.play(-1) # loading screens splashscreen1 = gamebox.load_sprite_sheet( imageLink + "v661x3zpy4fge6wi8ubbinp3ey0r4495", 1, 16) splashscreen1dummy = gamebox.from_color(camera.x, camera.y, 'black', 800, 700) splashscreen2 = gamebox.load_sprite_sheet( imageLink + "g7wvy29g47qjgkrdobmiqctyuhxnjtil", 1, 16) splashscreen2dummy = gamebox.from_color(camera.x, camera.y, 'black', 800, 700) # conditions that control appearance of menus and other items
# ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- # # ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- # import pygame # Gets the pygame library import gamebox import random # Imports the random module """ This is a Pong like game made as an assignment for CS-1111 Game Project. This project was done using the gamebox module developed by Professor Luther Tychonievich. This is the classic Pong game - Try to score more than your opponent :-) """ width = 800 # This is the width of the screen height = 600 # This is the height of the screen camera = gamebox.Camera(width, height) # This is the screen shown number = random.randint(0, 4) # A random number between 1-4 is chosen p_width = 10 # The player width p_height = 80 # The player heights ball_velocity = 15 # The ball velocity player_speed = 15 # The player speeds red_score = 0 # The score for the red team green_score = 0 # The score for the green team game_on = False # The game status numberLimit = 10 # The limit of the game <------------------- This is the max score of the game walls = \ [ gamebox.from_color(400, 600, "yellow", 1000, 20), # This is the bottom wall on the screen gamebox.from_color(400, 0, "yellow", 1000, 20), # This is the top wall on the screen
import pygame import gamebox camera = gamebox.Camera(200, 200) ship = gamebox.from_image( 100, 100, "http://www.cs.virginia.edu/~up3f/cs1111/images/spaceship.jpg") # try different x,y coordinate (notice the screen size (200, 200) above) def tick(keys): camera.clear('black') if pygame.K_LEFT in keys: ship.x -= 5 if pygame.K_RIGHT in keys: ship.x += 5 if pygame.K_UP in keys: ship.y -= 5 if pygame.K_DOWN in keys: ship.y += 5 camera.draw(ship) camera.display() gamebox.timer_loop(30, tick)
# Scrolling Level - The game will expand beyond the screen with new blocks and obstacles moving across the screen # Multiple Levels - The game can have multiple levels with different obstacles # Save Points - Allow users to return to beginning of level or to previous levels # All file and source code can be found at https://github.com/thh4yj/CS1111FinalProject # GAME CODE BELOW!!! import pygame import gamebox # set up display pygame.display.set_caption("SANTA RUN!") screen_width = 500 screen_height = 400 camera = gamebox.Camera(screen_width, screen_height) # IMAGES - all are from www.gameart2d.com # -------- images and sprites are copyright/royalty free and free to use! # walking animation images run_stages = ["Run (1).png", "Run (2).png", "Run (3).png", "Run (4).png", "Run (5).png", "Run (6).png", "Run (7).png", "Run (8).png", "Run (9).png", "Run (10).png", "Run (11).png"] # sliding animation images slide_stages = ["Slide (1).png", "Slide (2).png", "Slide (3).png", "Slide (4).png", "Slide (5).png", "Slide (6).png", "Slide (7).png", "Slide (8).png", "Slide (9).png", "Slide (10).png", "Slide (11).png"] # jumping animation images
#Michael Quinn mjq4my & Daniel Forsman dhf5qe #Zombies import pygame import gamebox import random camera = gamebox.Camera(1200, 700) shooter = gamebox.from_image( 135, 350, "http://images.clipartpanda.com/shooter-clipart-shooter-clipart-1.jpg") backgr = gamebox.from_image( 600, 350, "http://orig12.deviantart.net/eced/f/2014/312/f/c/abandoned_factory_by_stgspi-d85o7fq.png" ) start_pic = gamebox.from_image( 600, 350, "http://img08.deviantart.net/e319/i/2013/334/8/8/the_pale_forest_by_nelleke-d6w6lnu.png" ) intro = gamebox.from_text(camera.x, 100, "Welcome to Zombies", "Impact", 60, "white") instructions = gamebox.from_text( camera.x, 600, "Instructions: Press up and down to move, space to shoot. Defeat all three waves of zombies.", "Impact", 30, "white") names = gamebox.from_text(camera.x, 170, "Michael Quinn (mjq4my) & Daniel Forsman (dhf5qe)", "Impact", 30, "white") starting = gamebox.from_text(camera.x, 650, "Press s to start", "Impact", 40, "white") wave1 = gamebox.from_text(camera.x, 50, "WAVE 1", "Impact", 30, "red") wave2 = gamebox.from_text(camera.x, 50, "WAVE 2", "Impact", 30, "red")
# Modified from example by Prof. Tychonievich import pygame import gamebox camera = gamebox.Camera(300, 300) character = gamebox.from_color(150, 150, 'brown', 10, 10) things = [ gamebox.from_color(150, 250, 'green', 200, 50), gamebox.from_color(220, 200, 'white', 20, 100), gamebox.from_color(80, 100, 'black', 80, 20), ] moving = [ gamebox.from_color(120, 150, 'red', 20, 20), ] for thing in moving: thing.being_carried = False def tick(keys): camera.clear('lightblue') if pygame.K_LEFT in keys: character.x -= 5 if pygame.K_RIGHT in keys: character.x += 5 if pygame.K_UP in keys: for thing in things + moving: if character.bottom_touches(thing): character.speedy = -15
# Daniel Zarco - dz7as # Andrew Carl - ac2mx import pygame import gamebox import random camera = gamebox.Camera(1300, 700) game = 0 count = 0 t = 0 speed = 0 rotate = 0 p1_score = 100 plane1 = gamebox.from_image(400, 100, "http://i.imgur.com/Ay7WRQQ.png") title_png = gamebox.from_image(650, 125, "http://i.imgur.com/HpLlOk5.png") top_barrier = gamebox.from_color(650, -20, "red", 1300, 40) bottom_barrier = gamebox.from_color(650, 720, "red", 1300, 40) random_s = random.randrange(50, 650) s = gamebox.from_image(1400, random_s, "http://i.imgur.com/ULNNSrE.png") mama = gamebox.from_image(100, 350, "http://i.imgur.com/7CaRxO9.png") stars = [] for y in range(0, 1301, 2): stars.append( gamebox.from_color(random.randrange(0, 1305), y, 'white', 2, 2)) asteroids_20 = [] for y in range(0, 1100, 50): asteroids_20.append( gamebox.from_image(random.randrange(200, 1450), y,
# Andrew Walsh, abw9yd, CS 1111, Fall 2016 import pygame import gamebox import random screen_width = 1000 screen_length = 600 camera = gamebox.Camera(screen_width, screen_length) counter_space = 0 counter_coins = 0 counter_enemy = 0 counter_side = 0 counter_air = 0 life = 500 heal = 0 # Keeps character facing the same directions orientation = 'R' sheet = gamebox.load_sprite_sheet('images2.png', 5, 8) enemy_sheet = gamebox.load_sprite_sheet('flameskull.png', 4, 3) coin_sheet = gamebox.load_sprite_sheet('coins.png', 4, 8) arrow_sheet = gamebox.load_sprite_sheet('play_arrow.png', 2, 1) inst_button_sheet = gamebox.load_sprite_sheet('inst_button.png', 2, 1) character = gamebox.from_image(screen_width / 2, screen_length / 2, sheet[counter_space]) enemies = [ gamebox.from_image(random.randint(10, 990), 30, enemy_sheet[counter_enemy]) ] kills = 0 character_speed = 0 coins = []
# Very simple character movement example. # Craig Dill (cd9au) # When gamebox.timer_loop() method calls the tick method it sends a set of keys pressed to the keys parameter. # pygame defines the keys with constants and these constants are used to test if particular key (combinations) # are currently pressed by the user. import pygame import gamebox camera = gamebox.Camera(800, 600) # size of window character = gamebox.from_color(camera.x, camera.y, "green", 10, 10) def tick(keys): # Use pygame key definitions to detect user keyboard input. Parameter keys can have more than one key # if the decision statements below are converted into if elif, only one key is detected each tick, even though # multiple keys are pressed if pygame.K_RIGHT in keys: character.x += 1 if pygame.K_LEFT in keys: character.x -= 1 if pygame.K_UP in keys: character.y -= 1 if pygame.K_DOWN in keys: character.y += 1 camera.clear("red") camera.draw(character) camera.display() ticks_per_second = 30
pokemon2_1 = Pokemon( input("Player 2, what is your first Pokemon " "(This will be the first pokemon sent out during the battle)? ")) pokemon2_2 = Pokemon(input("What is your second Pokemon? ")) pokemon2_3 = Pokemon(input("What is your third Pokemon? ")) pokemon2_4 = Pokemon(input("What is your fourth Pokemon? ")) pokemon2_5 = Pokemon(input("What is your fifth Pokemon? ")) pokemon2_6 = Pokemon(input("What is your sixth Pokemon? ")) pokemon1_active = pokemon1_1 pokemon2_active = pokemon2_1 # ------ DISPLAY -------- #displays the initial pokemon sprites and health bars that are updated when changed # ------ SMALL CAMERA ------ camera = gamebox.Camera(600, 450) pokemon1_out = gamebox.from_image( 150, 250, "Sprites/" + str(pokemon1_active.get_name()) + ".png") pokemon2_out = gamebox.from_image( 450, 50, "Sprites/" + str(pokemon2_active.get_name()) + ".png") pokemon1_health = gamebox.from_color( 150, 210, "green", pokemon2_active.get_battle_hp() / pokemon2_active.get_hp() * 100, 5) pokemon2_health = gamebox.from_color( 450, 15, "green", pokemon2_active.get_battle_hp() / pokemon2_active.get_hp() * 100, 5) walls = [ gamebox.from_color(298, 375, "black", 4, 150), gamebox.from_color(400, 300, "black", 800, 4) ] player1_done = False
import pygame, gamebox #objects camera = gamebox.Camera(1400,600) walkSheet = gamebox.load_sprite_sheet( "Rambo Walk.png", 1,4) gunSheet = gamebox.load_sprite_sheet("Rambo Gun.png",1,4) badTankSheet = gamebox.load_sprite_sheet('badTank.png',1,7) uvaTankSheet = gamebox.load_sprite_sheet('UVATank.png',1,7) vtVillanSheet = gamebox.load_sprite_sheet('vtBadGuy.png',1,4) explosionSheet = gamebox.load_sprite_sheet('explosion.png',1,3) flyRambo = gamebox.from_image(0,0,'flyRambo.png') flySheet = gamebox.load_sprite_sheet('flySheet.png',1,4) coverPic = gamebox.from_image(700,300,'CoverPic.png') wallList = [ gamebox.from_color(3500,600,"black",8000,100), gamebox.from_color(350,380,"black",300,25),gamebox.from_color(4900,380,'black',600,25), gamebox.from_color(11500,600,"black",6000,100),gamebox.from_color(7870,380,"black",400,25), gamebox.from_color(8300,280,"black",300,25),gamebox.from_color(15900,550,'black',2000,200), ] weaponList = [gamebox.from_image(350,340,'MachineGun.png'),gamebox.from_image(10000,460,'unmannedTank.png'), gamebox.from_image(16300,420,'flyBoot.png')] villanList = [gamebox.from_image(2500,468,vtVillanSheet[0]),gamebox.from_image(1500,468,vtVillanSheet[0]), gamebox.from_image(2000,468,vtVillanSheet[0]),gamebox.from_image(5000,468,vtVillanSheet[0]), gamebox.from_image(5200,468,vtVillanSheet[0]),gamebox.from_image(5400,468,vtVillanSheet[0]), gamebox.from_image(8400,0,vtVillanSheet[0]),gamebox.from_image(10500,468,vtVillanSheet[0]), gamebox.from_image(10700,468,vtVillanSheet[0]),gamebox.from_image(10900,468,vtVillanSheet[0]), gamebox.from_image(16000,368,vtVillanSheet[0]),gamebox.from_image(16200,368,vtVillanSheet[0])]
def __init__(self, kind=1, start=None): """Robot() makes a robot in the corer of a square grid, as does Robot(1) Robot(2) makes a robot in the corer of a rectangular grid Robot(3) makes a robot randomly placed in a rectangular grid Robot(4) makes a robot randomly placed in a random mess of rooms Robot(''' xxxxx xxxxxxx xx xxx xx xxxx xxxx xxxx xxxx xx xxx xx xxx xxx xxxxxxx xxxxx ''') makes a robot inside a smiley face All versions have an optional "start position" parameter; if given it should be an x,y coordinate, with (0,0) the top left corner with x increasing to right and y to bottom""" import pygame self.scale = 35 try: self.scale = min(pygame.display.Info().current_w, pygame.display.Info().current_h) // 24 except: pass surf = pygame.surface.Surface((self.scale * 2, self.scale * 2), pygame.SRCALPHA, 32) pygame.draw.polygon(surf, (95, 47, 0), [(0, 0), (self.scale, self.scale), (0, self.scale * 2)]) pygame.draw.polygon(surf, (191, 255, 0), [(0, 0), (self.scale, self.scale), (self.scale * 2, 0)]) pygame.draw.polygon(surf, (63, 0, 63), [(self.scale * 2, 0), (self.scale, self.scale), (self.scale * 2, self.scale * 2)]) pygame.draw.polygon(surf, (207, 191, 63), [(0, self.scale * 2), (self.scale, self.scale), (self.scale * 2, self.scale * 2)]) pygame.draw.rect( surf, (191, 191, 191), pygame.rect.Rect( self.scale // 4, self.scale // 4, 6 * self.scale // 4, 6 * self.scale // 4, )) self.room = gamebox.SpriteBox(0, 0, surf, None) self.door = gamebox.from_color(0, 0, (0, 127, 127), 1, 1) self.b = gamebox.from_circle(self.scale * 3, self.scale * 3, 'white', self.scale // 2, 'black', 3 * self.scale // 8) self.eye = gamebox.from_circle(self.scale * 3, self.scale * 3, 'black', self.scale // 2, 'white', 7 * self.scale // 16) self.pupil = gamebox.from_circle(self.scale * 3, self.scale * 3, 'black', self.scale // 4) self.ok = True self.look = (0, 0) if kind == 1: # square, corner s = random.randrange(2, 10) self.open = {(a, b) for a in range(s) for b in range(s)} self.c = gamebox.Camera(self.scale * s * 2, self.scale * s * 2) if start not in self.open: start = (0, 0) self.b.center = (start[0] * 2 + 1) * self.scale, (start[1] * 2 + 1) * self.scale elif kind == 2: # rectangle, corner w, h = random.randrange(2, 10), random.randrange(2, 10) self.open = {(a, b) for a in range(w) for b in range(h)} self.c = gamebox.Camera(self.scale * w * 2, self.scale * h * 2) if start not in self.open: start = (0, 0) self.b.center = (start[0] * 2 + 1) * self.scale, (start[1] * 2 + 1) * self.scale elif kind == 3: # rectangle, not corner w, h = random.randrange(2, 10), random.randrange(2, 10) self.open = {(a, b) for a in range(w) for b in range(h)} self.c = gamebox.Camera(self.scale * w * 2, self.scale * h * 2) if start not in self.open: start = random.choice(list(self.open)) self.b.center = (start[0] * 2 + 1) * self.scale, (start[1] * 2 + 1) * self.scale elif kind == 4: # diamond, top s = random.randrange(1, 5) self.open = set() for i in range(s * 2 + 1): dist = s - abs(i - s) for k in range(s - dist, s + dist + 1): self.open.add((i, k)) self.c = gamebox.Camera(self.scale * (2 * s + 1) * 2, self.scale * (2 * s + 1) * 2) if start not in self.open: start = (s, 0) self.b.center = (start[0] * 2 + 1) * self.scale, (start[1] * 2 + 1) * self.scale elif kind == 5: # diamond, random s = random.randrange(1, 5) self.open = set() for i in range(s * 2 + 1): dist = s - abs(i - s) for k in range(s - dist, s + dist + 1): self.open.add((i, k)) self.c = gamebox.Camera(self.scale * (2 * s + 1) * 2, self.scale * (2 * s + 1) * 2) if start not in self.open: start = random.choice(list(self.open)) self.b.center = (start[0] * 2 + 1) * self.scale, (start[1] * 2 + 1) * self.scale elif kind == 6: # spiral s = random.randrange(3, 7) rot = random.randrange(4) self.open = set() p = [0, 0] for side in range(s): dx, dy = 0, 0 side += rot if side & 1: dx = (side & 2) - 1 else: dy = (side & 2) - 1 side -= rot for k in range(side + 1): self.open.add(tuple(p)) p[0] += dx p[1] += dy mx, Mx = min(_[0] for _ in self.open), max(_[0] for _ in self.open) my, My = min(_[1] for _ in self.open), max(_[1] for _ in self.open) w = Mx - mx + 1 h = My - my + 1 self.open = {(_[0] - mx, _[1] - my) for _ in self.open} self.c = gamebox.Camera(self.scale * w * 2, self.scale * h * 2) if start not in self.open: start = (-mx, -my) self.b.center = (start[0] * 2 + 1) * self.scale, (start[1] * 2 + 1) * self.scale elif kind == 7: # spiral, random placement s = random.randrange(3, 7) rot = random.randrange(4) self.open = set() p = [0, 0] for side in range(s): dx, dy = 0, 0 side += rot if side & 1: dx = (side & 2) - 1 else: dy = (side & 2) - 1 side -= rot for k in range(side + 1): self.open.add(tuple(p)) p[0] += dx p[1] += dy mx, Mx = min(_[0] for _ in self.open), max(_[0] for _ in self.open) my, My = min(_[1] for _ in self.open), max(_[1] for _ in self.open) w = Mx - mx + 1 h = My - my + 1 self.open = {(_[0] - mx, _[1] - my) for _ in self.open} self.c = gamebox.Camera(self.scale * w * 2, self.scale * h * 2) if start not in self.open: start = random.choice(list(self.open)) self.b.center = (start[0] * 2 + 1) * self.scale, (start[1] * 2 + 1) * self.scale elif kind == 8: # random cells = [(0, 0)] w, h = 1, 1 while w < 10 and h < 10: x, y = random.choice(cells) if random.randrange(2) == 0: x += random.randrange(-1, 2, 2) else: y += random.randrange(-1, 2, 2) if (x, y) not in cells: cells.append((x, y)) w = 1 + max(_[0] for _ in cells) - min(_[0] for _ in cells) h = 1 + max(_[1] for _ in cells) - min(_[1] for _ in cells) mx, my = min(_[0] for _ in cells), min(_[1] for _ in cells) self.open = {(a - mx, b - my) for (a, b) in cells} self.c = gamebox.Camera(self.scale * w * 2, self.scale * h * 2) if start not in self.open: start = random.choice(list(self.open)) self.b.center = (start[0] * 2 + 1) * self.scale, (start[1] * 2 + 1) * self.scale elif type(kind) is str: cells = set() for y in range(len(kind.split('\n'))): row = kind.split('\n')[y] for x in range(len(row)): cell = row[x] if not cell.isspace(): cells.add((x, y)) w = 1 + max(_[0] for _ in cells) - min(_[0] for _ in cells) h = 1 + max(_[1] for _ in cells) - min(_[1] for _ in cells) mx, my = min(_[0] for _ in cells), min(_[1] for _ in cells) self.open = {(a - mx, b - my) for (a, b) in cells} self.c = gamebox.Camera(self.scale * w * 2, self.scale * h * 2) if start not in self.open: start = random.choice(list(self.open)) self.b.center = (start[0] * 2 + 1) * self.scale, (start[1] * 2 + 1) * self.scale else: raise ValueError('Invalid room kind: ' + repr(kind)) self.moves = 0 self.looks = 0 print('Correct answer:', len(self.open))
- make special attack for when connecting with hammer if space is pressed. - more speed = more damage rmm3ya. """ import pygame import gamebox # gamebox written by Luther Tychonievich import math CAMERA_WIDTH, CAMERA_HEIGHT = 800, 600 BOX_WIDTH, BOX_HEIGHT = 10, 10 walksprite_frame = 0 framecountforplayerwalk = 0 camera = gamebox.Camera(CAMERA_WIDTH, CAMERA_HEIGHT) # size of window and camera points to the center player = gamebox.from_image(camera.x, camera.y, gamebox.load_sprite_sheet("/Users/rezamirzaiee/Desktop/GAME/Graphics/chara5.png", 8, 12)[1]) hammer = gamebox.from_color(player.x, player.y, "black", 10, 10) hammer_thrown = False has_stood = False playerdirection = gamebox.from_image(camera.x, camera.y, gamebox.load_sprite_sheet("/Users/rezamirzaiee/Desktop/GAME/Graphics/chara5.png", 8, 12)[1]) player_xspeed = 0 player_yspeed = 0 hammer_xspeed = 0 hammer_yspeed = 0 hammer_air = { 'hammer_xspeed_air': 0, 'hammer_yspeed_air': 0}
""" Boardgame with minigames! (needs a better title) Ben Life & Oliver Song HooHacks 2021 Built on PyGame and Gamebox Gamebox was built by Luther Tychonievich ([email protected]) """ import pygame import gamebox import random camera = gamebox.Camera(1000, 700) miniGames = ["ClickingRainbow", "Maze", "AstroidDodge", "CrossStreet", "PatternRepeat"] random.shuffle(miniGames) miniGame = None gamePaused = True currentIndex = 0 num_of_rolls = 0 rollingActive = False final_roll = None miniGameIndex = 0 astroid_timer = 10 astroid_tick_counter = 0 astroid_player_speed = 15 astroids = [ gamebox.from_image(0, 0, "asteroid.png"), gamebox.from_image(500, 0, "asteroid.png"), gamebox.from_image(1000, 0, "asteroid.png"), gamebox.from_image(0, 900, "asteroid.png"),
# Ruolin Chen, rlc8my # Christine Li, cjl4ev import pygame import gamebox camera = gamebox.Camera(1142, 636) background = gamebox.from_image(camera.x, camera.y, "night_time.png") creators = gamebox.from_text(280, 20, "Creators: Christine Li (cjl4ev), Ruolin Chen (rlc8my)", "Snap ITC", 18, "white") game_name = gamebox.from_text(camera.x, 280, "Counting Sheep", "Snap ITC", 60, "white") description = gamebox.from_text(camera.x, 340, "How long can you jump fences for?", "Snap ITC", 24, "white") rules1 = gamebox.from_text(camera.x, 370, "Jump fences without touching them or you lose a life!", "Snap ITC", 24, "white") rules2 = gamebox.from_text(camera.x, 400, "You get three lives, collect clovers to recover lives.", "Snap ITC", 24, "white") p1_instructions = gamebox.from_text(camera.x, 440, "Press SPACE to Jump", "Snap ITC", 24, "white") to_start = gamebox.from_text(camera.x, 480, "Press ENTER to Start", "Snap ITC", 32, "white") music = gamebox.load_sound('crickets_compressed.wav') music_player = music.play(-1) ground = gamebox.from_color(600, 634, "black", 1200, 50) fence = gamebox.from_image(1000, 550, "fence.png") fence.scale_by(.50) character = gamebox.from_image(350, 545, "sheep.png") character.scale_by(.20) lives = gamebox.from_text(950, 40, "Lives left:", "Snap ITC", 24, "white") health3 = gamebox.from_image(1075, 100, "sheep.png")
#J Preston Harvey jph8rw #George Wilson gaw8cf import pygame import gamebox import random state = 'intro' counter = 0 timer = 0 timer2 = 0 camera = gamebox.Camera(600, 800) walls = [] powerup_speed = [] powerup_clear = [] powerup_wrap = [] coins1 = [] coins2 = [] coins3 = [] coins4 = [] powerup_bomb = [] points = 0 wall_left = gamebox.from_color(0, 400, 'cyan', 15, 800) wall_right = gamebox.from_color(600, 400, 'cyan', 15, 800) colors = [ 'green', 'cyan', 'yellow', 'magenta', 'orange', 'blue1', 'chartreuse1', 'deeppink1' ] sheet = gamebox.load_sprite_sheet(
# Matthew Keitelman (mak2vr) # Fernando Mata Cordero (fm5ew) import pygame import gamebox camera = gamebox.Camera(1000,800,True) alien = gamebox.from_image(150, 10, "alien.png") alien.scale_by(1.4) alien.yspeed = 0 levels = gamebox.from_image(400,400,"levels.png") levels.scale_by(1.5) blue_hole_sheet = gamebox. platforms = [ # gamebox.from_color(-100, 600, "black", 3000, 100), levels # ground1 ] def tick(keys): # GRAVITY alien.yspeed += 1 alien.y = alien.y + alien.yspeed if pygame.K_s in keys: alien.image = "alien_top.png" elif pygame.K_d in keys:
# ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- # # ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- # # ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- # import pygame # Imports the pygame module import gamebox # Imports the gamebox module import random # Imports the random module """ This is a flappybird like game made as an assignment for CS-1111 Game project. This project was done using the gamebox module developed by Professor Luther Tychonievich. Other sources of help include google images where I acquired the images for the project and altered them to my fitting. This made the game look better :-) """ width = 800 # This is how wide the screen is height = 600 # This is how tall the screen is camera = gamebox.Camera(width, height) # This is the camera that pans the screen. bird_straight = 'http://drive.google.com/uc?export=view&id=1jNuB1HkF7KFI5z2BZ3DZ2lDDvktAgC2c' # Normal bird view when not falling bird_down = 'http://drive.google.com/uc?export=view&id=1f0dvy0JAq3q-CqvS1U8MgBZWoetbAt4l' # Bird view when falling obstacle_bottom = 'http://drive.google.com/uc?export=view&id=1JEC3kpyrVkw9pzZt40Lf5PHifYQRB0B1' # This is the obstacle coming from the top. obstacle_top = 'http://drive.google.com/uc?export=view&id=1AuHD1JOaQ4sLt_wqivfvWtL0J2SmnFxZ' # This is the obstacle coming from the bottom background = 'http://drive.google.com/uc?export=view&id=1uxUB5tClq-I3YgSRQ0bPzYZ95PBlT8Kt' # This is the background image for the screen fall_speed = 1 # This is how fast the bird falls ar first <---------------------- This value changes exponentially as the bird falls more. obstacle_speed = -4 # This is how fast the game moves (negative to go in the opposite direction) <----------------- Change this value to alter the speed of the game. obstacles_generation = 10 # This is how many obstacles are generated every 10 seconds of the game. (1 every seconds) score_number = 0 # This is the score of the game <-------------------------- This value changes as more obstacles are avoided. counter = 0 # This is a counter to generate more obstacles. position = 800 # This is the position that the obstacle is made. bird = bird_straight # Initial making of the bird sprite. bird_game = gamebox.from_image(width / 2, height / 2,
# Olivia Goodrich (otg5nt) and Camille Favero (caf3wu) # health code ~ line 136 # Game idea: Xtreme Tetris # Iterates through multiple levels of modifications as the player progresses, # including enemy fire, base triangle pieces, and the Flappy gauntlet. # Optional features: enemy, timer, health meter, multiple levels import pygame import gamebox import random import t_pieces camera = gamebox.Camera(320, 640) ticker = 0 # Game conditions time_s = 0 score = 0 health = 3 past_pieces = [] game_on = False trimode = True enemy_mode = False if trimode: current_piece = t_pieces.tritrominoes[random.randint( 0, 5)] # keeps current_piece from reassigning every frame else: current_piece = t_pieces.tetrominoes[random.randint(0, 6)]
#Some notes: after collecting 50 coins, the game gets faster. Collect 100 and 130, and the game gets even faster. #Try to get a 'Flawless' game -- getting 130 coins without going below 100 health! import pygame import gamebox import random camera = gamebox.Camera(400, 400) randsize = random.randrange(30, 60) print(randsize) platforms = [ gamebox.from_color(camera.x, camera.bottom, 'dark green', camera.right + 10, 40) ] rain = [ gamebox.from_color(camera.left + 100, camera.top, 'red', 10, 10), gamebox.from_color(camera.left + 200, camera.top, 'red', 10, 10), gamebox.from_color(camera.left + 300, camera.top, 'red', 10, 10) ] healthplus = [ gamebox.from_image(camera.right + 1000, camera.top + 300, 'plus.png') ] healthplus[0].size = 15, 15 music = gamebox.load_sound("savantsplinter.wav") box = gamebox.from_text(40, 200, "HE", "Arial", 35, "red") lava = gamebox.from_color(camera.x, camera.bottom, 'red', randsize, 40) coins = [
Timer: have a visible timer that counts to 60, game ends if you don't have enough points by the time it hits 60 Health Meter: Your collectibles refill Slenderman's health. If you hit too many hazards and it goes to below zero, you lose! """ import pygame import gamebox import random # images width = 800 height = 600 camera = gamebox.Camera(width, height) slenderman = gamebox.from_image(400, 560, "http://www.pngonly.com/wp-content/uploads/2017/05/Slender-Man-Small-PNG.png") slenderman.scale_by(0.2) background = gamebox.from_image(300, 300, 'https://3c1703fe8d.site.internapcdn.net/newman/gfx/news/2018/europeslostf.jpg') # variables game_on = False score_count = 0 counter = 0 # how many times tick is run milk = [] # he's lactose intolerant! very bad capri_sun = [] # that good stuff points = 0 # corresponds to energy instructions = """ Hey, it's Slenderman! I'm back at my lair trying to refuel with my favorite power-up, Capri-Sun.
# Thomas Rochman (ttr5n) ''' Character designs and running animations by Hope Radel ''' import random, gamebox, pygame camera = gamebox.Camera(1280, 800) p1 = gamebox.from_color(100, 50, "red", 30, 60) p2 = gamebox.from_color(700, 50, "red", 30, 60) ground = gamebox.from_color(400, 450, "black", 750, 100) backgroundimg = gamebox.from_image(640, 300, "background.png") groundimg = gamebox.from_image(400, 600, "Ground.png") on_button = gamebox.from_color(550, 650, "red", 100, 50) off_button = gamebox.from_color(730, 650, "green", 100, 50) platform_1 = gamebox.from_color(200, 250, "black", 100, 10) platform_2 = gamebox.from_color(600, 250, "black", 100, 10) platform_3 = gamebox.from_color(400, 100, "black", 200, 10) platform_4 = gamebox.from_color(750, 300, "black", 200, 10) platform_5 = gamebox.from_color(50, 300, "black", 200, 10) platforms = [platform_1, platform_2, platform_3, platform_4, platform_5] platformimage1 = gamebox.from_image(platform_1.x, platform_1.y, "platform_image1.png") platformimage2 = gamebox.from_image(platform_2.x, platform_2.y, "platform_image1.png") platformimage3 = gamebox.from_image(platform_3.x, platform_3.y, "platform_image2.png") platformimage4 = gamebox.from_image(platform_4.x, platform_4.y, "platform_image2.png")
# pharma game import pygame import gamebox import random from pygame.locals import * camera = gamebox.Camera(800, 750) display = pygame.display.set_mode((800, 750)) image = pygame.image.load("hospital.jpg") sheet1 = gamebox.load_sprite_sheet( "https://3.bp.blogspot.com/-_NVjscKbE7Q/WLB4GtYM6PI/AAAAAAAAIyk/iGm67QmaiV0v0VKNSnG5pzenizWGsbvyQCLcB/s1600/trump_run.png", 4, 6) sheet1 = [ sheet1[6], sheet1[7], sheet1[8], sheet1[9], sheet1[10], sheet1[11], ] obstacles = [ # patient room gamebox.from_color(625, 315, 'green', 20, 20), # pharmacy room gamebox.from_color(295, 630, 'green', 20, 20), gamebox.from_color(340, 255, 'green', 20, 20), gamebox.from_color(135, 375, 'green', 20, 20),
# Christopher Geier (cpg3rb) # Pong (Starter Code) import pygame import gamebox import random import time camera = gamebox.Camera(800, 600) p_width = 10 p_height = 80 ball_velocity = 15 player_speed = 14 p1_score = 0 p2_score = 0 game_on = False ticker = 0 walls = [ gamebox.from_color(400, 600, "green", 1000, 20), gamebox.from_color(400, 0, "green", 1000, 20), ] top_barrier = gamebox.from_color(700, -100, "red", 20, 600) bot_barrier = gamebox.from_color(700, 700, "red", 20, 600) p1 = gamebox.from_color(20, 400, "red", 15, 15) count = 0 #ball.xspeed = ball_velocity #ball.yspeed = ball_velocity
def spawn_jetpack(x, y): jetpack = gamebox.from_image(x, y, jetpack_sprite_sheet[0]) jetpacks.append(jetpack) objects.append(jetpack) def draw_collection(collection): for item in collection: camera.draw(item) # Preparation camera = gamebox.Camera(CAMERA_WIDTH, CAMERA_HEIGHT) player_sprite_sheet = gamebox.load_sprite_sheet(SPRITESHEET_PATH, SPRITESHEET_ROW_COUNT, SPRITESHEET_COLUMN_COUNT) # 0-8 in increasing size, 9 and 10 for left and right jetpack_sprite_sheet = gamebox.load_sprite_sheet("Jetpack_spritesheet.png", 1, 3) player = gamebox.from_image(200, 550, player_sprite_sheet[8]) player.speedy = -20 platforms = [ gamebox.from_color(rand_platform_x(), CAMERA_HEIGHT - VERTICAL_DIST_BTW_PLATFORMS * i, "Green", PLATFORM_WIDTH, PLATFORM_HEIGHT) for i in range(PLATFORM_COUNT) ]