Skip to content
Snippets Groups Projects
Commit d9e22a98 authored by dg's avatar dg
Browse files

more flyers

char info panel


git-svn-id: http://svn.net-core.org/repos/t-engine4@60 51575b47-30f0-44d4-a5cc-537603b46e54
parent db8b33e0
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,7 @@ function _M:init(keyhandler)
self.w, self.h = core.display.size()
self.dialogs = {}
self.save_name = "player"
self.player_name = "player"
self.mouse = engine.Mouse.new()
self.mouse:setCurrent()
......@@ -29,6 +30,12 @@ function _M:loaded()
self.mouse:setCurrent()
end
--- Sets the player name
function _M:setPlayerName(name)
self.save_name = name
self.player_name = name
end
--- Starts the game
-- Modules should reimplement it to do whatever their game needs
function _M:run()
......
require "engine.class"
--- Module that handles message history ina mouse wheel scrollable zone
module(..., package.seeall, class.make)
--- Creates the log zone
function _M:init(x, y, w, h, max, fontname, fontsize, color, bgcolor)
self.color = color or {255,255,255}
self.bgcolor = bgcolor or {0,0,0}
......@@ -17,6 +19,10 @@ function _M:init(x, y, w, h, max, fontname, fontsize, color, bgcolor)
self.changed = true
end
--- Appends text to the log
-- This method is set as the call methamethod too, this means it is usable like this:<br/>
-- log = LogDisplay.new(...)<br/>
-- log("foo %s", s)
function _M:call(str, ...)
local lines = str:format(...):splitLines(self.w - 4, self.font)
for i = 1, #lines do
......@@ -29,6 +35,7 @@ function _M:call(str, ...)
self.changed = true
end
--- Clear the log
function _M:empty()
self.log = {}
self.changed = true
......@@ -51,6 +58,8 @@ function _M:display()
return self.surface
end
--- Scroll the zone
-- @param i number representing how many lines to scroll
function _M:scrollUp(i)
self.scroll = self.scroll + i
if self.scroll > #self.log - 1 then self.scroll = #self.log - 1 end
......
......@@ -18,6 +18,7 @@ local Actor = require "mod.class.Actor"
local ActorStats = require "engine.interface.ActorStats"
local ActorAbilities = require "engine.interface.ActorAbilities"
local Player = require "mod.class.Player"
local PlayerDisplay = require "mod.class.PlayerDisplay"
local NPC = require "mod.class.NPC"
module(..., package.seeall, class.inherit(engine.GameTurnBased))
......@@ -43,6 +44,7 @@ function _M:run()
ActorAbilities:loadDefinition("/data/abilities.lua")
self.log = LogDisplay.new(0, self.h * 0.80, self.w * 0.5, self.h * 0.20, nil, nil, nil, {255,255,255}, {30,30,30})
self.player_display = PlayerDisplay.new(0, 0, self.w * 0.2, self.h * 0.8, {30,30,0})
self.calendar = Calendar.new("/data/calendar_rivendell.lua", "Today is the %s %s of the %s year of the Fourth Age of Middle-earth.\nThe time is %02d:%02d.", 122)
self.tooltip = Tooltip.new(nil, nil, {255,255,255}, {30,30,30})
self.flyers = FlyingText.new()
......@@ -68,16 +70,14 @@ end
function _M:newGame()
self.zone = Zone.new("ancient_ruins")
self.player = Player.new{name="player", image='player.png', display='@', color_r=230, color_g=230, color_b=230}
self.player = Player.new{name=self.player_name, image='player.png', display='@', color_r=230, color_g=230, color_b=230}
self:changeLevel(1)
-- self:registerDialog(require('mod.dialogs.EnterName').new())
end
function _M:loaded()
Zone:setup{npc_class="mod.class.NPC", grid_class="mod.class.Grid", object_class="engine.Entity"}
-- Map:setViewPort(0, 0, self.w, math.floor(self.h * 0.80), 20, 20, "/data/font/10X20.FON", 20)
Map:setViewPort(self.w * 0.2, 0, self.w * .8, math.floor(self.h * 0.80), 16, 16)
Map:setViewPort(self.w * 0.2, 0, self.w * 0.8, math.floor(self.h * 0.80), 16, 16)
engine.GameTurnBased.loaded(self)
self.key = engine.KeyCommand.new()
end
......@@ -115,6 +115,7 @@ end
function _M:display()
self.log:display():toScreen(self.log.display_x, self.log.display_y)
self.player_display:display():toScreen(self.player_display.display_x, self.player_display.display_y)
if self.level and self.level.map then
-- Display the map and compute FOV for the player if needed
......
......@@ -32,6 +32,12 @@ function _M:setName(name)
game.save_name = name
end
function _M:levelup()
local x, y = game.level.map:getTileToScreen(self.x, self.y)
game.flyers:add(x, y, 80, 0.5, -2, "LEVEL UP!", {0,255,255})
game.log("#00ffff#Welcome to level %d", self.level)
end
--- Tries to get a target from the user
-- *WARNING* If used inside a coroutine it will yield and resume it later when a target is found.
-- This is usualy just what you want so dont think too much about it :)
......
require "engine.class"
module(..., package.seeall, class.make)
function _M:init(x, y, w, h, bgcolor)
self.display_x = x
self.display_y = y
self.w, self.h = w, h
self.bgcolor = bgcolor
self.font = core.display.newFont("/data/font/VeraMono.ttf", 14)
self.font_h = self.font:lineSkip()
self.surface = core.display.newSurface(w, h)
end
-- Displays the stats
function _M:display()
self.surface:erase(self.bgcolor[1], self.bgcolor[2], self.bgcolor[3])
local cur_exp, max_exp = game.player.exp, game.player:getExpChart(game.player.level+1)
local h = 0
self.surface:drawString(self.font, game.player.name, 0, h, 0, 200, 255) h = h + self.font_h
self.surface:drawString(self.font, "Human", 0, h, 0, 200, 255) h = h + self.font_h
h = h + self.font_h
self.surface:drawString(self.font, "Level: "..game.player.level, 0, h, 255, 255, 255) h = h + self.font_h
self.surface:drawString(self.font, ("Exp: %2d%%"):format(100 * cur_exp / max_exp), 0, h, 255, 255, 255) h = h + self.font_h
return self.surface
end
......@@ -3,7 +3,7 @@ return {
{
name = "dragon of death",
display = "D", color_r=255,
level = 1, exp_worth = 1,
level = 10, exp_worth = 1,
life = 20,
mana = 1000,
energy = { mod=0.5 },
......@@ -15,7 +15,7 @@ return {
name = "baby dragon",
display = "d", color_r=128,
faction = "poorsods",
level = 1, exp_worth = 1,
level = 10, exp_worth = 1,
life = 30,
mana = 1000,
energy = { mod=0.3 },
......
......@@ -44,6 +44,12 @@ function _M:commandLineArgs(args)
if mod then
local M = mod.load()
_G.game = M.new()
-- Delete the corresponding savefile if any
local save = engine.Savefile.new(_G.game.save_name)
save:delete()
save:close()
_G.game:run()
else
print("Error: module "..req_mod.." not found!")
......@@ -90,9 +96,7 @@ function _M:selectStepNew()
for i, mod in ipairs(self.mod_list) do
mod.fct = function()
local M = mod.load()
_G.game = M.new()
_G.game:run()
self:registerDialog(require('special.mainmenu.dialogs.EnterName').new(mod))
end
mod.onSelect = function()
display_module.title = mod.long_name
......
require "engine.class"
require "engine.Dialog"
require "engine.Savefile"
module(..., package.seeall, class.inherit(engine.Dialog))
function _M:init()
engine.Dialog.init(self, "Enter your name?", 300, 100)
function _M:init(runmod)
engine.Dialog.init(self, "Enter your character's name?", 300, 100)
self.runmod = runmod
self.name = ""
self:keyCommands{
_RETURN = function()
if self.name:len() >= 3 then
game:unregisterDialog(self)
game.player:setName(self.name)
-- Ok run the module
local M = self.runmod.load()
_G.game = M.new()
_G.game:setPlayerName(self.name)
-- Delete the corresponding savefile if any
local save = engine.Savefile.new(_G.game.save_name)
save:delete()
save:close()
-- And now run it!
_G.game:run()
else
engine.Dialog:simplePopup("Error", "Character name must be between 3 and 25 characters.")
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment