Пример #1
0
    def __init__(self):
        '''game constructor: create attributes, start game'''

        #initialize sprite lists
        self.all_sprites_list = pygame.sprite.Group()

        #initialize room list
        self.room_list = []
        self.room_list.append(rooms.Home())
        self.room_list.append(rooms.InsideHome())
        self.room_list.append(rooms.Beach())

        #spawn in this room
        self.current_room = self.room_list[1]

        #make a player sprite
        self.player = Player()
        self.all_sprites_list.add(self.player)
Пример #2
0
import pyxel
import random
import initialization
from ballclass import Ball
from playerclass import Player
from missileclass import Missile

pyxel.init(256, 256)
initialization.initialize()

counter = 0
player = Player()
balls = []
state = 'GAMEOVER'
hiscore = 0
missiles = []


def update():
    global state
    if state == 'GAMEOVER':
        if pyxel.btn(pyxel.KEY_ENTER):
            start_game()
            state = 'PLAYING'
    else:
        update_playing()


def start_game():
    global counter, balls, player
    counter = 0
Пример #3
0
    def __init__(self):
        # this is super long omg
        # Bye Style Points...
        # but seriously though. its bad
        BHMode.init()

        self.triedToGoHome = False

        self.hasRained = False
        self.isRaining = False
        self.rain_thresh = 4000
        self.rainCount = 0
        self.max_rainCount = 60 * 60
        self.raindrops = pygame.sprite.Group()
        Raindrop.init()

        self.inBH = False
        self.BH = None
        self.BH1 = BHMode()
        #self.BH1.completed = True #!!
        self.BH2 = BHMode2()
        #self.BH2.completed = True #!!
        self.BH3 = BHMode3()
        #self.BH3.completed = True #!!
        # these comments were for testing purposes

        self.completed = False
        self.ending_thresh = 5980

        self.worldX = 0
        self.worldX_dx = 0
        self.max_worldX = 5400

        self.textbox = pygame.sprite.Group()
        self.textbox.add(Textbox())

        self.player = Player()
        self.playerList = pygame.sprite.Group()
        self.playerList.add(self.player)

        # add signs
        sign1 = Sign(300, [
            "\"Hello, I am a sign.\"",
            "\"Here is some important information:\"",
            "\"West: Residential area.\"", "\"East: Shopping district.\"",
            "\"I hope you found this helpful.\""
        ])
        sign2 = Sign(550, [
            "(There is a sticky note on this sign.)",
            "\"Dear Star Town citizens:\"", "\"It's me! Your mayor.\"",
            "\"Please join me in welcoming our new residents...\"",
            "\"Tomorrow.\"",
            "\"I don't want to miss the supermarket sale today!\""
        ])
        sign3 = Sign(1200, [
            "\"It's not 'trash CAN'T '...\"", "\"It's 'trash CAN' !!\"",
            "\"So, even if you are feeling like trash...\"",
            "\"Please, keep doing your best!!\"",
            "\"--Sincerely, a trash enthusiast.\""
        ])
        # (im the trash enthusiast)
        sign4 = Sign(2100, [
            "(It seems like someone has defaced this sign...)",
            "(Now there is a picture of a cat on it.)",
            "\"WANTED: cat who keeps eating my food\"",
            "\"Whoever you are, please stop...\""
        ])
        sign5 = Sign(2710, [
            "\"Space enthusiast meeting --\"", "\"Next Tuesday at 7pm.\"",
            "\"BYOS (Bring Your Own Spaceship).\""
        ])
        sign6 = Sign(3400, [
            "\"Star Town Tree:\"", "\"This tree was planted to commemorate\"",
            "\"the founding of our town.\"",
            "\"The tree supports our citizens in many ways,\"",
            "\"so please continue to support Star Town.\""
        ])
        sign7 = Sign(4900, ["\"Warning: dog.\"", "\"Very fluffy.\""])
        sign8 = Sign(5850, [
            "\"Supermarket -- just over to the right!\"",
            "\"Don't miss all our PRICES and SELECTIONS.\""
        ])
        self.signs = pygame.sprite.Group()
        self.signs.add(sign1, sign2, sign3, sign4, sign5, sign6, sign7, sign8)

        # add heal pts
        trash = HealPoint(
            rectY=180,
            worldX=1000,
            healthPts=10,
            imageName="trash-chan.png",
            textDict={
                False: [
                    "(It's a trash can.)", "(You find a burger in the trash.)",
                    "(You eat the burger and recover some HEALTH.)",
                    "(How disgusting...)"
                ],
                True: [
                    "(You ate the trash...)",
                    "(The trash is inside of you...)",
                    "(You feel like a trash can.)"
                ]
            })

        tallPerson = HealPoint(
            rectY=0,
            worldX=2300,
            healthPts=30,
            imageName="tall.png",
            textDict={
                False: [
                    "(It's an extremely tall individual.)",
                    "(For some reason, you feel very safe here.)",
                    "(You rest underneath the individual for a while...)",
                    "(Hopefully they didn't mind.)",
                    "(You recover some HEALTH.)"
                ],
                True: [
                    "(This individual is so tall,",
                    "that you can't see beyond their legs.)",
                    "(But, at least they have great footwear.)"
                ]
            })

        tree = HealPoint(
            rectY=0,
            worldX=3500,
            healthPts=30,
            imageName="tree.png",
            textDict={
                False: [
                    "(It's a great big tree.)",
                    "(You stop and take a break under it.)",
                    "(Suddenly, a piece of fruit falls in front of you!)",
                    "(You eat the fruit and regain some HEALTH.)",
                    "(Somewhere in the distance...)",
                    "(You sense that someone is greatly offended by this.)"
                ],
                True: [
                    "(You stay under the tree for a little while.)",
                    "(You feel so refreshed! Mentally, that is.)"
                ]
            })

        busStop = HealPoint(
            rectY=110,
            worldX=5500,
            healthPts=30,
            imageName="bus_stop.png",
            textDict={
                False: [
                    "(It's a bus stop.)",
                    "(You haven't seen the bus all day...)", "(But...)",
                    "(You're sure the bus is trying its best!!)",
                    "(Thinking of the bus increases your HEALTH.)"
                ],
                True: [
                    "(You keep thinking about the bus...)",
                    "(But nothing else happens. Aw.)"
                ]
            })

        self.healPoints = pygame.sprite.Group()
        self.healPoints.add(trash, tallPerson, tree, busStop)

        # add npc's
        egg = NPC(rectY=305,
                  worldX=800,
                  imageName="egg.png",
                  textDictM={
                      False: [
                          "\"Oh...hello...\"",
                          "\"I was just enjoying this nice sunlight.\"",
                          "\"I'll get out of the way.\""
                      ]
                  },
                  textDictD={
                      False: [
                          "\"Do you see that trash can over there?\"",
                          "\"I saw someone throw something away",
                          "a few minutes ago.\"",
                          "\"Maybe you should check it out.\""
                      ],
                      True: [
                          "\"The ground is all warm from the sun...\"",
                          "\"By the way, did you find anything in the trash?\""
                      ]
                  })
        egg.hasBH = False

        toast = NPC(
            rectY=250,
            worldX=1500,
            imageName="toast.png",
            textDictM={
                False: [
                    "\"Hello, new neighbor!\"", "\"You look hungry!\"",
                    "\"Did you eat breakfast today?\"",
                    "\"It's important to have a balanced breakfast.\"",
                    "\"Let me help you out.\"",
                    "\"Please take the breakfast items",
                    "that I am about to throw at you.\"",
                    "\"Run into them as hard as you can, ok??\"",
                    "\"I'm sure your HEALTH will improve in no time.\"",
                    "\"Of course, it's totally safe.\"",
                    "\"There is no way this can hurt you.\"", "(...)",
                    "(You hear a voice from above again...)",
                    "('Hey! Listen up!')",
                    "('Move around with the ARROW KEYS.')",
                    "('Try to dodge the projectiles!')",
                    "('If your HEART gets hit, you will lose HEALTH.')",
                    "('Hold down 'Z' to cry...')",
                    "('You will shoot tears at your opponent.')",
                    "('Crying will damage them...emotionally')",
                    "('They will leave you alone if they have low HP,)",
                    "('or if they run out of projectiles.')",
                    "('Hold down LEFT SHIFT to focus.')",
                    "('If you concentrate, you can slow your movements.')",
                    "('You will also cry harder.')",
                    "('Press 'X' to do something exciting.')",
                    "('If you distract your neighbor,')",
                    "('you can make them stop shooting momentarily.')",
                    "('You will also scare away the projectiles.')",
                    "('Finally, press 'P' to stop time.')",
                    "('It's fine to take a break.')",
                    "('OK, that's it! I hope you were paying attention!')",
                    "(...You carefully remember those instructions!)", "(...)",
                    "\"Are you ready?\"", "\"Here we go!\""
                ]
            },
            textDictD={
                False: [
                    "\"You didn't eat anything...\"",
                    "\"Do you not like food items...",
                    "...being hurled at you at high velocities?\"",
                    "\"Well...whatever works for you, I guess.\""
                ],
                True: [
                    "\"Are you headed to the supermarket?\"",
                    "\"It's all the way to your right.\"",
                    "\"You can go buy some fruits there...\"",
                    "\"Even though, I gave some to you for free.\""
                ]
            })
        toast.hasBH = True

        raindrop = NPC(
            rectY=255,
            worldX=1800,
            imageName="raindrop.png",
            textDictM={
                False: [
                    "\"Ah...I wish it was raining.\"",
                    "\"I love the rain. It's my element.\"",
                    "\"But I guess this weather is OK too.\"",
                    "\"...Oh, am I in your way?\"",
                    "\"I'll go stand a little bit to my right.\""
                ]
            },
            textDictD={
                False: [
                    "\"Sometimes the weather here gets really bad.\"",
                    "\"It'll rain so hard that, if the rain hits you...\"",
                    "\"You might even lose some HEALTH!\"",
                    "\"If you wanted to go anywhere...\"",
                    "\"You would have to dodge all the rain!!\"",
                    "\"Doesn't that sound fun? Haha.\"",
                    "\"Don't worry, though.\"",
                    "\"It won't happen to you today.\"",
                    "\"It might rain a little bit, but,\"",
                    "\"a slight drizzle won't hurt you.\""
                ],
                True: [
                    "\"It's good to stock up on food at home.\"",
                    "\"That way you won't have to go outside",
                    "when there's bad weather.\"", "\"...\"",
                    "\"What do you mean, you never go outside anyway??\""
                ]
            })
        raindrop.hasBH = False

        ufo = NPC(rectY=220,
                  worldX=2900,
                  imageName="ufo.png",
                  textDictM={
                      False:
                      ["\"...\"", "\".....\"", "\"....!\"", "\"! ! !\""]
                  },
                  textDictD={
                      False: [
                          "\"Oh no...I'm sorry, are you hurt?\"",
                          "\"I was just so excited about space.\"",
                          "\"I just moved here from space, you see.\"",
                          "\"I wanted to show everyone here",
                          "how cool and pretty my home was...\"",
                          "\"So I bought a bunch of plastic stars...\"",
                          "\"But now they're all over the ground.\"",
                          "\"...whoops...\""
                      ],
                      True: [
                          "\"...\"", "\"......\"", "\"...zzz...\"",
                          "(You look more closely at the UFO...)",
                          "(Oh! There is a very small cat inside.)",
                          "(The cat is taking a nap!)",
                          "(It must be nice and cozy in there.)"
                      ]
                  })
        ufo.hasBH = True

        cat = NPC(
            rectY=210,
            worldX=3850,
            imageName="cat.png",
            textDictM={
                False: [
                    "\"Someone keeps eating all my Frisky Bitz.\"",
                    "\"It's not you, is it??\"", "\"...\"",
                    "\"You don't look like a cat, so...\"",
                    "\"I guess it's someone else.\"",
                    "\"I mean, they pay me back for it, but still!\"",
                    "\"Now I have to go buy more all the time.\"",
                    "\"Sigh...\""
                ]
            },
            textDictD={
                False: [
                    "\"...Have you noticed all the stuff on the ground?\"",
                    "\"Those star-shaped rocks...\"",
                    "\"No one knows where they came from.\"",
                    "\"Except maybe the mayor.\"",
                    "\"I've never seen them before, but...\"",
                    "\"Sometimes you'll hear their voice from above.\"",
                    "\"So, has the mayor said anything to you yet?\"",
                    "(...You hear something from above...)",
                    "('...*coughing noises*...')",
                    "('...Sorry, I choked on a chip.')",
                    "('Did you need something?')",
                    "(...no thanks...you're good...)"
                ],
                True: [
                    "\"I'll be waiting here until I run into",
                    "whoever keeps eating my food.\"",
                    "\"You should go on ahead!\"",
                    "\"The shopping district is not so far ahead.\""
                ]
            })
        cat.hasBH = False

        dog = NPC(rectY=210,
                  worldX=5200,
                  imageName="dog.png",
                  textDictM={
                      False: [
                          "\"Woof!\"", "\"Don't come any closer!\"",
                          "\"I decided to dig up all my chew toys.\"",
                          "\"But now I have too many...\"",
                          "\"I can't hold on to all of them...\"",
                          "\"...Oh no...\"", "\"Oh no oh no oh no\"",
                          "\"Now they're dropping all over the place.\"",
                          "\"You'd better get out of the way!!\""
                      ]
                  },
                  textDictD={
                      False: [
                          "\"Bark bark!\"", "\"Are you ok??\"",
                          "\"I didn't mean for that to happen...\"",
                          "\"Oh no...\"", "(The dog looks sad...)",
                          "(You reach out to pet the dog.)",
                          "(The dog is so fluffy and nice...)",
                          "(After being pet, the dog looks happy again!)"
                      ],
                      True: [
                          "(You pet the dog again.)",
                          "(The dog is so happy!!)",
                          "(Petting the dog makes you feel happy too.)"
                      ]
                  })
        dog.hasBH = True

        self.NPCs = pygame.sprite.Group()
        self.NPCs.add(egg, toast, raindrop, ufo, cat, dog)

        self.currentSign = None
        self.currentHP = None
        self.currentNPC = None

        self.bg_ground = pygame.image.load("ground.png").convert_alpha()
        self.bg_bush = pygame.image.load("bushes.png").convert_alpha()
        self.bg_sky = pygame.image.load("sky.png").convert_alpha()
        self.bg_sun = pygame.image.load("sunlight.png").convert_alpha()
        self.bg_sun = pygame.transform.flip(self.bg_sun, True, False)