浏览代码

Using the new scenes as well as some data for loading in walls for the game map.

master
Bryan Miller 6 年前
父节点
当前提交
73e3b7d790
共有 2 个文件被更改,包括 77 次插入22 次删除
  1. +53
    -0
      data/json/walls.json
  2. +24
    -22
      game/__init__.py

+ 53
- 0
data/json/walls.json 查看文件

@@ -0,0 +1,53 @@
{
"src":"maptiles/Walls.png",
"walls":[
{
"name":"Bricks",
"f_close":[0,0,48,48],
"f_mid":[48,0,32,32],
"f_far":[48,32,16,16],
"s_close":[0,48,8,64],
"s_mid":[8,48,8,64],
"s_far":[16,48,9,64]
},
{
"name":"Wood",
"f_close":[80,0,48,48],
"f_mid":[128,0,32,32],
"f_far":[128,32,16,16],
"s_close":[80,48,8,64],
"s_mid":[88,48,8,64],
"s_far":[96,48,9,64]
},
{
"name":"Daub",
"f_close":[160,0,48,48],
"f_mid":[208,0,32,32],
"f_far":[208,32,16,16],
"s_close":[160,48,8,64],
"s_mid":[168,48,8,64],
"s_far":[176,48,9,64]
}
],
"doors":[
{
"name":"Wood Framed",
"open":{
"f_close":[0,112,48,48],
"f_mid":[48,112,32,32],
"f_far":[48,144,16,16],
"s_close":[0,48,8,64],
"s_mid":[8,48,8,64],
"s_far":[16,48,9,64]
},
"closed":{
"f_close":[80,112,48,48],
"f_mid":[128,112,32,32],
"f_far":[128,144,16,16],
"s_close":[80,160,8,64],
"s_mid":[88,160,8,64],
"s_far":[96,160,9,64]
}
}
]
}

+ 24
- 22
game/__init__.py 查看文件

@@ -1,5 +1,6 @@
from . import gbe
from .nodes import *
from . import scenes

_RUNNING = False

@@ -31,36 +32,37 @@ def start():
sm = gbe.statemachine.StateMachine()

gbe.events.Events.listen("QUIT", _OnQuit)
gbe.events.Events.listen("KEYDOWN", _OnKeyEvent)
gbe.events.Events.listen("KEYUP", _OnKeyEvent)
gbe.events.Events.listen("KEYPRESSED", _OnKeyEvent)
#gbe.events.Events.listen("KEYDOWN", _OnKeyEvent)
#gbe.events.Events.listen("KEYUP", _OnKeyEvent)
#gbe.events.Events.listen("KEYPRESSED", _OnKeyEvent)
d = gbe.display.Display
d.init(640, 480)
d.caption = "Goldbox 64"
d.watch_for_resize(True)
d.set_clear_color(0,0,255)
d.set_clear_color(0,0,0)

root = NodeInterface()
root.scale_to_display = True
root.keep_aspect_ratio = True
root.align_center = True
root.set_surface((64, 64))
#root = NodeInterface()
#root.scale_to_display = True
#root.keep_aspect_ratio = True
#root.align_center = True
#root.set_surface((64, 64))

sprite = gbe.nodes.NodeSprite("Sprite", root)
sprite.image = "maptiles/Walls.png"
sprite.rect = (48, 32, 16, 16)
sprite.position = (20, 20)
#sprite = gbe.nodes.NodeSprite("Sprite", root)
#sprite.image = "maptiles/Walls.png"
#sprite.rect = (48, 32, 16, 16)
#sprite.position = (20, 20)

text = gbe.nodes.NodeText("TextNode", root)
text.font_src = "IttyBitty.ttf"
text.size = 4
text.antialias = False
text.text = "ObsidianBlk 123456"
text.set_color(255, 64, 128)
text.position_y = 30
#text = gbe.nodes.NodeText("TextNode", root)
#text.font_src = "IttyBitty.ttf"
#text.size = 4
#text.antialias = False
#text.text = "ObsidianBlk 123456"
#text.set_color(255, 64, 128)
#text.position_y = 30

sm.register_node(root)
sm.activate_node(root.name)
e = scenes.editor.get()
sm.register_node(e)
sm.activate_node(e.name)

_RUNNING = True
while _RUNNING:

正在加载...
取消
保存