-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDim.lua
More file actions
72 lines (51 loc) · 2.52 KB
/
Dim.lua
File metadata and controls
72 lines (51 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
-- Dim.lua
local Dim = {}
Dim.__index = Dim -- failed table lookups on the instances should fallback to the class table, to get methods
-- "At the beginning of the game, each player draws seven tiles from the bag and places them on their rack"
function Dim.new(width, height)
local o = {}
setmetatable(o, Dim)
o.numX = width
o.numY = height
-- safeAreaInsets reports top=126, left=0, bottom=97, right=0 for iPhone X
local topInset, leftInset, bottomInset, rightInset = display.getSafeAreaInsets()
o.topInset = topInset
local xQ = math.floor(display.actualContentWidth/o.numX)
local yQ = math.floor(display.actualContentHeight / (o.numY + 3)) -- add for statusbar, wordbar, toolbar
-- trace('Dim reports Qx, Qy', xQ, yQ)
o.Q = math.min(xQ, yQ)
o.halfQ = o.Q * 0.5
o.quarterQ = o.Q * 0.24
o.size3D = o.Q * 0.95
o.offset3D = o.Q * 0.025
o.tileFontSize = o.Q * 0.75
-- o.bannerHeight = o.Q
-- o.bannerX = display.contentCenterX
-- o.bannerY = topInset - display.screenOriginY + (o.bannerHeight / 2)
-- o.bannerWidth = display.actualContentWidth
o.statusbarHeight = o.Q / 2
o.statusbarX = display.contentCenterX
o.statusbarY = topInset - display.screenOriginY + (o.statusbarHeight / 2)
o.statusbarWidth = display.actualContentWidth
o.wordbarHeight = o.Q
o.wordbarX = display.contentCenterX
o.wordbarY = topInset - display.screenOriginY + o.statusbarHeight + (o.wordbarHeight / 2)
o.wordbarWidth = display.actualContentWidth
o.toolbarHeight = o.Q
o.toolbarX = display.contentCenterX
o.toolbarY = display.actualContentHeight - (o.toolbarHeight / 2) - bottomInset
o.toolbarWidth = display.actualContentWidth
o.baizeHeight = display.actualContentHeight - o.statusbarHeight - o.toolbarHeight - o.wordbarHeight
-- o.numX = math.floor(display.actualContentWidth / o.Q)
-- o.numY = math.floor(contentHeight / o.Q)
trace('baize height', o.baizeHeight, 'tiles height', o.numY * o.Q)
-- firstTileX, firstTileY is the coord of the centerpoint of the first slot (1,1)
o.firstTileX = (display.actualContentWidth - (o.numX * o.Q)) / 2
o.firstTileX = o.firstTileX + leftInset
-- o.firstTileY = ((o.toolbarHeight + o.statusbarHeight + (o.Q * o.numY)) - display.actualContentHeight) / 2
-- o.firstTileY = o.toolbarHeight + (display.actualContentHeight - (o.numY * o.Q)) / 2
-- o.firstTileY = (display.actualContentHeight - (o.numY * o.Q)) / 2
o.firstTileY = topInset - display.screenOriginY + o.statusbarHeight + o.wordbarHeight + ((o.baizeHeight - (o.numY * o.Q)) / 2)
return o
end
return Dim