Exemplo n.º 1
0
# 增加环境变量,仅测试使用
import os
import sys
p = os.path.split(os.getcwd())[0]
sys.path = [p] + sys.path
import sys;print(sys.stdout.encoding)



import vgame

vgame.DEBUG = True
# vgame.Player.DEBUG = True
vgame.Map.DEBUG = True

init = vgame.Initer()
main = vgame.Theater()



hywz1 = '../test_data/hywz/1.png'
hywz2 = '../test_data/hywz/2.png'
hywz3 = '../test_data/hywz/3.png'

def load_images(imgpath, Class, map, local, speed):
    imake = vgame.ImageMaker(imgpath)
    s = imake.gridcut((64, 64))
    p = []
    for i in range(int(len(s)/3)):
        v = s[i*3:(i+1)*3]
        p.append(v)
Exemplo n.º 2
0
# 增加环境变量,仅测试使用
import os
import sys
p = os.path.split(os.getcwd())[0]
sys.path = [p] + sys.path
import sys
print(sys.stdout.encoding)

import vgame
import random
import time
s = vgame.Initer()
t = vgame.Theater()
f = vgame.font.SysFont("simhei", 15)
bullets = []


def direct_a(self, d):
    self.mover.move(d.get('p1'))


d = {}
d['starttime'] = time.time()
currtime = lambda: time.time() - d['starttime']
currlens = lambda: len(bullets)
n = vgame.Actor(f.render('游戏时间:{:.5f}'.format(currtime()), 3, (255, 255, 255)),
                in_entity=False)
l = vgame.Actor(f.render('当前数量:{}'.format(currlens()), 3, (255, 255, 255)),
                in_entity=False)
n.rect.x, n.rect.y, l.rect.x, l.rect.y = 200, 0, 200, 18
a = vgame.Actor(showsize=(20, 20), in_control=True)
# 增加环境变量,仅测试使用
import os
import sys
p = os.path.split(os.getcwd())[0]
sys.path = [p] + sys.path
import sys
print(sys.stdout.encoding)

import vgame
vgame.DEBUG = True

path = '../test_data/fjdz/image'

vgame.Initer(size=(240, 480))
main = vgame.Theater(path + '/background.png', (640, 480))
print(main.size)
player_imgs = [
    path + '/hero1.png',
    path + '/hero2.png',
]
player = vgame.Player(player_imgs, rate=200,
                      showsize=(50, 62)).local(main,
                                               (120, 400)).follow(main, .05)
player.direction = lambda self, d: self.mover.move(d.get('p1'), 6)


def control(self, c):
    if self.delay(c and c.get('p1')[0], time=50, repeat=True): create_bullet()
    if self.delay(c and c.get('p1')[1], time=50, repeat=True):
        for idx, i in enumerate(main.Bullet):
            print(idx, i)
Exemplo n.º 4
0
# 增加环境变量,仅测试使用
import os
import sys
p = os.path.split(os.getcwd())[0]
sys.path = [p] + sys.path
import sys
print(sys.stdout.encoding)

import vgame
import random

# vgame.DEBUG = True
# vgame.Map.DEBUG = True
path = '../test_data/fjdz/image'

vgame.Initer(size=(240, 430))
main = vgame.Theater(path + '/background.png', size=(340, 530))
pause = vgame.Theater(path + '/background.png', size=(340, 530))
death = vgame.Theater(path + '/background.png', size=(340, 530))
unpause = vgame.Button(vgame.Text('暂停')).local(pause,
                                               pause.background.rect.center)
restart = vgame.Button(vgame.Text('重开')).local(death,
                                               death.background.rect.center)

unpause.click = lambda: vgame.change_theater(main)
unpause.control = lambda self, c: unpause.click() if self.delay(c and c.get(
    'p1')[1]) else None


def _restart():
    for i in main.Enemy: