Engine 0.0.4
Game engine in lua
Loading...
Searching...
No Matches
draw.lua
Go to the documentation of this file.
1local modes = {
2 [true] = {
3 [0] = true,
4 [1] = false
5 },
6 [false] = {
7 [0] = 'fill',
8 [1] = 'line'
9 }
10}
11
12local function color(c)
13 local DIV = love.wiimote and 1 or 255
14 local R = bit.band(bit.rshift(c, 24), 0xFF)/DIV
15 local G = bit.band(bit.rshift(c, 16), 0xFF)/DIV
16 local B = bit.band(bit.rshift(c, 8), 0xFF)/DIV
17 local A = bit.band(bit.rshift(c, 0), 0xFF)/DIV
18 love.graphics.setColor(R, G, B, A)
19end
20
21local function rect(a,b,c,d,e,f)
22 love.graphics.rectangle(modes[love.wiimote ~= nil][a], b, c, d, e)
23end
24
25--! @todo support WII
26local function text(x, y, text)
27 if love.wiimote then return 32 end
28 if x and y then
29 love.graphics.print(text, x, y)
30 end
31 return love.graphics.getFont():getWidth(text or x)
32end
33
34local function line(x1, y1, x2, y2)
35 love.graphics.line(x1, y1, x2, y2)
36end
37
38--! @todo implement it!
39local function font(a, b)
40
41end
42
43local function install(std, game, application)
44 std = std or {}
45 std.draw = std.draw or {}
46 application.callbacks.draw = application.callbacks.draw or function() end
47
48 std.draw.clear = function(c)
49 color(c)
50 love.graphics.rectangle(modes[love.wiimote ~= nil][0], 0, 0, game.width, game.height)
51 end
52
58
59 if love then
60 love.draw = function()
61 application.callbacks.draw(std, game)
62 if std.draw.fps then
63 std.draw.fps(game.fps_show, 8, 8)
64 end
65 end
66 love.resize = function(w, h)
67 game.width, game.height = w, h
68 end
69 end
70
71 return std.draw
72end
73
74local P = {
76}
77
78return P
local function fps(self, show, x, y)
local application
Definition main.lua:16
local game
Definition main.lua:17
local std
Definition main.lua:18
local color
Definition main.lua:12
local function install(std, lgame, application, ginga)
local function line(x1, y1, x2, y2)
local function clear(c)
local function font(a, b)
local function rect(mode, x, y, width, height)
local function text(x, y, text)
local function draw(std, game)