Ejemplo 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)
    unit_img_u = vgame.Image(p[1], rate=150, showsize=(60,60))
Ejemplo 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)
Ejemplo 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

vgame.DEBUG = True
vgame.Camera.DEBUG = True

vgame.Initer()
main = vgame.Theater(size=(1024, 640))

player = vgame.Player().local(main,
                              (80, 600)).follow(main,
                                                .05)  # 在没有超过边界时,窗口会平滑居中移动
wall = vgame.Wall(showsize=(500, 10)).local(main, (400, 300))
player.direction = lambda self, d: self.mover.move(d.get('p1'), 10)
player.mouse = lambda self, m: self.clicker.dnd(m)  # 设置a对象可以被鼠标左键拖动

player.bound = lambda self, b: print(self, b)
player.click = lambda self: print(123)
player.mouseover = lambda self: print('over')
player.mouseout = lambda self: print('out')
Ejemplo n.º 5
0
Attack      = Attack.gridcut((Attack.size[0]/14, 128))
Dash        = vgame.ImageMaker(pathA + '/spr_ArcherDash_strip_NoBkg.png')
Dash        = Dash.gridcut((Dash.size[0]/14, 128))
Death       = vgame.ImageMaker(pathA + '/spr_ArcherDeath_strip_NoBkg.png')
Death       = Death.gridcut((Death.size[0]/24, 128))
Idle        = vgame.ImageMaker(pathA + '/spr_ArcherIdle_strip_NoBkg.png')
Idle        = Idle.gridcut((Idle.size[0]/8, 128))
JumpAndFall = vgame.ImageMaker(pathA + '/spr_ArcherJumpAndFall_strip_NoBkg.png')
JumpAndFall = JumpAndFall.gridcut((JumpAndFall.size[0]/12, 128))
Melee       = vgame.ImageMaker(pathA + '/spr_ArcherMelee_strip_NoBkg.png')
Melee       = Melee.gridcut((Melee.size[0]/28, 128))
Run         = vgame.ImageMaker(pathA + '/spr_ArcherRun_strip_NoBkg.png')
Run         = Run.gridcut((Run.size[0]/8, 128))

vgame.Initer()
main = vgame.Theater(size=(980,640))
show_Attack      = vgame.Anime(Attack,     rectsize=(30,40), rate=60, offsets=(-30,-5)).local(main, offsets=(100,-200))
show_Dash        = vgame.Anime(Dash,       rectsize=(30,40), rate=60, offsets=(0,-5)).local(main, offsets=(100,-150))
show_Death       = vgame.Anime(Death,      rectsize=(30,40), rate=60, offsets=(0,-5)).local(main, offsets=(100,-100))
show_Idle        = vgame.Anime(Idle,       rectsize=(30,40), rate=60, offsets=(0,-5)).local(main, offsets=(100,-50))
show_JumpAndFall = vgame.Anime(JumpAndFall,rectsize=(30,40), rate=60, offsets=(0,-5)).local(main, offsets=(100,0))
show_Melee       = vgame.Anime(Melee,      rectsize=(30,40), rate=60, offsets=(0,-5)).local(main, offsets=(100,50))
show_Run         = vgame.Anime(Run,        rectsize=(30,40), rate=60, offsets=(0,-5)).local(main, offsets=(100,100))

Idle_r = vgame.Image(Idle, rate=60, offsets=(0,-5))
Idle_l = vgame.Image(Idle, rate=60, offsets=(0,-5), flip='x')
player = vgame.Player(Idle_r, rectsize=(30,40)).local(main).follow(main, .1)
player.status['direction']['right'] = Idle_r
player.status['direction']['left'] = Idle_l

def direct(self, d):
Ejemplo n.º 6
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.Map.DEBUG = True

vgame.Initer()
main = vgame.Theater(size=(960, 720))
maps = vgame.Map(grid=(20, 15), showsize=main.size).local(main)
label = vgame.Anime(vgame.Text('wasd控制,j跳跃k冲刺')).local(main)

player = vgame.Player((255, 0, 0),
                      showsize=maps.gridsize).map.local(maps, (0, 14))

# 窗口大小由 Initer 配置
# 游戏内窗大小由 Theater 配置(如不配置默认随窗口大小)
# 这里让 player 作为main窗口的跟随移动进行处理,这样可以让某些动作类的游戏窗口的移动更加平滑。
player.follow(main, .05)


def direct(self, d):
    d = d.get('p1')
    if self.status['dash_toggle']:
        pass
    else:
Ejemplo n.º 7
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:
        i.kill()
Ejemplo n.º 8
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.Menu.DEBUG = True
vgame.Map.DEBUG = True

vgame.Initer()

main = vgame.Theater((0, 0, 0)).draw.rect((255, 255, 255), 5, 3)
menu = vgame.Menu(grid=(9, 9), showsize=(main.size[0] - 50,
                                         200 - 50)).local(main,
                                                          offsets=(0, 140))
player = vgame.Player(showsize=(40, 20)).menu.local(menu, (1, 1))

maps = vgame.Map(grid=(9, 9), showsize=(main.size[0] - 200,
                                        200 - 50)).local(main,
                                                         offsets=(0, -140))
vgame.Enemy(showsize=(30, 10)).map.local(maps, (3, 3), 2)
vgame.Enemy(showsize=(30, 10)).map.local(maps, (3, 4), 2)
vgame.Enemy(showsize=(30, 10)).map.local(maps, (3, 5), 2)
enemy = vgame.Enemy(showsize=(30, 10)).map.local(maps, (8, 8), 2)
player = vgame.Player(showsize=(30, 15)).map.local(maps, (4, 5), 1)