Example #1
0
def on_button_callback3():
    global current_script, speed, score, move_lock_flag
    game.game_start()
    game.set_background([4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1])
    while True:
        index = random.randint(0, sprite_num - 1)
        current_script = sprite_create(sprites[index])
        game.add_sprite(current_script)
        if game.background_collision_check(current_script):
            game.del_sprite(current_script)
            current_script = None
            codey.say("wrong")
            game.game_over()
            codey.show(score)
            score = 0
            break
        count = 1
        speed = 10
        while True:
            if count % speed == 0:
                background_control()
                line_remove_process()
            if move_control():
                break
            speed_control()
            time.sleep(0.05)
            count += 1
        time.sleep(0.1)
        game.set_background(game.get_screen())
        current_script.hide()
        time.sleep(0.1)
        game.del_sprite(current_script)
        move_lock_flag = False
Example #2
0
def on_button_callback3():
    global current_script, down_speed, score, move_lock_flag
    game.game_start()
    game.set_background([0] * 16)
    while True:
        index = random.randint(0, sprite_num - 1)
        current_script = sprite_create(sprites[index])
        game.add_sprite(current_script)
        if game.background_collision_check(current_script):
            game.del_sprite(current_script)
            current_script = None
            codey.say("wrong")
            game.game_over()
            codey.show(score)
            score = 0
            break
        count = 1
        down_speed = 10
        while True:
            if count % down_speed == 0:
                current_script.right()
            
            if current_script.meet_border_check() == RIGHT_MEET:
                move_lock_flag = True
                current_script.left()
                codey.say("score")
                break

            if game.background_collision_check(current_script):
                move_lock_flag = True
                current_script.left()
                codey.say("score")
                break

            move_control()

            time.sleep(0.02)
            count += 1
        time.sleep(0.1)
        game.set_background(game.get_screen())
        current_script.hide()
        time.sleep(0.1)
        line_remove_process()
        game.del_sprite(current_script)
        move_lock_flag = False
Example #3
0
from game import game_base
from game import sprite_create
import codey
import time
import random

game = game_base()
game.game_start()
b = sprite_create("00000080808080000000000000000000")
a = sprite_create("00000000000000000000000000303000")
game.add_sprite(b)
game.add_sprite(a)

cur_direc = 1  # 1: right-up 2: right-down 3: left-up 4: left-down
last_direc = 1
speed = 1
b.up()


def on_button_callback():
    global cur_direc, last_direc
    b.left()


codey.on_button('A', on_button_callback)


def on_button_callback1():
    global cur_direc, last_direc
    b.right()
Example #4
0
def main():
    global game_status, score, plane_id, plane, music_name, bullet, music_id
    count = 0

    while True:
        if game_status == 0:
            if plane_id == 0:
                codey.face(plane_s)
            elif plane_id == 1:
                codey.face(plane_s1)
            else:
                codey.face(plane_s2)

            if codey.is_button("C"):
                codey.say("start")
                game_status = 1
                score = 0
                if plane_id == 0:
                    plane = sprite_create(plane_s)
                elif plane_id == 1:
                    plane = sprite_create(plane_s1)
                else:
                    plane = sprite_create(plane_s2)

                bullet = sprite_create(bullet_s)
                game.add_sprite(plane)
                bullet.hide()
                game.add_sprite(bullet)

                game.game_start()
                time.sleep(1)
            elif codey.is_button("A"):
                plane_id += 1
                if plane_id > 2:
                    plane_id = 0
                while codey.is_button("A"):
                    pass
            elif codey.is_button("B"):
                music_id += 1
                if music_id > 2:
                    music_id = 0

                if music_id == 0:
                    music_name = "shot"
                elif music_id == 1:
                    music_name = "laser"
                elif music_id == 2:
                    music_name = "score"
                codey.say(music_name)
                while codey.is_button("B"):
                    pass

        elif game_status == 1:
            if count % 3 == 0:
                plane_move_control()

            bullet_move_control()

            if count % (codey.dail() // 6) == 0:
                background_control()
            if game.background_collision_check(plane):
                codey.say('wrong')
                game_status = 2
                game.set_background("00000000000000000000000000000000")
                game.sprite_list_clean()

                palne = None
                bullet = None
                game.game_over()
            time.sleep(0.02)
        else:
            codey.show(score)
            if codey.is_button("C"):
                game_status = 0
            time.sleep(0.1)
        count += 1
Example #5
0
from game import game_base
from game import sprite_create
from game import *
import codey
import time
import random

score = 0
game = game_base()
bg_s = '81818181818181818181818181818181'
a_s = '10101010000000000000000000000000'
c_s = '00000000000000000000000000030000'
p_s = "40000000000000000000000000000000"

a = sprite_create(a_s)
b = sprite_create(a_s)
c = sprite_create(c_s)
p = sprite_create(p_s)

game.add_sprite(a)
game.add_sprite(b)
game.add_sprite(c)
game.add_sprite(p)
a.right(1)
b.right(8)
#c.hide()

game.game_start()
game.set_background(bg_s)

down_flag = False
Example #6
0
from game import game_base
from game import sprite_create
from game import *
import codey
import time
import random

score = 0
game = game_base()
p_s = "80000000000000000000000000000000"
bg_s = "00000000000000000000000000000000"
p = sprite_create(p_s)
game.add_sprite(p)

game.game_start()
game.set_background(bg_s)


def move_control():
    if codey.get_variable('cmd') == 1:
        p.up()
        codey.set_variable('cmd', 0)
    elif codey.get_variable('cmd') == 2:
        p.down()
        codey.set_variable('cmd', 0)
    elif codey.get_variable('cmd') == 3:
        p.left()
        codey.set_variable('cmd', 0)
    elif codey.get_variable('cmd') == 4:
        p.right()
        codey.set_variable('cmd', 0)
Example #7
0
from game import *
import codey
import time
import random

game = game_base()
game.game_start()

a_s = '10101010000000000000000000000000'
b_s = '10380000000000000000000000000000'
c_s = '30300000000000000000000000000000'
d_s = '10180800000000000000000000000000'
e_s = '30101000000000000000000000000000'
f_s = '08181000000000000000000000000000'

current_sprite = sprite_create(b_s)
game.add_sprite(current_sprite)


def on_button_callback1():
    while True:
        if codey.is_button('A'):
            current_sprite.left()
            while codey.is_button('A'):
                time.sleep(0.1)
        elif codey.is_button('B'):
            current_sprite.right()
            while codey.is_button('B'):
                time.sleep(0.1)
        elif codey.is_button('C'):
            current_sprite.rotate()
Example #8
0
def main():
    global game_status, score, plane_id, plane, music_name, bullet, music_id
    count = 0

    while True:
        # 开机选择飞机造型及音效
        if game_status == 0:
            if plane_id == 0:
                codey.face(plane_s)
            elif plane_id == 1:
                codey.face(plane_s1)
            else:
                codey.face(plane_s2)
            # 开始游戏
            if codey.is_button("C"):
                codey.say("start")
                game_status = 1
                score = 0

                # 创建角色
                if plane_id == 0:
                    plane = sprite_create(plane_s)
                elif plane_id == 1:
                    plane = sprite_create(plane_s1)
                else:
                    plane = sprite_create(plane_s2)

                bullet = sprite_create(bullet_s)
                game.add_sprite(plane)
                bullet.hide()
                game.add_sprite(bullet)
                
                # 游戏开始
                game.game_start()
                time.sleep(1)
            # 选择飞机
            elif codey.is_button("A"):
                plane_id += 1
                if plane_id > 2:
                    plane_id = 0
                while codey.is_button("A"):
                    pass
            # 选择音效
            elif codey.is_button("B"):
                music_id += 1
                if music_id > 2:
                    music_id = 0

                if music_id == 0:
                    music_name = "shot"
                elif music_id == 1:
                    music_name = "laser"
                elif music_id == 2:
                    music_name = "score"
                codey.say(music_name)
                while codey.is_button("B"):
                    pass
        # 游戏运行控制
        elif game_status == 1:
            # 调整数字可以调整移动灵敏度
            if count % 3 == 0:
                plane_move_control()
            # 子弹移动控制
            bullet_move_control()
            
            #障碍物移动控制, 速度随电位器变化而变化
            if count % (codey.dail() // 6) == 0:
                background_control()

            # 飞机是否撞到障碍物检测
            if game.background_collision_check(plane):
                codey.say('wrong')
                game_status = 2
                game.set_background("00000000000000000000000000000000")
                game.sprite_list_clean()

                palne = None
                bullet = None
                game.game_over()
            time.sleep(0.02)
        else:
            # 游戏结束, 显示分数, 并等待C键按下, 重新开始游戏
            codey.show(score)
            if codey.is_button("C"):
                game_status = 0
            time.sleep(0.1)
        count += 1
Example #9
0
from game import game_base
from game import sprite_create
from game import *
import codey
import time
import random

game = game_base()
# 两个角色 为两个小点
l_s = '00000000000000200000000000000000'
r_s = '00000000000000002000000000000000'
#背景图案
b_s = '0000000000ff00000000ff0000000000'

left_h = sprite_create(l_s)
game.add_sprite(left_h)
right_h = sprite_create(r_s)
game.add_sprite(right_h)

game.set_background(b_s)
game.game_start()

move_lock_flag = False
speed = 10
score = 0

bg_change_count = 0


# 速度控制
def speed_control():