Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ttwings committed Oct 4, 2017
0 parents commit 9abec75
Show file tree
Hide file tree
Showing 881 changed files with 40,592 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

327 changes: 327 additions & 0 deletions .idea/workspace.xml

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions .idea/wxrpg.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${file}"
}
]
}
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Place your settings in this file to overwrite default and user settings.
{
// Path to the Love2D executable file
"pixelbyte.love2d.path": "D:\\Program Files\\Love\\love.exe",

// Runs Love2D with a console window for debugging. (Windows Only)
"pixelbyte.love2d.debug": false,

// Whenever a file is saved, Love2D is executed on the workspace folder
"pixelbyte.love2d.runOnSave": false
}
19 changes: 19 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"version": "1.0.0",
"command": "love",
"isShellCommand": true,
"args": [
"."
],
"tasks": [
{
"taskName": "build",
"args": [
"."
],
"problemMatcher": [
"$node-sass"
]
}
]
}
21 changes: 21 additions & 0 deletions Actor.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require "lib/middleclass"
require "lib/anim8"

Actor=calss("actor")
Actor.property={}
function Actor:init(actorData)
for k, v in pairs(actorData) do
Actor.property.k=v
end
end

function Actor:move(x,y)
Actor.property.x = x
Actor.property.y = y
end

function Actor:draw()
local imagePath = "" .. Actor.property["行走图"]
local image = love.graphics.newImage()
love.graphics.draw()
end
71 changes: 71 additions & 0 deletions Date.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
date = {year=0,month=0,week=0,day=0,hour=0,minute=0,second=0,turn=0}
animals = {"","","","","","","","","","","",""}
weeks = {"上旬","中旬","下旬"}
days = {"月曜日","火曜日","水曜日","木曜日","金曜日","土曜日","日曜日"}
hours = {"","","","","","","","","","","",""}
months = {"","","","","","","","","","","",""}
numbers = {"","","","","","","","","",""}
season = {"","","",""}
weather = { "","多云","","阵雨","雷阵雨","雷阵雨伴有冰雹",
"雨夹雪","小雨","中雨","大雨","暴雨","大暴雨","特大暴雨",
"阵雪","小雪","中雪","大雪","暴雪","","冻雨","沙尘暴",
"小到中雨","中到大雨","大到暴雨","暴雨到大暴雨",
"大暴雨到特大暴雨","小到中雪","中到大雪","大到暴雪",
"浮尘","扬沙","沙尘暴","强沙尘暴","特强沙尘暴轻雾",
"浓雾强浓雾","轻微霾","轻度霾","中度霾","重度霾","特强霾","","飑线"}

font = love.graphics.newFont("assets/font/simsun.ttf", 18)
love.graphics.setFont(font)

function date:update(dt)
-- 1年 = 12 月 * 3 旬 * 7 天 * 12 时辰 * 120 分 * 60 秒 * 60 帧 = 15552000
-- 计算年月日
date.second = date.second + 100
date.new(date.second)
end

function date:draw()
-- colorText(colorstr)
local d = date
local yearStr = hours[d.year]..animals[d.year]
local monthStr = months[d.month]
local weekStr = weeks[d.week]
local dayStr = days[d.day]
local hourStr = hours[d.hour]
dateStr = string.format("%s年%s月%s%s%s时",yearStr,monthStr,weekStr,dayStr,hourStr)
love.graphics.print(dateStr,560,0)
end

--- 将数字转为文字
function replaseNumber(number)
-- local numbers = number ..""
numbers = string.gsub(number,"1", "")
numbers = string.gsub(numbers,"2", "")
numbers = string.gsub(numbers,"3", "")
numbers = string.gsub(numbers,"4", "")
numbers = string.gsub(numbers,"5", "")
numbers = string.gsub(numbers,"6", "")
numbers = string.gsub(numbers,"7", "")
numbers = string.gsub(numbers,"8", "")
numbers = string.gsub(numbers,"9", "")
numbers = string.gsub(numbers,"0", "")
return numbers
end

function date.new(second)
date.second = second
date.minute = math.modf(date.second/60)
date.hour = math.modf(date.minute/60)
date.day = math.modf(date.hour/12)
date.week = math.modf(date.day/7)
date.month = math.modf(date.week/3)
date.year = math.modf(date.month/12)
--
date.minute = math.modf(date.minute%60)+1
date.hour = math.modf(date.hour%12)+1
date.day = math.modf(date.day%7)+1
date.week = math.modf(date.week%3)+1
date.month = math.modf(date.month%12)+1
date.year = math.modf(date.year%12)+1
return date
end
153 changes: 153 additions & 0 deletions GameScreen.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
local Screen = require( "lib/Screen" )
local sti = require "sti"
local actorsdata=require "assets/data/actors"
local anim8 = require 'lib/anim8'
-- local Class = require "lib/middleclass"
require "Date"
-- 主要对象类,角色类,房间类,区域类
require "Actor"
require "Npc"
require "assets/data/actors"
require "assets/data/rooms"
require "lib/guiDraw"
require "lib/colorT"
require "lib/drawTool"
local GameScreen = {}
local map
local world
local tx, ty
local font
local canvas = love.graphics.newCanvas()
local canvasGUI = love.graphics.newCanvas()
local tx
local ty
-- shader
local code =[[
vec4 effect(vec4 color,Image texture,vec2 tc,vec2 sc){
return Texel(texture,vec2((tc.x-0.5)/(tc.y+1)+0.5,tc.y));
}
]]
shader = love.graphics.newShader(code)

-- npc table
function canvasLoad()
love.graphics.setCanvas(canvas)
love.graphics.clear()
map:draw(-tx,-ty)
map:box2d_draw(-tx,-ty)
love.graphics.setCanvas()
end

function canvasGUIload()
love.graphics.setCanvas(canvas)
love.graphics.clear()
guiDraw()
love.graphics.print("FPS:" .. love.timer.getFPS(),1220,0)
drawTile(actorImgs[1],0,0,32,48,640,400)
-- 绘制时间
-- date.draw()
love.graphics.setCanvas()
end

function loadData( )
-- actor class
actor=Actor:new(actors["段誉"])
-- actor:readData(actors["段誉"])
-- npc1 = Actor:new(actors["言达平"])
-- npc2 = Actor:new(actors["鲁坤"])
npcs:add(actors,5)
-- npc1.x = 500
-- npc1.y = 600
-- npc2.x = 800
-- npc2.y = 1000
-- npc1:readData(actors["言达平"])
-- actor.misc = {}
--
font = love.graphics.newFont("assets/font/msyh.ttf", 18)
love.graphics.setFont(font)
map = sti("assets/tileMaps/wuguan.lua",{"box2d"})
-- Prepare translations
tx, ty = 0, 0
-- Prepare physics world
love.physics.setMeter(32)
world = love.physics.newWorld(0, 0)
map:box2d_init(world)
-- Create a Custom Layer
map:addCustomLayer("Sprite Layer", 5)
-- Add data to Custom Layer
local spriteLayer = map.layers["Sprite Layer"]

spriteLayer.sprites = {
player = {}
}
-- Update callback for Custom Layer
function spriteLayer:update(dt)
local objs = map.layers[7].objects
for i=1,#objs,1 do
local objName = objs[i].name
local bx,by = objs[i].x,objs[i].y
local ax,ay = actor.x/2,actor.y/2
local distance=math.abs(bx-ax) + math.abs(by-ay)
-- print(distance)
-- print( distance )
if (distance<100) then
actor.target = objName .. ":"..bx .. ":".. by
break
else
actor.target = ""
end
end
end
--
function spriteLayer:draw()
for _, sprite in pairs(self.sprites) do
local x = math.floor(actor.x/2)
local y = math.floor(actor.y/2)
actor:drawAnim()
npcs:drawAnim()
-- npc1:drawAnim()
-- npc2:drawAnim()
-- actor:drawFly()
end
end


canvasLoad()
end


function GameScreen.new( )
local self=Screen.new()
loadData()
function self:draw()
love.graphics.setShader(shader)
love.graphics.draw(canvas)
love.graphics.setShader()
-- GUI
guiDraw()
-- actor:draw()
-- actor:drawBag()
love.graphics.print("FPS:" .. love.timer.getFPS(),1220,0)
date.draw()
end

function self:update( dt )
world:update(dt)
map:update(dt)
actor:key(dt)
actor:update(dt)
-- npc1:update(dt)
npcs:update(dt)
-- 地图的位移
tx = math.floor((actor.x - 1280)/ 2)
ty = math.floor((actor.y - 800)/ 2)
-- 画布
canvasLoad()
guiUpdata(actor,dt)
date.update()
end
return self
end


return GameScreen
40 changes: 40 additions & 0 deletions HelpScreen.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
local Screen = require( "lib/Screen" )
local HelpScreen = {}
local bg = love.graphics.newImage("bg.jpeg")
local font = love.graphics.newFont("assets/font/msyh.ttf", 24)
local titlefont = love.graphics.newFont("assets/font/msyh.ttf", 48)
local menu ={}
local index = 1
function HelpScreen.new( )
love.graphics.setFont(font)
local self=Screen.new()
-- local x,y,w,h = 20,20,40,20
title = love.graphics.newText(titlefont,"侠客宝典")


function self:draw( )
love.graphics.draw(bg, 0, 0, 0)
love.graphics.setColor(0, 0, 0, 255)
love.graphics.draw(title, 300, 40)
love.graphics.setColor(255,255,255, 255)

end

function self:update( dt )

end

function self:keypressed(key)
if key=="e" and index>1 then
index = index -1
elseif key=="d" and index<4 then
index = index + 1
elseif key=="j" or "k" then
print(key)
end
end
return self
end


return HelpScreen
26 changes: 26 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Simple Tiled Implementation

This code is licensed under the [**MIT/X11 Open Source License**][MIT].

Copyright (c) 2014 Landon Manning - [email protected] - [LandonManning.com][LM]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

[MIT]: http://www.opensource.org/licenses/mit-license.html
[LM]: http://LandonManning.com
Loading

0 comments on commit 9abec75

Please sign in to comment.