示例#1
0
 def collision(self):
     self.__lives -= 1
     if self.__lives == 0:
         global_var.mando.inc_score(30)
         message = "You defeated the boss! You won!"
         global_funct.display_ending(message)
         quit()
示例#2
0
    def check_mando_collision(self):
        for i in range(len(config.mando[0])):
            if self.__foo == 1:
                break
            for j in range(len(config.mando)):  
                if global_var.mando.yget()+j == self._posy and global_var.mando.xget()+i == self._posx:
                    global_var.mando.red_lives()
                    if global_var.mando.lives() == 0:
                        message = "Ded"
                        global_funct.display_ending(message)
                        quit()
                    global_var.mando.xdset(global_var.mp.start_index + 5)
                    self.__foo = 1
                    break                

        return self .__foo
示例#3
0
def movedin():
    # moves the player
    char = kb.getinput()

    if char == 'd':
        if mando.xget(
        ) <= global_var.mp.start_index + config.columns - 4 - mando.get_width(
        ) and mando.xget() <= 1090:
            mando.xset(1)

    if char == 'a':
        if mando.xget() > global_var.mp.start_index + 4:
            mando.xset(-1)

    if char == 'w':
        if mando.yget() >= 5:
            mando.yset(-1)
            mando.set_air_pos(mando.yget())
            mando.set_air_time(time())

    if char == ' ' and mando.get_shield_allow() == 1:
        mando.set_shield_allow(0)
        mando.set_shield_time(time())
        mando.set_shield(1)

    if char == 'e':
        bullet = objects.Bullet(config.bullet,
                                mando.xget() + 4,
                                mando.yget() + 1)
        bullet.render()
        global_var.bullets.append(bullet)

    if char == 'q':
        message = "Y U Quit :'("
        global_funct.display_ending(message)
        quit()
示例#4
0
from time import time, sleep
import signal
from getch import KBHit
from global_var import mando, dragon, bullets, dragon_bullets
from global_funct import remove_shield, allow_shield, move_board_back, check_speedup_time, move_with_magnet
import inputs

global_funct.initialize_board()

while True:

    global_var.TIME_REM = global_var.TIME_TOTAL - round(
        time()) + global_var.TIME_BEGUN
    if global_var.TIME_REM == 0:
        message = "Time over!"
        global_funct.display_ending(message)
        break

    remove_shield()
    allow_shield()
    check_speedup_time()
    mando.clear()

    inputs.movedin()
    mando.check_collision()

    global_funct.gravity(mando)
    global_funct.move_bullets(bullets)

    global_var.mp.magnet_check(global_var.magnets)
示例#5
0
    def check_collision(self):

        for i in range(self._width):
            for j in range(self._height):
                
                if j+self._posy >= 50:
                    continue
            
                if global_var.mp.matrix[j+self._posy][i+self._posx] == "$":
                    self.__coins += 1
                    self.__score += 1
                    global_var.mp.matrix[j+self._posy][i+self._posx] = " "

                if global_var.mp.matrix[j+self._posy][i+self._posx] == "D":
                    self.__dragon_flag = 1
                    global_funct.clear_boost(self._posx + i, self._posy+j)
                    self.change_shape()
                    global_var.dg_power_up[0].clear()


                elif global_var.mp.matrix[j+self._posy][i+self._posx] == "#" or global_var.mp.matrix[j+self._posy][i+self._posx] == "M" or global_var.mp.matrix[j+self._posy][i+self._posx] == "o": 
                    if self.__shield == 1:
                        if global_var.mp.matrix[j+self._posy][i+self._posx] == "#":
                            global_funct.clear_beam(self._posx + i, self._posy+j)

                        if global_var.mp.matrix[j+self._posy][i+self._posx] == "M":
                            global_funct.clear_magnet(self._posx + i, self._posy+j)

                        self.__score += 5

                    elif self.__dragon_flag ==1:
                        self._posy = 5
                        self.__dragon_flag = 0
                        self.change_shape()
                        return

                    elif self.__lives > 1:
                        self.__lives -= 1

                        if global_var.mp.start_index != 1000:
                            global_var.mp.start_index = 0
                            self._posx = 5
                            self._posy = global_var.mando_ground
                        else:
                            self._posx = global_var.mp.start_index + 5
                            return


                    else:

                        self.__lives -= 1
                        message = "Oops, you lost!"
                        global_funct.display_ending(message)
                        quit()                
                    return

                elif global_var.mp.matrix[j+self._posy][i+self._posx] == "B":
                    global_funct.clear_boost(self._posx, self._posy)
                    global_var.mp.set_speedup_time(time())
                    global_var.mp.set_speedup_flag(1)
                    global_var.mp.set_speed(global_var.BOARD_SPEED_FAST)
                    global_var.mp.set_bullet_speed(global_var.BULLET_SPEED_FAST)
                    global_var.mp.set_step(2)
示例#6
0
                        mando.check_right()
                        mando.check_right()
            # SHIELDED
            if (global_var.shield == 1):
                cur_time = time.time()
                if (cur_time - global_var.shield_time >= 10):
                    global_var.shield = 0
                    mando.style = create.mando
                    #cur_time=-1
                    global_var.shield_cooldown = 60
            global_var.shield_cooldown -= shifting_time
            if (global_var.shield_cooldown <= 0):
                global_var.shield_cooldown = 0
        #timing of game
        if s - time.time() + 300 <= 0:
            global_funct.display_ending("TIME OUT :(")
            break

        if global_var.lives <= 0:
            global_funct.display_ending("YOU LOST!")
            break

        if global_var.quit_flag:
            global_funct.display_ending("YOU LOST!")
            break

        event = create.get_key(create.get_input())

        cnt = 0

        cnt2 = 0
            if(c==1):
                sblist[i].clear()
                sblist.remove(sblist[i])
                del(sblist[i])
            c = hlist[i].check_bullet()  
            if(c==1):
                hlist[i].clear()
                hlist.remove(hlist[i])
                del(hlist[i])
            c = mags[i].check_bullet()  
            if(c==1):
                mags[i].clear()
                mags.remove(mags[i])
                del(mags[i])
        if din.get_lives() <= 0:
            global_funct.display_ending("YOU LOST!")
            break
        global_var.n = global_var.n-1   #decreasing timer
        #checking for collision
        for i in range(5):

            # mags[i].
            # hlist
            c = vblist[i].check_bullet()  
            if(c==1):
                vblist.remove(vblist[i])
                del(vblist[i])
            # sblist
        #din.collected_powerups()
        if(time.time()-sh > 10):
            # print("deactivating shield")
示例#8
0
    mario = people.Person(config.mario, int(config.columns/2), global_var.scenery.ground_level-len(config.mario))
    # mario.posx = 1035
    # global_var.scenery.scene_start_index = 1030
    mario.render()

    # Generate enemies
    global_funct.generate_enemies()

    global_var.scenery.render()
    global_funct.create_footer()
    os.system('aplay newstart.wav&')

    while True:

        if global_var.lives <= 0:
            global_funct.display_ending("YOU LOST!")
            break

        if global_var.quit_flag:
            global_funct.display_ending("YOU LOST!")
            break

        global_funct.run_background(mario)

        mario.gravity() 

        global_funct.check_enemies(mario)

        event = config.get_key(config.get_input())

        if event == config.QUIT: