nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge: Extends chars, string and stream with some whitespace-related function
[nit.git]
/
lib
/
mnit
/
tileset.nit
diff --git
a/lib/mnit/tileset.nit
b/lib/mnit/tileset.nit
index
7b473f3
..
5bd5d4d
100644
(file)
--- a/
lib/mnit/tileset.nit
+++ b/
lib/mnit/tileset.nit
@@
-28,12
+28,8
@@
class TileSet
# The height of a tile
var height: Int
# The height of a tile
var height: Int
- init(image: Image, width: Int, height: Int)
+ init
do
do
- self.image = image
- self.width = width
- self.height = height
-
self.nb_cols = image.width / width
self.nb_rows = image.height / height
self.nb_cols = image.width / width
self.nb_rows = image.height / height
@@
-45,13
+41,13
@@
class TileSet
end
# The number of columns of tiles in the image
end
# The number of columns of tiles in the image
- var nb_cols: Int
+ var nb_cols: Int is noinit
# The number of rows of tiles in the image
# The number of rows of tiles in the image
- var nb_rows: Int
+ var nb_rows: Int is noinit
# Cache for images of tiles
# Cache for images of tiles
- private var subimages = new Array[Image]
+ var subimages = new Array[Image]
# The subimage of given tile
# Aborts if x or y are out of bound
# The subimage of given tile
# Aborts if x or y are out of bound
@@
-72,19
+68,13
@@
class TileSetFont
# Use space (' ') for holes in the tileset
var chars: String
# Use space (' ') for holes in the tileset
var chars: String
- init(image: Image, width: Int, height: Int, chars: String)
- do
- super
- self.chars = chars
- end
-
# Additional space to insert horizontally between characters
# A negave value will display tile overlaped
# Additional space to insert horizontally between characters
# A negave value will display tile overlaped
- var hspace: Int writable = 0
+ var hspace: Numeric = 0.0 is writable
# Additional space to insert vertically between characters
# A negave value will display tile overlaped
# Additional space to insert vertically between characters
# A negave value will display tile overlaped
- var vspace: Int writable = 0
+ var vspace: Numeric = 0.0 is writable
# The glyph (tile) associated to the caracter `c` according to `chars`
# Returns null if `c` is not in `chars`
# The glyph (tile) associated to the caracter `c` according to `chars`
# Returns null if `c` is not in `chars`
@@
-99,12
+89,13
@@
end
redef class Display
# Blit the text using a monospace bitmap font
# '\n' are rendered as carriage return
redef class Display
# Blit the text using a monospace bitmap font
# '\n' are rendered as carriage return
- fun text(text: String, font: TileSetFont, x, y: Int)
+ fun text(text: String, font: TileSetFont, x, y: Numeric)
do
do
+ x = x.to_f
var cx = x
var cx = x
- var cy = y
- var sw = font.width + font.hspace
- var sh = font.height + font.vspace
+ var cy = y.to_f
+ var sw = font.width.to_f + font.hspace.to_f
+ var sh = font.height.to_f + font.vspace.to_f
for c in text.chars do
if c == '\n' then
cx = x
for c in text.chars do
if c == '\n' then
cx = x