diff --git a/Actor.lua b/Actor.lua index 567285b..8feabf9 100644 --- a/Actor.lua +++ b/Actor.lua @@ -2,6 +2,11 @@ Class=require "lib/middleclass" anim8=require "lib/anim8" require "assets/data/actors" require "assets/data/mapWuGuan" +require("bullets") +require("lib.messages") +---- test bullet +bullet={} +message={} Actor=Class("actor") Actor["actorMsg"]={} -- fly Msg @@ -101,35 +106,47 @@ function Actor:drawBag() end --------------------------- 键盘控制 ------------------------ -cd=10 +cd=0 function Actor:key(dt) speed = 600 - cd=cd-dt + --cd=cd-dt if love.keyboard.isDown("f") then self.x = self.x + dt*speed self.animNow=self.anim.moveRight + self.r = 0 elseif love.keyboard.isDown("s") then self.x = self.x - dt*speed self.animNow=self.anim.moveLeft + self.r = 3.1415 end if love.keyboard.isDown("d") then self.y = self.y + dt*speed self.animNow=self.anim.moveDown + self.r = 3.1415/2 elseif love.keyboard.isDown("e") then self.y = self.y - dt*speed self.animNow=self.anim.moveUp + self.r = 3.1415*1.5 end -- if love.keyboard.isDown("j") then -- end - if love.keyboard.isDown("k") then + local bullet = {x=self.x/2,y=self.y/2,x0=self.x/2,y0=self.y/2,w=4,h=4,r=self.r or 0,color={255,0,0,100},range=100,speed=1000,cd=0.5} + local message = {text="暴击",x=self.x/2,y=self.y/2,x0=self.x/2,y0=self.y/2,w=4,h=4,r=self.r or 0,color={255,255,0,255},range=100,speed=100,cd=0.5} + cd = cd + dt + local text = string.format("%s%s%s%s%s",bullet.x/2,bullet.y/2,bullet.x0/2,bullet.y0/2,#bullets) + if love.keyboard.isDown("k") and cd > message.cd then -- table.insert(self.actorMsg,self["名称"] .. "测试信息") -- fly msg test - local msg={x=self.x,y=self.y,text="测试信息111",cd=3} - table.insert(flyMsgs,msg) + --local msg={x=self.x,y=self.y,text="测试信息111",cd=3} + --table.insert(flyMsgs,msg) + bullets.add(bullet) + messages.add(message) + --print(text) + cd = 0 end end @@ -147,22 +164,23 @@ function Actor:keypressed(key) end end end - +-------------- 总体功能 ------------------------- function Actor:draw() - -- for i,v in pairs(actorMsg) do - -- love.graphics.print(v,400,400+20*i) - -- end - Actor:drawMsg() - Actor:drawBag() - Actor:drawFly() + --Actor:drawMsg() + --Actor:drawBag() + --Actor:drawFly() + bullets.draw() + messages.draw() end function Actor:update(dt) -- self:key(dt) self:atRoom() self["animNow"]:update(dt) + bullets.update(dt) + messages.update(dt) end --- -- 更新角色的位置 +------------------ 更新角色的位置 -------------- function Actor:atRoom() local rx,ry rx = math.modf(self.x/256)+1 or 1 @@ -171,21 +189,8 @@ function Actor:atRoom() self.room=mapWuGuan[ry][rx] end end --- 绘制飞行文字 -function Actor:addFlyMsg(msg) - -- body - flyMsg.x= msg.x - flyMsg.y = msg.y - flyMsg.text = msg.text - flyMsg.cd = msg.cd -end -function Actor:drawFly() - for i,v in ipairs(flyMsgs) do - love.graphics.print(v.text, v.x, v.y) - end -end --- 行走图文件 +------------------ 行走图文件 -------------------- function Actor:image(name) local path = "assets/graphics/Characters/" self.image=love.graphics.newImage(path .. name) @@ -195,12 +200,7 @@ end function Actor:anims() local image = self.image - -- skillImg = love.graphics.newImage("assets/graphics/Animations/Attack2.png") - -- local skillG = anim8.newGrid(192,192,skillImg:getWidth(),skillImg:getHeight()) local g = anim8.newGrid(32,48,image:getWidth(),image:getHeight()) - -- animation = anim8.newAnimation(g('1-4',2),0.2) - -- skillAnim = anim8.newAnimation(skillG('1-5',1),0.2) - self["anim"]["moveDown"] = anim8.newAnimation(g('1-4',1),0.3) self["anim"]["moveLeft"] = anim8.newAnimation(g('1-4',2),0.3) self["anim"]["moveRight"] = anim8.newAnimation(g('1-4',3),0.3) @@ -210,11 +210,11 @@ end function Actor:drawAnim() self["animNow"]:draw(self.image,self.x/2,self.y/2) end --- 获得物品 +--------------------------- 获得物品 --------------------------- local cd function getObj() if self.target~=nil then table.insert( self.misc,self.target) print( #self.misc .. ":"..self.misc[#self.misc] ) end -end \ No newline at end of file +end diff --git a/Date.lua b/Date.lua index e9518e8..5a6d6ee 100644 --- a/Date.lua +++ b/Date.lua @@ -6,15 +6,15 @@ hours = {"子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥 months = {"正","二","三","四","五","六","七","八","九","十","冬","腊"} numbers = {"〇","一","二","三","四","五","六","七","八","九"} season = {"春","夏","秋","冬"} -weather = { "晴","多云","阴","阵雨","雷阵雨","雷阵雨伴有冰雹", - "雨夹雪","小雨","中雨","大雨","暴雨","大暴雨","特大暴雨", - "阵雪","小雪","中雪","大雪","暴雪","雾","冻雨","沙尘暴", - "小到中雨","中到大雨","大到暴雨","暴雨到大暴雨", - "大暴雨到特大暴雨","小到中雪","中到大雪","大到暴雪", - "浮尘","扬沙","沙尘暴","强沙尘暴","特强沙尘暴轻雾", - "浓雾强浓雾","轻微霾","轻度霾","中度霾","重度霾","特强霾","霰","飑线"} +--weather = { "晴","多云","阴","阵雨","雷阵雨","雷阵雨伴有冰雹", +-- "雨夹雪","小雨","中雨","大雨","暴雨","大暴雨","特大暴雨", +-- "阵雪","小雪","中雪","大雪","暴雪","雾","冻雨","沙尘暴", +-- "小到中雨","中到大雨","大到暴雨","暴雨到大暴雨", +-- "大暴雨到特大暴雨","小到中雪","中到大雪","大到暴雪", +-- "浮尘","扬沙","沙尘暴","强沙尘暴","特强沙尘暴轻雾", +-- "浓雾强浓雾","轻微霾","轻度霾","中度霾","重度霾","特强霾","霰","飑线"} -font = love.graphics.newFont("assets/font/simsun.ttf", 18) +font = love.graphics.newFont("assets/font/myfont.ttf", 20) love.graphics.setFont(font) function date:update(dt) @@ -25,7 +25,6 @@ function date:update(dt) end function date:draw() - -- colorText(colorstr) local d = date local yearStr = hours[d.year]..animals[d.year] local monthStr = months[d.month] @@ -37,6 +36,7 @@ function date:draw() end --- 将数字转为文字 +---@return string function replaseNumber(number) -- local numbers = number .."" numbers = string.gsub(number,"1", "一") @@ -52,6 +52,9 @@ function replaseNumber(number) return numbers end +---new +---@param second number 回合数 +---@return table date 日期 function date.new(second) date.second = second date.minute = math.modf(date.second/60) @@ -60,7 +63,7 @@ function date.new(second) 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 diff --git a/GameScreen.lua b/GameScreen.lua index 57bdb24..61efc77 100644 --- a/GameScreen.lua +++ b/GameScreen.lua @@ -2,16 +2,14 @@ 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 @@ -50,20 +48,10 @@ function canvasGUIload() end function loadData( ) - -- actor class + -- 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) + local font = love.graphics.newFont("assets/font/myfont.ttf", 20) love.graphics.setFont(font) map = sti("assets/tileMaps/wuguan.lua",{"box2d"}) -- Prepare translations @@ -88,8 +76,6 @@ function loadData( ) 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 @@ -101,21 +87,14 @@ function loadData( ) -- 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() + actor:draw() + --npcs:drawAnim() end end - - canvasLoad() end - function GameScreen.new( ) local self=Screen.new() loadData() @@ -125,8 +104,6 @@ function GameScreen.new( ) love.graphics.setShader() -- GUI guiDraw() - -- actor:draw() - -- actor:drawBag() love.graphics.print("FPS:" .. love.timer.getFPS(),1220,0) date.draw() end @@ -136,8 +113,7 @@ function GameScreen.new( ) map:update(dt) actor:key(dt) actor:update(dt) - -- npc1:update(dt) - npcs:update(dt) + --npcs:update(dt) -- 地图的位移 tx = math.floor((actor.x - 1280)/ 2) ty = math.floor((actor.y - 800)/ 2) @@ -149,5 +125,4 @@ function GameScreen.new( ) return self end - return GameScreen \ No newline at end of file diff --git a/MainScreen.lua b/MainScreen.lua index 9318e7d..63ace77 100644 --- a/MainScreen.lua +++ b/MainScreen.lua @@ -3,8 +3,8 @@ local ScreenManager = require("lib/ScreenManager") local snow = require( "Snow" ) local MainScreen = {} 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 font = love.graphics.newFont("assets/font/myfont.ttf", 32) +local titlefont = love.graphics.newFont("assets/font/myfont.ttf", 56) local menu = {} local index = 1 function MainScreen.new( ) diff --git a/Snow.lua b/Snow.lua index d4f1de4..d8fff8c 100644 --- a/Snow.lua +++ b/Snow.lua @@ -1,3 +1,4 @@ +----------------- 下雪动画 ---------------- local snow={} local circles={} function snow.init(n) @@ -15,7 +16,6 @@ end function snow.draw() for i,v in ipairs(circles) do - -- v=circles[i] love.graphics.setColor(v.color) love.graphics.circle("fill",v.x,v.y,v.r-1) love.graphics.circle("fill",v.x,v.y,v.r-2) diff --git a/ani.lua b/ani.lua new file mode 100644 index 0000000..a07e84c --- /dev/null +++ b/ani.lua @@ -0,0 +1,27 @@ +require "lib/animation" +-- ani 动画测试 +ani = {} + +ani.init = function (img,w,h,dur) + local w,h,sw,sh,dur,offx,offy + w = w or 192 + h = h or 192 + dur = dur or 0.05 + local path = "assets/graphics/Animations/"..img..".png" + local img = love.graphics.newImage(path) + sw,sh = img:getDimensions() + ani.animation = love.graphics.newAnimation(img,1,1,w,h,0,0,sw,sh,dur) + -- ani.animation.mode = 1 +end + + +ani.update = function (dt) + ani.animation:update(dt) +end + +ani.draw = function (x,y,r,sx,sy,offx,offy) + local x,y + x = ani.animation.x or 400 + y = ani.animation.y or 300 + ani.animation:draw(x,y,r,sx,sy,offx,offy) +end diff --git a/assets/font/myfont.ttf b/assets/font/myfont.ttf index ece2ac2..afe13f4 100644 Binary files a/assets/font/myfont.ttf and b/assets/font/myfont.ttf differ diff --git a/bullets.lua b/bullets.lua new file mode 100644 index 0000000..d6a5d21 --- /dev/null +++ b/bullets.lua @@ -0,0 +1,51 @@ +--- +--- Created by ttwings. +--- DateTime: 2017/10/8 23:01 +--- +bullets = {} +local bullet = {x0,y0,x,y,w,h,r=0,speed,range,color} + +bullets.update = function(dt) + local vx,vy + local lx,ly + local b + for i = #bullets,1,-1 do + b = bullets[i] + vx = b.speed * math.cos(b.r)*dt + vy = b.speed * math.sin(b.r)*dt + b.x = b.x + vx + b.y = b.y + vy + lx = b.x - b.x0 + ly = b.y - b.y0 + if (lx^2 + ly^2)>b.range^2 then + table.remove(bullets,i) + end + local text = string.format("%d:%d",lx^2 + ly^2,b.range^2) + print(text) + + end + + +end + +bullets.draw = function() + for i = #bullets,1,-1 do + local b = bullets[i] + --local vx,vy + --vx = b.speed * math.cos(b.r) + --vy = b.speed * math.sin(b.r) + --b.x = b.x + vx + --b.y = b.y + vy + love.graphics.setColor(b.color) + love.graphics.rectangle("fill",b.x+16,b.y+16,b.w,b.h) + love.graphics.circle("line",b.x0+16,b.y0+16,b.range) + love.graphics.setColor({255,255,255,255}) + --love.graphics.rectangle("fill",200,200,200,200) + end +end + +bullets.add = function(bullet) + table.insert(bullets,bullet) +end + +return bullets \ No newline at end of file diff --git a/lib/colorT.lua b/lib/Color.lua similarity index 100% rename from lib/colorT.lua rename to lib/Color.lua diff --git a/lib/animation.lua b/lib/animation.lua new file mode 100644 index 0000000..89b8f3b --- /dev/null +++ b/lib/animation.lua @@ -0,0 +1,94 @@ +---by alexar, Class (Class= require "middleclass") is need +---用法:img保存动画的image对象 fx,fy,lx,ly 动画第一像素和最后一个像素位置不包含外框 +---offx,offy 动画图片间距 +---delay 动画延时 +---count 帧数,如缺省则取最大 +---mode 0 循环 1 单次 2 回转 +----1. ani=love.graphics.newAnimation(img,fx,fy,w,h,offx,offy,lx,ly,delay,count) +----2. ani:update(dt) 在update里加入 +----3. love.graphics.draw(img,ani.frame) --画包含动画image,ani.frame是一个quad +Class = require "lib/middleclass" +local animation=Class("ani") + + +function animation:initialize(img,fx,fy,w,h,offx,offy,lx,ly,delay,count) + + self.img=img + local sw,sh= img:getDimensions() + local index=0 + self.frames={} + local stop + for y=fy,ly,h+offy do + for x=fx,lx,w+offx do + local quad = love.graphics.newQuad(x, y, w, h, sw, sh) + index=index+1 + self.frames[index]=quad + if count and index+1>count then stop=true ;break end + end + if stop then break end + end + self.maxFrame=index + self.currentFrame=1 + self.mode=0 --0 for loop 1 for one time 2 for bounce + self.isRev=false + self.isPlay=true --0 for stop 1 for play 2 + self.timer=0 + self.delay=delay + self.frame=self.frames[self.currentFrame] +end + + +function animation:play() + self.isPlay=true +end + +function animation:stop() + self.isPlay=false +end + +function animation:update(dt) + local frame=self.frames[self.currentFrame] + if self.isPlay then + self.timer=self.timer+dt + if self.timer>=self.delay then + self.timer=0 + if self.isRev then + self.currentFrame=self.currentFrame-1 + if self.currentFrame<1 then + if self.mode==0 then + self.currentFrame=self.maxFrame + elseif self.mode==1 then + self.currentFrame=1 + self.isPlay=false + elseif self.mode==2 then + self.currentFrame=1 + self.isRev=not self.isRev + end + end + else + self.currentFrame=self.currentFrame+1 + if self.currentFrame>self.maxFrame then + if self.mode==0 then + self.currentFrame=1 + elseif self.mode==1 then + self.currentFrame=self.maxFrame + self.isPlay=false + elseif self.mode==2 then + self.currentFrame=self.maxFrame + self.isRev=not self.isRev + end + end + end + + end + end + self.frame=frame +end + +function animation:draw(x,y,rot,scaleX,scaleY,offx,offy) + love.graphics.draw(self.img,self.frame, x,y,rot,scaleX,scaleY,offx,offy) +end + +love.graphics.newAnimation=animation + +return animation \ No newline at end of file diff --git a/lib/guiData.lua b/lib/guiData.lua index c6bc047..48d043e 100644 --- a/lib/guiData.lua +++ b/lib/guiData.lua @@ -16,14 +16,16 @@ guiData={ ["技能2"]={visible=true,type="txt",x=300,y=760,contant="",color="RED"}, ["技能3"]={visible=true,type="txt",x=500,y=760,contant="",color="RED"}, ["技能4"]={visible=true,type="txt",x=700,y=760,contant="",color="RED"}, - ["区域"]={visible=true,type="txt",x=400,y=20,contant="",color=nil}, - ["房间"]={visible=true,type="txt",x=500,y=20,contant="",color=nil}, + ["区域"]={visible=true,type="txt",x=400,y=20,contant="",color="GREEN"}, + ["房间"]={visible=true,type="txt",x=500,y=20,contant="",color="GREEN"}, ["描述"]={visible=true,type="long",x=8,y=160,width=280,height=200,alpha=64,contant="",color=nil}, -- ["时间"]={visible=true,type="txt",x=500,y=0,contant="虎年 十二月 十日 子时 晴朗",color=nil}, ["对话"]={visible=true,type="dialog",x=500,y=160,width=280,height=100,alpha=64,contant="对话测试文本这是一段长文本的对话测试",color=nil,image=nil}, ["地图"]={visible=true,title="测试",type="map",x=1080,y=0,width=200,height=200,alpha=64,contant="",color=nil}, ["技能"]={visible=true,type="skill",x=4,y=752,width=1280,height=48,alpha=64,contant="技能栏测试",align="center",color=nil,image=nil}, ["发现"]={visible=true,type="txt",x=440,y=40,contant="",color=nil}, + ["坐标"]={visible=true,type="txt",x=240,y=40,contant="",color=nil}, + ["信息"]={visible=true,type="long",x=8,y=400,width=280,height=340,alpha=64,contant="",color=nil}, } return guiData \ No newline at end of file diff --git a/lib/guiDraw.lua b/lib/guiDraw.lua index 4445481..d29fcaa 100644 --- a/lib/guiDraw.lua +++ b/lib/guiDraw.lua @@ -3,23 +3,24 @@ local lp=love.graphics.print local lf=love.graphics.printf require "lib/guiData" require "assets/data/rooms" --- color -local colorT={ - ["RED"]={255,0,0,255}, - ["GREEN"]={0,255,0,255}, - ["MAROON"]={0xb0,0x30,0x60,0xff}, - ["VIOLET"]={0xee,0x82,0xee,0xff}, - ["PURPLE"]={0xA0,0x20,0xf0,0xff}, - ["BLUE"]={0xA0,0x20,0xf0,0xff}, -} -local font = love.graphics.newFont("assets/font/msyh.ttf", 18) +require("assets.data.Color") +---- color +--local colorT={ +-- ["RED"]={255,0,0,255}, +-- ["GREEN"]={0,255,0,255}, +-- ["MAROON"]={0xb0,0x30,0x60,0xff}, +-- ["VIOLET"]={0xee,0x82,0xee,0xff}, +-- ["PURPLE"]={0xA0,0x20,0xf0,0xff}, +-- ["BLUE"]={0xA0,0x20,0xf0,0xff}, +--} +local font = love.graphics.newFont("assets/font/myfont.ttf", 20) local text = love.graphics.newText(font,"") function guiDraw() local color={} for i, v in pairs( guiData ) do if v.visible and v.type=="txt"then -- text:setf({{255,255,0,255},v["contant"]}) - local color=colorT[v.color] or {255,255,255,255} + local color=Color[v.color] or {255,255,255,255} text:set({color,v.contant}) love.graphics.draw(text,v.x,v.y) elseif v.visible and v.type=="image" then @@ -29,14 +30,14 @@ function guiDraw() elseif v.visible and v.type=="bar" then local maxHP=v["contant"] -- lg.print(v["contant"]) - local color=colorT[v.color] or {255,255,255,255} + local color=Color[v.color] or {255,255,255,255} text:set({color,v.title ..":"}) love.graphics.draw(text,v.x,v.y) bar(maxHP,maxHP,v.x+50,v.y+26) -- bar(100,100,v.x+50,v.y+26) elseif v.visible and v.type=="long" then local alpha = v.alpha or 128 - local color = v.color or {255,255,255,255} + local color=Color[v.color] or {255,255,255,255} love.graphics.setColor(0, 0, 0, alpha) love.graphics.rectangle("fill", v.x, v.y, v.width, v.height) love.graphics.setColor(255, 255, 255, 255) @@ -47,7 +48,7 @@ function guiDraw() local image = love.graphics.newImage(dir .. v.image) love.graphics.draw(image,v.x-image:getWidth(),v.y) local alpha = v.alpha or 128 - local color = v.color or {255,255,255,255} + local color=Color[v.color] or {255,255,255,255} love.graphics.setColor(0, 0, 0, alpha) love.graphics.rectangle("fill", v.x, v.y, v.width, v.height) love.graphics.setColor(255, 255, 255, 255) @@ -55,14 +56,14 @@ function guiDraw() love.graphics.draw(text,v.x,v.y) elseif v.visible and v.type=="map" then local alpha = v.alpha or 128 - local color = v.color or {255,255,255,255} + local color=Color[v.color] or {255,255,255,255} love.graphics.print(v.title or "地图", v.x, v.y) love.graphics.setColor(0, 0, 0, alpha) love.graphics.rectangle("fill", v.x, v.y+20, v.width, v.height) love.graphics.setColor(255, 255, 255, 255) elseif v.visible and v.type=="skill" then local alpha = v.alpha or 128 - local color = v.color or {255,255,255,255} + local color=Color[v.color] or {255,255,255,255} love.graphics.setColor(0, 0, 0, alpha) love.graphics.rectangle("fill", v.x, v.y, v.width, v.height) love.graphics.setColor(255, 255, 255, 255) @@ -89,6 +90,8 @@ function guiUpdata(actor,dt) guiData["区域"].contant=actor.region guiData["地图"].title=actor.region guiData["房间"].contant=actor.room + local text = string.format("%d:%d",actor.x,actor.y) + guiData["坐标"].contant = text if rooms[actor.room] and #actor.room>2 then guiData["描述"].contant=rooms[actor.room]["description"] else @@ -97,6 +100,7 @@ function guiUpdata(actor,dt) guiData["对话"].image=actor.faceImg guiData["发现"].contant=actor.target + guiData["信息"].contant="测试信息测试信息" -- gui["精力"].contant=actor["精力"] -- gui["食物"].contant=actor["食物"] diff --git a/lib/mainColor.lua b/lib/mainColor.lua index 933417a..8f76054 100644 --- a/lib/mainColor.lua +++ b/lib/mainColor.lua @@ -1,5 +1,3 @@ - - local font26,font12,font120 local tab={} local rt=require("richtext") diff --git a/lib/messages.lua b/lib/messages.lua new file mode 100644 index 0000000..7a4e0dc --- /dev/null +++ b/lib/messages.lua @@ -0,0 +1,47 @@ +--- +--- Created by ttwings. +--- DateTime: 2017/10/9 1:11 +--- +messages = {} +local message = {text="",x0,y0,x,y,w,h,r=0,speed,range,color} + +messages.update = function(dt) + local vx,vy + local lx,ly + local b + for i = #messages,1,-1 do + b = messages[i] + vx = 0 + vy = b.speed *dt + b.x = b.x + vx + b.y = b.y - vy + lx = b.x - b.x0 + ly = b.y - b.y0 + if ly^2>b.range^2 then + table.remove(messages,i) + end + end + + +end + +messages.draw = function() + for i = #messages,1,-1 do + local b = messages[i] + --local vx,vy + --vx = b.speed * math.cos(b.r) + --vy = b.speed * math.sin(b.r) + --b.x = b.x + vx + --b.y = b.y + vy + love.graphics.setColor(b.color) + love.graphics.print(b.text,b.x+16,b.y+16) + love.graphics.setColor({255,255,255,255}) + --love.graphics.rectangle("fill",200,200,200,200) + end +end + +messages.add = function(bullet) + table.insert(messages,bullet) +end + +return messages \ No newline at end of file diff --git a/lib/richtext.lua b/lib/richtext.lua index e61c9fb..ba0444a 100644 --- a/lib/richtext.lua +++ b/lib/richtext.lua @@ -1,4 +1,3 @@ - local rt={} rt.padding = {0,0,0,0} -- top,left,bottom,right rt.margin = {0,0,0,0} -- top,left,bottom,right diff --git a/lib/time.lua b/lib/time.lua deleted file mode 100644 index 2e72c4e..0000000 --- a/lib/time.lua +++ /dev/null @@ -1,84 +0,0 @@ - --- 太阳升起,落下时间,春夏秋冬,四季不同 - calendar = { - year = 0; - season = 0; --- // month = 0; - day = 0; - hour = 0; - minute = 0; - second = 0; - } - function initCalendar(int year, int season, int day, int hour, int minute, int second) - this.year = year; - this.season = season; - this.day = day; - this.hour = hour; - this.minute = minute; - this.second = second; - end - - function getTurn() { - int ret = second / 6; - ret += minute * 10; - ret += hour * 600; - ret += day * 14400; -// ret += month * 14400 * 30; - ret += season * 14400 * 30; - ret += year * 14400 * 4 * 30; - return ret; - } - public void updata(int turn) - { - int minute_param = turn / 10; - int hour_param = minute_param / 60; - int day_param = hour_param / 24; - int season_param = day_param / 30; - second = 6 * (turn % 10); - minute = minute_param % 60; - hour = hour_param % 24; - day = day_param % 30; - season = season_param % 4; - year = season_param / 4; - } - - public void opratorAdd(int turn){ - int newTurn = getTurn()+turn; - updata(newTurn); - } - - public void opratorSub(int turn){ - int newTurn = getTurn()-turn; - updata(newTurn); - } - - public String printCalenar(){ - String snew = String.format(Vocab.CALENDAR,year(),Vocab.SEASONS[season],day,Vocab.HOURS[hour/2],weekday()); -// Gdx.app.debug("",snew); - return snew; - } - - function moon() - local moon=""; - local moon = Vocab.MOONS[day/6]; - return moon; - end - public String sun(){ - String sun; - sun = Vocab.SUNS[1]; - return sun; - } - - public String weekday(){ - String weekday; - weekday = Vocab.WEEKDAYS[day%7]; - return weekday; - } - - public String year(){ - String yearStr; - yearStr = Vocab.YEARS[year%12]; - return yearStr; - } - -} diff --git a/main.lua b/main.lua index 1448dab..282e126 100644 --- a/main.lua +++ b/main.lua @@ -1,4 +1,8 @@ local ScreenManager = require( "lib/ScreenManager" ) +require("ani") + +ani.init("Light1") + screens = { main=require( "MainScreen" ), help=require( "HelpScreen" ), @@ -11,10 +15,12 @@ end function love.draw() ScreenManager.draw() + ani.draw() end function love.update(dt) ScreenManager.update(dt) + ani.update(dt) end function love.keypressed( key )